diff options
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 46c0eaabe1a..a6d8b55c08f 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -336,9 +336,8 @@ bool Loop::hasDedicatedExits() const { SmallVector<BasicBlock *, 4> ExitBlocks; getExitBlocks(ExitBlocks); for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) - for (pred_iterator PI = pred_begin(ExitBlocks[i]), - PE = pred_end(ExitBlocks[i]); PI != PE; ++PI) - if (!contains(*PI)) + for (BasicBlock *Pred : predecessors(ExitBlocks[i])) + if (!contains(Pred)) return false; // All the requirements are met. return true; @@ -360,12 +359,12 @@ Loop::getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const { BasicBlock *current = *BI; switchExitBlocks.clear(); - for (succ_iterator I = succ_begin(*BI), E = succ_end(*BI); I != E; ++I) { + for (BasicBlock *Succ : successors(*BI)) { // If block is inside the loop then it is not a exit block. - if (contains(*I)) + if (contains(Succ)) continue; - pred_iterator PI = pred_begin(*I); + pred_iterator PI = pred_begin(Succ); BasicBlock *firstPred = *PI; // If current basic block is this exit block's first predecessor @@ -379,17 +378,17 @@ Loop::getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const { // then it is possible that there are multiple edges from current block // to one exit block. if (std::distance(succ_begin(current), succ_end(current)) <= 2) { - ExitBlocks.push_back(*I); + ExitBlocks.push_back(Succ); continue; } // In case of multiple edges from current block to exit block, collect // only one edge in ExitBlocks. Use switchExitBlocks to keep track of // duplicate edges. - if (std::find(switchExitBlocks.begin(), switchExitBlocks.end(), *I) + if (std::find(switchExitBlocks.begin(), switchExitBlocks.end(), Succ) == switchExitBlocks.end()) { - switchExitBlocks.push_back(*I); - ExitBlocks.push_back(*I); + switchExitBlocks.push_back(Succ); + ExitBlocks.push_back(Succ); } } } |