[llvm-commits] CVS: llvm/tools/llvm-prof/ProfileInfo.cpp llvm-prof.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 29 15:48:01 PST 2003


Changes in directory llvm/tools/llvm-prof:

ProfileInfo.cpp updated: 1.3 -> 1.4
llvm-prof.cpp updated: 1.7 -> 1.8

---
Log message:

Add the ability to synthesize function counts from block count information


---
Diffs of the changes:  (+10 -3)

Index: llvm/tools/llvm-prof/ProfileInfo.cpp
diff -u llvm/tools/llvm-prof/ProfileInfo.cpp:1.3 llvm/tools/llvm-prof/ProfileInfo.cpp:1.4
--- llvm/tools/llvm-prof/ProfileInfo.cpp:1.3	Tue Oct 28 15:25:23 2003
+++ llvm/tools/llvm-prof/ProfileInfo.cpp	Wed Oct 29 15:47:44 2003
@@ -141,8 +141,15 @@
 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;
   }
   


Index: llvm/tools/llvm-prof/llvm-prof.cpp
diff -u llvm/tools/llvm-prof/llvm-prof.cpp:1.7 llvm/tools/llvm-prof/llvm-prof.cpp:1.8
--- llvm/tools/llvm-prof/llvm-prof.cpp:1.7	Wed Oct 29 15:41:17 2003
+++ llvm/tools/llvm-prof/llvm-prof.cpp	Wed Oct 29 15:47:44 2003
@@ -123,7 +123,7 @@
     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());
 





More information about the llvm-commits mailing list