diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-08 18:44:18 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-08 18:44:18 +0000 |
commit | 55e354ac0e294bde258420f80a2cc11ea19db482 (patch) | |
tree | 0fcf726b9cb30296a4c023c49f64387783020f4c /include/llvm/Analysis/LoopInfo.h | |
parent | 63cd7e557c642e9b6e67f0ac3b19a9456d7e2306 (diff) | |
download | external_llvm-55e354ac0e294bde258420f80a2cc11ea19db482.zip external_llvm-55e354ac0e294bde258420f80a2cc11ea19db482.tar.gz external_llvm-55e354ac0e294bde258420f80a2cc11ea19db482.tar.bz2 |
Add a basic static ProfileInfo provider (ProfileEstimatorPass).
- Part of optimal static profiling patch sequence by Andreas Neustifter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78484 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/LoopInfo.h')
-rw-r--r-- | include/llvm/Analysis/LoopInfo.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 7ce6a4e..fd12e66 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -213,6 +213,25 @@ public: return 0; } + /// getExitEdges - Return all pairs of (_inside_block_,_outside_block_). + /// (Modelled after getExitingBlocks().) + typedef std::pair<const BlockT*,const BlockT*> Edge; + void getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const { + // Sort the blocks vector so that we can use binary search to do quick + // lookups. + SmallVector<BlockT*, 128> LoopBBs(block_begin(), block_end()); + std::sort(LoopBBs.begin(), LoopBBs.end()); + + typedef GraphTraits<BlockT*> BlockTraits; + for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) + for (typename BlockTraits::ChildIteratorType I = + BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); + I != E; ++I) + if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) + // Not in current loop? It must be an exit block. + ExitEdges.push_back(std::make_pair(*BI,*I)); + } + /// getUniqueExitBlocks - Return all unique successor blocks of this loop. /// These are the blocks _outside of the current loop_ which are branched to. /// This assumes that loop is in canonical form. |