28 : NextInstPos(0), BB(BasicB) {
29 LastInstFound = BB->
end();
34 bool OrderedBasicBlock::comesBefore(
const Instruction *A,
37 assert(!(LastInstFound == BB->
end() && NextInstPos != 0) &&
38 "Instruction supposed to be in NumberedInsts");
39 assert(A->
getParent() == BB &&
"Instruction supposed to be in the block!");
40 assert(B->
getParent() == BB &&
"Instruction supposed to be in the block!");
43 auto II = BB->
begin();
45 if (LastInstFound !=
IE)
46 II = std::next(LastInstFound);
49 for (; II !=
IE; ++II) {
50 Inst = cast<Instruction>(II);
51 NumberedInsts[Inst] = NextInstPos++;
52 if (Inst == A || Inst == B)
56 assert(II !=
IE &&
"Instruction not found?");
57 assert((Inst == A || Inst == B) &&
"Should find A or B");
68 "Instructions must be in the same basic block!");
69 assert(A->
getParent() == BB &&
"Instructions must be in the tracked block!");
77 auto NAI = NumberedInsts.find(A);
78 auto NBI = NumberedInsts.find(B);
79 if (NAI != NumberedInsts.end() && NBI != NumberedInsts.end())
80 return NAI->second < NBI->second;
81 if (NAI != NumberedInsts.end())
83 if (NBI != NumberedInsts.end())
86 return comesBefore(A, B);
90 if (LastInstFound != BB->
end() && I == &*LastInstFound) {
91 if (LastInstFound == BB->
begin()) {
92 LastInstFound = BB->
end();
98 NumberedInsts.erase(I);
103 auto OI = NumberedInsts.find(Old);
104 if (OI == NumberedInsts.end())
107 NumberedInsts.insert({New, OI->second});
108 if (LastInstFound != BB->
end() && Old == &*LastInstFound)
110 NumberedInsts.erase(Old);
void eraseInstruction(const Instruction *I)
Remove from the ordering, if it is present.
OrderedBasicBlock(const BasicBlock *BasicB)
This class represents lattice values for constants.
bool dominates(const Instruction *A, const Instruction *B)
Find out whether A dominates B, meaning whether A comes before B in BB.
iterator begin()
Instruction iterator methods.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
LLVM Basic Block Representation.
self_iterator getIterator()
void replaceInstruction(const Instruction *Old, const Instruction *New)
Replace Old with New in the ordering.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock * getParent() const