diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-29 21:47:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-29 21:47:44 +0000 |
commit | 750ba3d6eb1144caa3ba2bec1de3a1a4c9b970eb (patch) | |
tree | 9beefa1bd9e64bcda23dc9d99e7ff1c12430f554 /tools/llvm-prof/ProfileInfo.cpp | |
parent | 18884a86ae337b6ce9636738c069a87004d43017 (diff) |
Add the ability to synthesize function counts from block count information
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9595 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-prof/ProfileInfo.cpp')
-rw-r--r-- | tools/llvm-prof/ProfileInfo.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/llvm-prof/ProfileInfo.cpp b/tools/llvm-prof/ProfileInfo.cpp index 4c31138aa3..78de9c16c7 100644 --- a/tools/llvm-prof/ProfileInfo.cpp +++ b/tools/llvm-prof/ProfileInfo.cpp @@ -141,8 +141,15 @@ ProfileInfo::ProfileInfo(const char *ToolName, const std::string &Filename, void ProfileInfo::getFunctionCounts(std::vector<std::pair<Function*, unsigned> > &Counts) { if (FunctionCounts.empty()) { - std::cerr << "Function counts not available, and no synthesis " - << "is implemented yet!\n"; + // Synthesize function frequency information from the number of times their + // entry blocks were executed. + std::vector<std::pair<BasicBlock*, unsigned> > BlockCounts; + getBlockCounts(BlockCounts); + + for (unsigned i = 0, e = BlockCounts.size(); i != e; ++i) + if (&BlockCounts[i].first->getParent()->front() == BlockCounts[i].first) + Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(), + BlockCounts[i].second)); return; } |