35 Slot =
new AllocaInst(
I.getType(),
DL.getAllocaAddrSpace(),
nullptr,
36 I.getName()+
".reg2mem", AllocaPoint);
38 Slot =
new AllocaInst(
I.getType(),
DL.getAllocaAddrSpace(),
nullptr,
39 I.getName() +
".reg2mem", &
F->getEntryBlock().front());
46 if (!II->getNormalDest()->getSinglePredecessor()) {
50 assert(BB &&
"Unable to split critical edge.");
56 while (!
I.use_empty()) {
58 if (
PHINode *PN = dyn_cast<PHINode>(U)) {
69 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
70 if (PN->getIncomingValue(i) == &
I) {
71 Value *&V = Loads[PN->getIncomingBlock(i)];
74 V =
new LoadInst(
I.getType(), Slot,
I.getName() +
".reload",
76 PN->getIncomingBlock(i)->getTerminator());
77 Loads[PN->getIncomingBlock(i)] = V;
79 PN->setIncomingValue(i, V);
86 U->replaceUsesOfWith(&
I, V);
94 if (!
I.isTerminator()) {
95 InsertPt = ++
I.getIterator();
97 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
98 if (isa<CatchSwitchInst>(InsertPt))
100 if (isa<CatchSwitchInst>(InsertPt)) {
102 new StoreInst(&
I, Slot, &*Handler->getFirstInsertionPt());
118 if (
P->use_empty()) {
119 P->eraseFromParent();
128 Slot =
new AllocaInst(
P->getType(),
DL.getAllocaAddrSpace(),
nullptr,
129 P->getName()+
".reg2mem", AllocaPoint);
132 Slot =
new AllocaInst(
P->getType(),
DL.getAllocaAddrSpace(),
nullptr,
133 P->getName() +
".reg2mem",
134 &
F->getEntryBlock().front());
138 for (
unsigned i = 0, e =
P->getNumIncomingValues(); i < e; ++i) {
139 if (
InvokeInst *II = dyn_cast<InvokeInst>(
P->getIncomingValue(i))) {
140 assert(II->getParent() !=
P->getIncomingBlock(i) &&
141 "Invoke edge not supported yet"); (void)II;
144 P->getIncomingBlock(i)->getTerminator());
150 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
151 if (isa<CatchSwitchInst>(InsertPt))
153 if (isa<CatchSwitchInst>(InsertPt)) {
156 for (
User *U :
P->users()) {
167 new LoadInst(
P->getType(), Slot,
P->getName() +
".reload", &*InsertPt);
168 P->replaceAllUsesWith(V);
171 P->eraseFromParent();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseMap class.
iv Induction Variable Users
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
an instruction to allocate memory on the stack
LLVM Basic Block Representation.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
InstListType::iterator iterator
Instruction iterators...
A parsed version of the target data layout string in and methods for querying it.
BasicBlock * getNormalDest() const
An instruction for reading from memory.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
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...
auto successors(const MachineBasicBlock *BB)
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.
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 ...
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...