[profile] show more statistics

Add value profile statistics with the 'show' command.

llvm-svn: 270450
This commit is contained in:
Xinliang David Li 2016-05-23 16:36:11 +00:00
parent fd8009266f
commit 872362c457
2 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -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<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 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";