36 Slot =
new AllocaInst(
I.getType(),
DL.getAllocaAddrSpace(),
nullptr,
37 I.getName()+
".reg2mem", AllocaPoint);
39 Slot =
new AllocaInst(
I.getType(),
DL.getAllocaAddrSpace(),
nullptr,
40 I.getName() +
".reg2mem", &
F->getEntryBlock().front());
47 if (!II->getNormalDest()->getSinglePredecessor()) {
51 assert(BB &&
"Unable to split critical edge.");
57 while (!
I.use_empty()) {
59 if (
PHINode *PN = dyn_cast<PHINode>(U)) {
70 for (
unsigned i = 0,
e = PN->getNumIncomingValues(); i !=
e; ++i)
71 if (PN->getIncomingValue(i) == &
I) {
72 Value *&V = Loads[PN->getIncomingBlock(i)];
75 V =
new LoadInst(
I.getType(), Slot,
I.getName() +
".reload",
77 PN->getIncomingBlock(i)->getTerminator());
79 PN->setIncomingValue(i, V);
94 if (!
I.isTerminator()) {
95 InsertPt = ++
I.getIterator();
96 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
111 if (
P->use_empty()) {
112 P->eraseFromParent();
121 Slot =
new AllocaInst(
P->getType(),
DL.getAllocaAddrSpace(),
nullptr,
122 P->getName()+
".reg2mem", AllocaPoint);
125 Slot =
new AllocaInst(
P->getType(),
DL.getAllocaAddrSpace(),
nullptr,
126 P->getName() +
".reg2mem",
127 &
F->getEntryBlock().front());
131 for (
unsigned i = 0,
e =
P->getNumIncomingValues(); i <
e; ++i) {
132 if (
InvokeInst *II = dyn_cast<InvokeInst>(
P->getIncomingValue(i))) {
133 assert(II->getParent() !=
P->getIncomingBlock(i) &&
134 "Invoke edge not supported yet"); (void)II;
137 P->getIncomingBlock(i)->getTerminator());
143 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
147 new LoadInst(
P->getType(), Slot,
P->getName() +
".reload", &*InsertPt);
148 P->replaceAllUsesWith(V);
151 P->eraseFromParent();
A parsed version of the target data layout string in and methods for querying it.
AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, Instruction *AllocaPoint=nullptr)
This function takes a virtual register computed by an Instruction and replaces it with a slot in the ...
This class represents lattice values for constants.
An instruction for reading from memory.
An instruction for storing to memory.
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM Basic Block Representation.
BasicBlock * SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
If this edge is a critical edge, insert a new node to split the critical edge.
bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges=false)
Return true if the specified edge is a critical edge.
BasicBlock * getNormalDest() const
Iterator for intrusive lists based on ilist_node.
unsigned GetSuccessorNumber(const BasicBlock *BB, const BasicBlock *Succ)
Search for the specified successor of basic block BB and return its position in the terminator instru...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
AllocaInst * DemotePHIToStack(PHINode *P, Instruction *AllocaPoint=nullptr)
This function takes a virtual register computed by a phi node and replaces it with a slot in the stac...
LLVM Value Representation.
an instruction to allocate memory on the stack
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL