[llvm] r270450 - [profile] show more statistics

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 09:36:12 PDT 2016


Author: davidxl
Date: Mon May 23 11:36:11 2016
New Revision: 270450

URL: http://llvm.org/viewvc/llvm-project?rev=270450&view=rev
Log:
[profile] show more statistics

Add value profile statistics with the 'show' command.




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

Modified: llvm/trunk/test/tools/llvm-profdata/value-prof.proftext
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/value-prof.proftext?rev=270450&r1=270449&r2=270450&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/value-prof.proftext (original)
+++ llvm/trunk/test/tools/llvm-profdata/value-prof.proftext Mon May 23 11:36:11 2016
@@ -1,7 +1,7 @@
-# RUN: llvm-profdata show -ic-targets  -all-functions %s | FileCheck %s --check-prefix=ICTXT
+# RUN: llvm-profdata show -ic-targets  -all-functions %s | FileCheck %s --check-prefix=ICTXT --check-prefix=ICSUM
 # RUN: llvm-profdata show -ic-targets -counts -text -all-functions %s | FileCheck %s --check-prefix=ICTEXT
 # RUN: llvm-profdata merge -o %t.profdata  %s
-# RUN: llvm-profdata show -ic-targets  -all-functions %t.profdata | FileCheck %s --check-prefix=IC
+# RUN: llvm-profdata show -ic-targets  -all-functions %t.profdata | FileCheck %s --check-prefix=IC --check-prefix=ICSUM
 
 foo
 # Func Hash:
@@ -61,3 +61,9 @@ foo2:20000
 #ICTEXT-NEXT: foo2:1000
 #ICTEXT-NEXT: 1
 #ICTEXT-NEXT: foo2:20000
+#
+
+#ICSUM: Total Number of Indirect Call Sites : 3
+#ICSUM: Total Number of Sites With Values : 2
+#ICSUM: Total Number of Profiled Values : 3
+

Modified: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=270450&r1=270449&r2=270450&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp (original)
+++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp Mon May 23 11:36:11 2016
@@ -288,6 +288,9 @@ static int showInstrProfile(std::string
   auto Reader = std::move(ReaderOrErr.get());
   bool IsIRInstr = Reader->isIRLevelProfile();
   size_t ShownFunctions = 0;
+  uint64_t TotalNumValueSites = 0;
+  uint64_t TotalNumValueSitesWithValueProfile = 0;
+  uint64_t TotalNumValues = 0;
   for (const auto &Func : *Reader) {
     bool Show =
         ShowAllFunctions || (!ShowFunction.empty() &&
@@ -334,10 +337,14 @@ static int showInstrProfile(std::string
         InstrProfSymtab &Symtab = Reader->getSymtab();
         uint32_t NS = Func.getNumValueSites(IPVK_IndirectCallTarget);
         OS << "    Indirect Target Results: \n";
+        TotalNumValueSites += NS;
         for (size_t I = 0; I < NS; ++I) {
           uint32_t NV = Func.getNumValueDataForSite(IPVK_IndirectCallTarget, I);
           std::unique_ptr<InstrProfValueData[]> VD =
               Func.getValueForSite(IPVK_IndirectCallTarget, I);
+          TotalNumValues += NV;
+          if (NV)
+            TotalNumValueSitesWithValueProfile++;
           for (uint32_t V = 0; V < NV; V++) {
             OS << "\t[ " << I << ", ";
             OS << Symtab.getFuncName(VD[V].Value) << ", " << VD[V].Count
@@ -347,7 +354,6 @@ static int showInstrProfile(std::string
       }
     }
   }
-
   if (Reader->hasError())
     exitWithError(Reader->getError(), Filename);
 
@@ -359,6 +365,13 @@ static int showInstrProfile(std::string
   OS << "Total functions: " << PS->getNumFunctions() << "\n";
   OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n";
   OS << "Maximum internal block count: " << PS->getMaxInternalCount() << "\n";
+  if (ShownFunctions && ShowIndirectCallTargets) {
+    OS << "Total Number of Indirect Call Sites : " << TotalNumValueSites
+       << "\n";
+    OS << "Total Number of Sites With Values : "
+       << TotalNumValueSitesWithValueProfile << "\n";
+    OS << "Total Number of Profiled Values : " << TotalNumValues << "\n";
+  }
 
   if (ShowDetailedSummary) {
     OS << "Detailed summary:\n";




More information about the llvm-commits mailing list