diff --git a/test/tools/llvm-profdata/value-prof.proftext b/test/tools/llvm-profdata/value-prof.proftext index a8f6e8641c6..75a74566449 100644 --- a/test/tools/llvm-profdata/value-prof.proftext +++ b/test/tools/llvm-profdata/value-prof.proftext @@ -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 + diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp index b2e60aa43bc..546029aef9f 100644 --- a/tools/llvm-profdata/llvm-profdata.cpp +++ b/tools/llvm-profdata/llvm-profdata.cpp @@ -288,6 +288,9 @@ static int showInstrProfile(std::string Filename, bool ShowCounts, 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 Filename, bool ShowCounts, 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 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 Filename, bool ShowCounts, } } } - if (Reader->hasError()) exitWithError(Reader->getError(), Filename); @@ -359,6 +365,13 @@ static int showInstrProfile(std::string Filename, bool ShowCounts, 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";