Changes in directory llvm/lib/Analysis:
LoopInfo.cpp updated: 1.78 -> 1.79 --- Log message: add a method --- Diffs of the changes: (+20 -0) LoopInfo.cpp | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+) Index: llvm/lib/Analysis/LoopInfo.cpp diff -u llvm/lib/Analysis/LoopInfo.cpp:1.78 llvm/lib/Analysis/LoopInfo.cpp:1.79 --- llvm/lib/Analysis/LoopInfo.cpp:1.78 Tue Aug 29 17:29:16 2006 +++ llvm/lib/Analysis/LoopInfo.cpp Fri Oct 27 20:24:05 2006 @@ -332,6 +332,26 @@ // APIs for simple analysis of the loop. // +/// getExitingBlocks - Return all blocks inside the loop that have successors +/// outside of the loop. These are the blocks _inside of the current loop_ +/// which branch out. The returned list is always unique. +/// +void Loop::getExitingBlocks(std::vector<BasicBlock*> &ExitingBlocks) const { + // Sort the blocks vector so that we can use binary search to do quick + // lookups. + std::vector<BasicBlock*> LoopBBs(block_begin(), block_end()); + std::sort(LoopBBs.begin(), LoopBBs.end()); + + for (std::vector<BasicBlock*>::const_iterator BI = Blocks.begin(), + BE = Blocks.end(); BI != BE; ++BI) + for (succ_iterator I = succ_begin(*BI), E = succ_end(*BI); I != E; ++I) + if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) { + // Not in current loop? It must be an exit block. + ExitingBlocks.push_back(*BI); + break; + } +} + /// getExitBlocks - Return all of the successor blocks of this loop. These /// are the blocks _outside of the current loop_ which are branched to. /// _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits