Make block and function count available via ProfileInfo.

- Part of optimal static profiling patch sequence by Andreas Neustifter.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78247 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2009-08-05 21:51:16 +00:00
parent b341577401
commit c9008c5cc7
4 changed files with 28 additions and 10 deletions

View File

@ -27,6 +27,9 @@ char ProfileInfo::ID = 0;
ProfileInfo::~ProfileInfo() {}
unsigned ProfileInfo::getExecutionCount(const BasicBlock *BB) const {
if (BlockCounts.find(BB) != BlockCounts.end())
return BlockCounts.find(BB)->second;
pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB);
// Are there zero predecessors of this block?
@ -76,7 +79,9 @@ unsigned ProfileInfo::getExecutionCount(const BasicBlock *BB) const {
}
unsigned ProfileInfo::getExecutionCount(const Function *F) const {
if (F->isDeclaration()) return -1;
if (FunctionCounts.find(F) != FunctionCounts.end())
return FunctionCounts.find(F)->second;
return getExecutionCount(&F->getEntryBlock());
}