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());
78 PN->setIncomingValue(i, V);
93 if (!
I.isTerminator()) {
94 InsertPt = ++
I.getIterator();
96 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
97 if (isa<CatchSwitchInst>(InsertPt))
99 if (isa<CatchSwitchInst>(InsertPt)) {
101 new StoreInst(&
I, Slot, &*Handler->getFirstInsertionPt());
117 if (
P->use_empty()) {
118 P->eraseFromParent();
127 Slot =
new AllocaInst(
P->getType(),
DL.getAllocaAddrSpace(),
nullptr,
128 P->getName()+
".reg2mem", AllocaPoint);
131 Slot =
new AllocaInst(
P->getType(),
DL.getAllocaAddrSpace(),
nullptr,
132 P->getName() +
".reg2mem",
133 &
F->getEntryBlock().front());
137 for (
unsigned i = 0, e =
P->getNumIncomingValues(); i < e; ++i) {
138 if (
InvokeInst *II = dyn_cast<InvokeInst>(
P->getIncomingValue(i))) {
139 assert(II->getParent() !=
P->getIncomingBlock(i) &&
140 "Invoke edge not supported yet"); (void)II;
143 P->getIncomingBlock(i)->getTerminator());
149 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
150 if (isa<CatchSwitchInst>(InsertPt))
152 if (isa<CatchSwitchInst>(InsertPt)) {
155 for (
User *U :
P->users()) {
166 new LoadInst(
P->getType(), Slot,
P->getName() +
".reload", &*InsertPt);
167 P->replaceAllUsesWith(V);
170 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...