diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-14 06:58:59 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-14 06:58:59 +0000 |
commit | 858cb8a5e07d4fe4b516a99eef7e8c028516a679 (patch) | |
tree | ff34da69a12554b93f8bc94551280ae165b40cb7 /lib/Analysis | |
parent | e11c4db848d4b9c0e8a2bd1752ec87a451ff3a55 (diff) | |
download | external_llvm-858cb8a5e07d4fe4b516a99eef7e8c028516a679.zip external_llvm-858cb8a5e07d4fe4b516a99eef7e8c028516a679.tar.gz external_llvm-858cb8a5e07d4fe4b516a99eef7e8c028516a679.tar.bz2 |
ProfileInfo interface tweaks.
- Add getExecutionCount(const Function).
- Add helper Edge type.
- constify.
- No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ProfileInfo.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp index a0965b6..26328d0 100644 --- a/lib/Analysis/ProfileInfo.cpp +++ b/lib/Analysis/ProfileInfo.cpp @@ -26,8 +26,8 @@ char ProfileInfo::ID = 0; ProfileInfo::~ProfileInfo() {} -unsigned ProfileInfo::getExecutionCount(BasicBlock *BB) const { - pred_iterator PI = pred_begin(BB), PE = pred_end(BB); +unsigned ProfileInfo::getExecutionCount(const BasicBlock *BB) const { + pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); // Are there zero predecessors of this block? if (PI == PE) { @@ -49,23 +49,23 @@ unsigned ProfileInfo::getExecutionCount(BasicBlock *BB) const { // has a LARGE number of in-edges. Handle the common case of having only a // few in-edges with special code. // - BasicBlock *FirstPred = *PI; + const BasicBlock *FirstPred = *PI; unsigned Count = getEdgeWeight(FirstPred, BB); ++PI; if (PI == PE) return Count; // Quick exit for single predecessor blocks - BasicBlock *SecondPred = *PI; + const BasicBlock *SecondPred = *PI; if (SecondPred != FirstPred) Count += getEdgeWeight(SecondPred, BB); ++PI; if (PI == PE) return Count; // Quick exit for two predecessor blocks - BasicBlock *ThirdPred = *PI; + const BasicBlock *ThirdPred = *PI; if (ThirdPred != FirstPred && ThirdPred != SecondPred) Count += getEdgeWeight(ThirdPred, BB); ++PI; if (PI == PE) return Count; // Quick exit for three predecessor blocks - std::set<BasicBlock*> ProcessedPreds; + std::set<const BasicBlock*> ProcessedPreds; ProcessedPreds.insert(FirstPred); ProcessedPreds.insert(SecondPred); ProcessedPreds.insert(ThirdPred); @@ -75,6 +75,10 @@ unsigned ProfileInfo::getExecutionCount(BasicBlock *BB) const { return Count; } +unsigned ProfileInfo::getExecutionCount(const Function *F) const { + if (F->isDeclaration()) return -1; + return getExecutionCount(&F->getEntryBlock()); +} //===----------------------------------------------------------------------===// |