[PATCH] D24783: [Profile] show distribution/histogram of indirect call profiles

David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 13:48:14 PDT 2016


davidxl created this revision.
davidxl added a reviewer: vsk.
davidxl added a subscriber: llvm-commits.

With collected value profile data, it is useful to see statistics such as how many value sites have <N> target values. This simple patch adds that support and dumps it as part of profile summary.

https://reviews.llvm.org/D24783

Files:
  test/tools/llvm-profdata/value-prof.proftext
  tools/llvm-profdata/llvm-profdata.cpp

Index: test/tools/llvm-profdata/value-prof.proftext
===================================================================
--- test/tools/llvm-profdata/value-prof.proftext
+++ test/tools/llvm-profdata/value-prof.proftext
@@ -66,4 +66,7 @@
 #ICSUM: Total Number of Indirect Call Sites : 3
 #ICSUM: Total Number of Sites With Values : 2
 #ICSUM: Total Number of Profiled Values : 3
+#ICSUM:	NumTargets, SiteCount
+#ICSUM	1, 1
+#ICSUM	2, 1
 
Index: tools/llvm-profdata/llvm-profdata.cpp
===================================================================
--- tools/llvm-profdata/llvm-profdata.cpp
+++ tools/llvm-profdata/llvm-profdata.cpp
@@ -463,6 +463,7 @@
   uint64_t TotalNumValueSites = 0;
   uint64_t TotalNumValueSitesWithValueProfile = 0;
   uint64_t TotalNumValues = 0;
+  std::vector<unsigned> ICHistogram;
   for (const auto &Func : *Reader) {
     bool Show =
         ShowAllFunctions || (!ShowFunction.empty() &&
@@ -515,8 +516,12 @@
           std::unique_ptr<InstrProfValueData[]> VD =
               Func.getValueForSite(IPVK_IndirectCallTarget, I);
           TotalNumValues += NV;
-          if (NV)
+          if (NV) {
             TotalNumValueSitesWithValueProfile++;
+            if (NV > ICHistogram.size())
+              ICHistogram.resize(NV, 0);
+            ICHistogram[NV - 1]++;
+          }
           for (uint32_t V = 0; V < NV; V++) {
             OS << "\t[ " << I << ", ";
             OS << Symtab.getFuncName(VD[V].Value) << ", " << VD[V].Count
@@ -543,6 +548,11 @@
     OS << "Total Number of Sites With Values : "
        << TotalNumValueSitesWithValueProfile << "\n";
     OS << "Total Number of Profiled Values : " << TotalNumValues << "\n";
+
+    OS << "IC Value histogram : \n\tNumTargets, SiteCount\n";
+    for (unsigned I = 0; I < ICHistogram.size(); I++) {
+      OS << "\t" << I + 1 << ", " << ICHistogram[I] << "\n";
+    }
   }
 
   if (ShowDetailedSummary) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24783.71980.patch
Type: text/x-patch
Size: 1908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160920/6858fcb7/attachment.bin>


More information about the llvm-commits mailing list