mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
add a method
llvm-svn: 31249
This commit is contained in:
parent
93414d06c4
commit
44b3550217
@ -107,6 +107,12 @@ public:
|
||||
// induction variable canonicalization pass should be used to normalize loops
|
||||
// for easy analysis. These methods assume canonical loops.
|
||||
|
||||
/// 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 getExitingBlocks(std::vector<BasicBlock*> &Blocks) const;
|
||||
|
||||
/// getExitBlocks - Return all of the successor blocks of this loop. These
|
||||
/// are the blocks _outside of the current loop_ which are branched to.
|
||||
///
|
||||
|
@ -332,6 +332,26 @@ void LoopInfo::removeBlock(BasicBlock *BB) {
|
||||
// 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.
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user