summaryrefslogtreecommitdiff
path: root/tools/llvm-prof
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-prof')
-rw-r--r--tools/llvm-prof/ProfileInfo.cpp11
-rw-r--r--tools/llvm-prof/llvm-prof.cpp2
2 files changed, 10 insertions, 3 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;
}
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp
index 083e1ce170..a459a38937 100644
--- a/tools/llvm-prof/llvm-prof.cpp
+++ b/tools/llvm-prof/llvm-prof.cpp
@@ -123,7 +123,7 @@ int main(int argc, char **argv) {
unsigned BlocksToPrint = Counts.size();
if (BlocksToPrint > 20) BlocksToPrint = 20;
for (unsigned i = 0; i != BlocksToPrint; ++i)
- printf("%3d. %5d/%d %s - %s\n", i+1, Counts[i].second, TotalExecutions,
+ printf("%3d. %5d/%d %s() - %s\n", i+1, Counts[i].second, TotalExecutions,
Counts[i].first->getParent()->getName().c_str(),
Counts[i].first->getName().c_str());