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
diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp
index 26328d0..1b86ec8 100644
--- a/lib/Analysis/ProfileInfo.cpp
+++ b/lib/Analysis/ProfileInfo.cpp
@@ -27,6 +27,9 @@
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 Function *F) const {
- if (F->isDeclaration()) return -1;
+ if (FunctionCounts.find(F) != FunctionCounts.end())
+ return FunctionCounts.find(F)->second;
+
return getExecutionCount(&F->getEntryBlock());
}