summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-prof/ProfileInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-prof/ProfileInfo.cpp')
-rw-r--r--llvm/tools/llvm-prof/ProfileInfo.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/llvm/tools/llvm-prof/ProfileInfo.cpp b/llvm/tools/llvm-prof/ProfileInfo.cpp
index 2341db0bb9f..4c31138aa34 100644
--- a/llvm/tools/llvm-prof/ProfileInfo.cpp
+++ b/llvm/tools/llvm-prof/ProfileInfo.cpp
@@ -148,7 +148,28 @@ void ProfileInfo::getFunctionCounts(std::vector<std::pair<Function*,
unsigned Counter = 0;
for (Module::iterator I = M.begin(), E = M.end();
- I != E && Counter != FunctionCounts.size(); ++I, ++Counter)
+ I != E && Counter != FunctionCounts.size(); ++I)
if (!I->isExternal())
- Counts.push_back(std::make_pair(I, FunctionCounts[Counter]));
+ Counts.push_back(std::make_pair(I, FunctionCounts[Counter++]));
+}
+
+// getBlockCounts - This method is used by consumers of block counting
+// information. If we do not directly have block count information, we
+// compute it from other, more refined, types of profile information.
+//
+void ProfileInfo::getBlockCounts(std::vector<std::pair<BasicBlock*,
+ unsigned> > &Counts) {
+ if (BlockCounts.empty()) {
+ std::cerr << "Block counts not available, and no synthesis "
+ << "is implemented yet!\n";
+ return;
+ }
+
+ unsigned Counter = 0;
+ for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
+ for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
+ Counts.push_back(std::make_pair(BB, BlockCounts[Counter++]));
+ if (Counter == BlockCounts.size())
+ return;
+ }
}
OpenPOWER on IntegriCloud