llvm.org GIT mirror llvm / 5f281ed
[PGO] Revert r350579 to fix commit message. Will re-commit it using the correct commit message. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350670 91177308-0d34-0410-b5e6-96231b3b80d8 Rong Xu 8 months ago
5 changed file(s) with 17 addition(s) and 111 deletion(s). Raw diff Collapse all Expand all
202202 annotations.
203203
204204 .. option:: -topn=n
205
205
206206 Instruct the profile dumper to show the top ``n`` functions with the
207207 hottest basic blocks in the summary section. By default, the topn functions
208208 are not dumped.
215215
216216 Show the profiled sizes of the memory intrinsic calls for shown functions.
217217
218 .. option:: -value-cutoff=n
219
220 Show only those functions whose max count values are greater or equal to ``n``.
221 By default, the value-cutoff is set to 0.
222
223 .. option:: -list-below-cutoff
224
225 Only output names of functions whose max count value are below the cutoff
226 value.
227
228218 EXIT STATUS
229219 -----------
230220
+0
-21
test/tools/llvm-profdata/Inputs/cutoff.proftext less more
None # IR level Instrumentation Flag
1 :ir
2 bar
3 10
4 2
5 0
6 0
7
8 main
9 16650
10 4
11 1
12 1000
13 1000000
14 499500
15
16 foo
17 10
18 2
19 999
20 1
+0
-23
test/tools/llvm-profdata/cutoff.test less more
None Basic tests for cutoff options in show command.
1
2 RUN: llvm-profdata show -value-cutoff=1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefix=CUTOFF1 -check-prefix=CHECK
3 RUN: llvm-profdata show -value-cutoff=1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefix=CUTOFF1000 -check-prefix=CHECK
4 RUN: llvm-profdata show -all-functions -value-cutoff=1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefix=CUTOFF1FUNC -check-prefix=CUTOFF1 -check-prefix=CHECK
5 RUN: llvm-profdata show -all-functions -value-cutoff=1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefix=CUTOFF1000FUNC -check-prefix=CUTOFF1000 -check-prefix=CHECK
6 RUN: llvm-profdata show -value-cutoff=1 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefix=BELOW1 -check-prefix=CUTOFF1 -check-prefix=CHECK
7 RUN: llvm-profdata show -value-cutoff=1000 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefix=BELOW1000 -check-prefix=CUTOFF1000 -check-prefix=CHECK
8 CUTOFF1FUNC-NOT: bar
9 CUTOFF1FUNC: Functions shown: 2
10 CUTOFF1000FUNC-NOT: bar
11 CUTOFF1000FUNC-NOT: foo
12 CUTOFF1000FUNC: Functions shown: 1
13 BELOW1: The list of functions with the maximum counter less than 1:
14 BELOW1: bar: (Max = 0 Sum = 0)
15 BELOW1000:The list of functions with the maximum counter less than 1000:
16 BELOW1000: bar: (Max = 0 Sum = 0)
17 BELOW1000: foo: (Max = 999 Sum = 1000)
18 CHECK: Total functions: 3
19 CUTOFF1: Number of functions with maximum count (< 1): 1
20 CUTOFF1: Number of functions with maximum count (>= 1): 2
21 CUTOFF1000: Number of functions with maximum count (< 1000): 2
22 CUTOFF1000: Number of functions with maximum count (>= 1000): 1
4646
4747 #ICTXT: Indirect Call Site Count: 3
4848 #ICTXT-NEXT: Indirect Target Results:
49 #ICTXT-NEXT: [ 1, foo, 100 ] (9.09%)
50 #ICTXT-NEXT: [ 1, foo2, 1000 ] (90.91%)
51 #ICTXT-NEXT: [ 2, foo2, 20000 ] (100.00%)
49 #ICTXT-NEXT: [ 1, foo, 100 ]
50 #ICTXT-NEXT: [ 1, foo2, 1000 ]
51 #ICTXT-NEXT: [ 2, foo2, 20000 ]
5252
5353 #IC: Indirect Call Site Count: 3
5454 #IC-NEXT: Indirect Target Results:
632632 Stats.ValueSitesHistogram.resize(NV, 0);
633633 Stats.ValueSitesHistogram[NV - 1]++;
634634 }
635
636 uint64_t SiteSum = 0;
637 for (uint32_t V = 0; V < NV; V++)
638 SiteSum += VD[V].Count;
639 if (SiteSum == 0)
640 SiteSum = 1;
641
642635 for (uint32_t V = 0; V < NV; V++) {
643 OS << "\t[ " << format("%2u", I) << ", ";
636 OS << "\t[ " << I << ", ";
644637 if (Symtab == nullptr)
645 OS << format("%4u", VD[V].Value);
638 OS << VD[V].Value;
646639 else
647640 OS << Symtab->getFuncName(VD[V].Value);
648 OS << ", " << format("%10" PRId64, VD[V].Count) << " ] ("
649 << format("%.2f%%", (VD[V].Count * 100.0 / SiteSum)) << ")\n";
641 OS << ", " << VD[V].Count << " ]\n";
650642 }
651643 }
652644 }
669661 uint32_t TopN, bool ShowIndirectCallTargets,
670662 bool ShowMemOPSizes, bool ShowDetailedSummary,
671663 std::vector DetailedSummaryCutoffs,
672 bool ShowAllFunctions, uint64_t ValueCutoff,
673 bool OnlyListBelow, const std::string &ShowFunction,
674 bool TextFormat, raw_fd_ostream &OS) {
664 bool ShowAllFunctions,
665 const std::string &ShowFunction, bool TextFormat,
666 raw_fd_ostream &OS) {
675667 auto ReaderOrErr = InstrProfReader::create(Filename);
676668 std::vector Cutoffs = std::move(DetailedSummaryCutoffs);
677669 if (ShowDetailedSummary && Cutoffs.empty()) {
684676 auto Reader = std::move(ReaderOrErr.get());
685677 bool IsIRInstr = Reader->isIRLevelProfile();
686678 size_t ShownFunctions = 0;
687 size_t BelowCutoffFunctions = 0;
688679 int NumVPKind = IPVK_Last - IPVK_First + 1;
689680 std::vector VPStats(NumVPKind);
690681
697688 std::vector>,
698689 decltype(MinCmp)>
699690 HottestFuncs(MinCmp);
700
701 if (!TextFormat && OnlyListBelow) {
702 OS << "The list of functions with the maximum counter less than "
703 << ValueCutoff << ":\n";
704 }
705691
706692 // Add marker so that IR-level instrumentation round-trips properly.
707693 if (TextFormat && IsIRInstr)
724710 assert(Func.Counts.size() > 0 && "function missing entry counter");
725711 Builder.addRecord(Func);
726712
727 uint64_t FuncMax = 0;
728 uint64_t FuncSum = 0;
729 for (size_t I = 0, E = Func.Counts.size(); I < E; ++I) {
730 FuncMax = std::max(FuncMax, Func.Counts[I]);
731 FuncSum += Func.Counts[I];
732 }
733
734 if (FuncMax < ValueCutoff) {
735 ++BelowCutoffFunctions;
736 if (OnlyListBelow) {
737 OS << " " << Func.Name << ": (Max = " << FuncMax
738 << " Sum = " << FuncSum << ")\n";
739 }
740 continue;
741 } else if (OnlyListBelow)
742 continue;
743
744713 if (TopN) {
714 uint64_t FuncMax = 0;
715 for (size_t I = 0, E = Func.Counts.size(); I < E; ++I)
716 FuncMax = std::max(FuncMax, Func.Counts[I]);
717
745718 if (HottestFuncs.size() == TopN) {
746719 if (HottestFuncs.top().second < FuncMax) {
747720 HottestFuncs.pop();
752725 }
753726
754727 if (Show) {
728
755729 if (!ShownFunctions)
756730 OS << "Counters:\n";
757731
806780 if (ShowAllFunctions || !ShowFunction.empty())
807781 OS << "Functions shown: " << ShownFunctions << "\n";
808782 OS << "Total functions: " << PS->getNumFunctions() << "\n";
809 if (ValueCutoff > 0) {
810 OS << "Number of functions with maximum count (< " << ValueCutoff
811 << "): " << BelowCutoffFunctions << "\n";
812 OS << "Number of functions with maximum count (>= " << ValueCutoff
813 << "): " << PS->getNumFunctions() - BelowCutoffFunctions << "\n";
814 }
815783 OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n";
816784 OS << "Maximum internal block count: " << PS->getMaxInternalCount() << "\n";
817785
913881 cl::opt TopNFunctions(
914882 "topn", cl::init(0),
915883 cl::desc("Show the list of functions with the largest internal counts"));
916 cl::opt ValueCutoff(
917 "value-cutoff", cl::init(0),
918 cl::desc("Set the count value cutoff. Functions with the maximum count "
919 "less than this value will not be printed out. (Default is 0)"));
920 cl::opt OnlyListBelow(
921 "list-below-cutoff", cl::init(false),
922 cl::desc("Only output names of functions whose max count values are "
923 "below the cutoff value"));
884
924885 cl::ParseCommandLineOptions(argc, argv, "LLVM profile data summary\n");
925886
926887 if (OutputFilename.empty())
940901 return showInstrProfile(Filename, ShowCounts, TopNFunctions,
941902 ShowIndirectCallTargets, ShowMemOPSizes,
942903 ShowDetailedSummary, DetailedSummaryCutoffs,
943 ShowAllFunctions, ValueCutoff, OnlyListBelow,
944 ShowFunction, TextFormat, OS);
904 ShowAllFunctions, ShowFunction, TextFormat, OS);
945905 else
946906 return showSampleProfile(Filename, ShowCounts, ShowAllFunctions,
947907 ShowFunction, OS);