void llvm::FindFunctionBackedges(const Function &F,
SmallVectorImpl<std::pair<const BasicBlock*,const BasicBlock*> > &Result) {
const BasicBlock *BB = &F.getEntryBlock();
- if (succ_begin(BB) == succ_end(BB))
+ if (succ_empty(BB))
return;
SmallPtrSet<const BasicBlock*, 8> Visited;
return L1 != nullptr && L1 == L2;
}
-static bool isPotentiallyReachableInner(SmallVectorImpl<BasicBlock *> &Worklist,
- BasicBlock *StopBB,
- const DominatorTree *DT,
- const LoopInfo *LI) {
+bool llvm::isPotentiallyReachableFromMany(
+ SmallVectorImpl<BasicBlock *> &Worklist, BasicBlock *StopBB,
+ const DominatorTree *DT, const LoopInfo *LI) {
// When the stop block is unreachable, it's dominated from everywhere,
// regardless of whether there's a path between the two blocks.
if (DT && !DT->isReachableFromEntry(StopBB))
SmallVector<BasicBlock*, 32> Worklist;
Worklist.push_back(const_cast<BasicBlock*>(A));
- return isPotentiallyReachableInner(Worklist, const_cast<BasicBlock*>(B),
- DT, LI);
+ return isPotentiallyReachableFromMany(Worklist, const_cast<BasicBlock *>(B),
+ DT, LI);
}
bool llvm::isPotentiallyReachable(const Instruction *A, const Instruction *B,
return true;
// Linear scan, start at 'A', see whether we hit 'B' or the end first.
- for (BasicBlock::const_iterator I = A, E = BB->end(); I != E; ++I) {
+ for (BasicBlock::const_iterator I = A->getIterator(), E = BB->end(); I != E;
+ ++I) {
if (&*I == B)
return true;
}
if (B->getParent() == &A->getParent()->getParent()->getEntryBlock())
return false;
- return isPotentiallyReachableInner(Worklist,
- const_cast<BasicBlock*>(B->getParent()),
- DT, LI);
+ return isPotentiallyReachableFromMany(
+ Worklist, const_cast<BasicBlock *>(B->getParent()), DT, LI);
}