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 | |
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')
-rw-r--r-- | include/llvm/Analysis/LoopInfo.h | 19 | ||||
-rw-r--r-- | include/llvm/Analysis/Passes.h | 9 | ||||
-rw-r--r-- | include/llvm/LinkAllPasses.h | 1 |
3 files changed, 29 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. diff --git a/include/llvm/Analysis/Passes.h b/include/llvm/Analysis/Passes.h index 35bd821..e5b86e8 100644 --- a/include/llvm/Analysis/Passes.h +++ b/include/llvm/Analysis/Passes.h @@ -21,6 +21,7 @@ namespace llvm { class LoopPass; class ModulePass; class Pass; + class PassInfo; class LibCallInfo; //===--------------------------------------------------------------------===// @@ -93,6 +94,14 @@ namespace llvm { //===--------------------------------------------------------------------===// // + // createProfileEstimatorPass - This pass estimates profiling information + // instead of loading it from a previous run. + // + FunctionPass *createProfileEstimatorPass(); + extern const PassInfo *ProfileEstimatorPassID; + + //===--------------------------------------------------------------------===// + // // createDSAAPass - This pass implements simple context sensitive alias // analysis. // diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index c0cd766..52bca9d 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -92,6 +92,7 @@ namespace { (void) llvm::createLowerSwitchPass(); (void) llvm::createNoAAPass(); (void) llvm::createNoProfileInfoPass(); + (void) llvm::createProfileEstimatorPass(); (void) llvm::createProfileLoaderPass(); (void) llvm::createPromoteMemoryToRegisterPass(); (void) llvm::createDemoteRegisterToMemoryPass(); |