llvm.org GIT mirror llvm / 1386ead
[profile] show more statistics Add value profile statistics with the 'show' command. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270450 91177308-0d34-0410-b5e6-96231b3b80d8 Xinliang David Li 3 years ago
2 changed file(s) with 22 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
None # RUN: llvm-profdata show -ic-targets -all-functions %s | FileCheck %s --check-prefix=ICTXT
0 # RUN: llvm-profdata show -ic-targets -all-functions %s | FileCheck %s --check-prefix=ICTXT --check-prefix=ICSUM
11 # RUN: llvm-profdata show -ic-targets -counts -text -all-functions %s | FileCheck %s --check-prefix=ICTEXT
22 # RUN: llvm-profdata merge -o %t.profdata %s
3 # RUN: llvm-profdata show -ic-targets -all-functions %t.profdata | FileCheck %s --check-prefix=IC
3 # RUN: llvm-profdata show -ic-targets -all-functions %t.profdata | FileCheck %s --check-prefix=IC --check-prefix=ICSUM
44
55 foo
66 # Func Hash:
6060 #ICTEXT-NEXT: foo2:1000
6161 #ICTEXT-NEXT: 1
6262 #ICTEXT-NEXT: foo2:20000
63 #
64
65 #ICSUM: Total Number of Indirect Call Sites : 3
66 #ICSUM: Total Number of Sites With Values : 2
67 #ICSUM: Total Number of Profiled Values : 3
68
287287 auto Reader = std::move(ReaderOrErr.get());
288288 bool IsIRInstr = Reader->isIRLevelProfile();
289289 size_t ShownFunctions = 0;
290 uint64_t TotalNumValueSites = 0;
291 uint64_t TotalNumValueSitesWithValueProfile = 0;
292 uint64_t TotalNumValues = 0;
290293 for (const auto &Func : *Reader) {
291294 bool Show =
292295 ShowAllFunctions || (!ShowFunction.empty() &&
333336 InstrProfSymtab &Symtab = Reader->getSymtab();
334337 uint32_t NS = Func.getNumValueSites(IPVK_IndirectCallTarget);
335338 OS << " Indirect Target Results: \n";
339 TotalNumValueSites += NS;
336340 for (size_t I = 0; I < NS; ++I) {
337341 uint32_t NV = Func.getNumValueDataForSite(IPVK_IndirectCallTarget, I);
338342 std::unique_ptr VD =
339343 Func.getValueForSite(IPVK_IndirectCallTarget, I);
344 TotalNumValues += NV;
345 if (NV)
346 TotalNumValueSitesWithValueProfile++;
340347 for (uint32_t V = 0; V < NV; V++) {
341348 OS << "\t[ " << I << ", ";
342349 OS << Symtab.getFuncName(VD[V].Value) << ", " << VD[V].Count
346353 }
347354 }
348355 }
349
350356 if (Reader->hasError())
351357 exitWithError(Reader->getError(), Filename);
352358
358364 OS << "Total functions: " << PS->getNumFunctions() << "\n";
359365 OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n";
360366 OS << "Maximum internal block count: " << PS->getMaxInternalCount() << "\n";
367 if (ShownFunctions && ShowIndirectCallTargets) {
368 OS << "Total Number of Indirect Call Sites : " << TotalNumValueSites
369 << "\n";
370 OS << "Total Number of Sites With Values : "
371 << TotalNumValueSitesWithValueProfile << "\n";
372 OS << "Total Number of Profiled Values : " << TotalNumValues << "\n";
373 }
361374
362375 if (ShowDetailedSummary) {
363376 OS << "Detailed summary:\n";