Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm-profdata] Add block percent to detailed summary #105915

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ellishg
Copy link
Contributor

@ellishg ellishg commented Aug 24, 2024

In the detailed summary, we want to report the fraction of total blocks that account for each percentile cutoff. Also, use ProfileSummary::printSummary() in Instr profiles for consistancy.

In the detailed summary, we want to report the fraction of total blocks
that account for each percentile cutoff. Also, use
`ProfileSummary::printSummary()` in Instr profiles for consistancy.
@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations llvm:ir labels Aug 24, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 24, 2024

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-ir

Author: Ellis Hoag (ellishg)

Changes

In the detailed summary, we want to report the fraction of total blocks that account for each percentile cutoff. Also, use ProfileSummary::printSummary() in Instr profiles for consistancy.


Patch is 25.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/105915.diff

10 Files Affected:

  • (modified) compiler-rt/test/profile/Linux/Inputs/instrprof-value-merge.c (+2)
  • (modified) compiler-rt/test/profile/Linux/binary-id.c (+10)
  • (modified) compiler-rt/test/profile/Linux/profile-version.c (+4)
  • (modified) llvm/lib/IR/ProfileSummary.cpp (+6-5)
  • (modified) llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test (+34-34)
  • (modified) llvm/test/tools/llvm-profdata/general.proftext (+11-11)
  • (modified) llvm/test/tools/llvm-profdata/sample-summary.test (+17-17)
  • (modified) llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test (+16-16)
  • (modified) llvm/test/tools/llvm-profdata/vtable-value-prof.test (+8-6)
  • (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+2-7)
diff --git a/compiler-rt/test/profile/Linux/Inputs/instrprof-value-merge.c b/compiler-rt/test/profile/Linux/Inputs/instrprof-value-merge.c
index 6f5b4790cca564..3efbcf26e81ff7 100644
--- a/compiler-rt/test/profile/Linux/Inputs/instrprof-value-merge.c
+++ b/compiler-rt/test/profile/Linux/Inputs/instrprof-value-merge.c
@@ -54,6 +54,8 @@ int main(int argc, char *argv[]) {
 // CHECK-NEXT: Total functions: 3
 // CHECK-NEXT: Maximum function count: 327
 // CHECK-NEXT: Maximum internal block count: 297
+// CHECK-NEXT: Total number of blocks: 8
+// CHECK-NEXT: Total count: 805
 // CHECK-NEXT: Statistics for indirect call sites profile:
 // CHECK-NEXT:   Total number of sites: 3
 // CHECK-NEXT:   Total number of sites with values: 3
diff --git a/compiler-rt/test/profile/Linux/binary-id.c b/compiler-rt/test/profile/Linux/binary-id.c
index 9bff9004e97a7e..93a6852e626eb1 100644
--- a/compiler-rt/test/profile/Linux/binary-id.c
+++ b/compiler-rt/test/profile/Linux/binary-id.c
@@ -62,6 +62,8 @@ int main() {
 // BINARY-ID-RAW-PROF-NEXT: Total functions: 3
 // BINARY-ID-RAW-PROF-NEXT: Maximum function count: 1
 // BINARY-ID-RAW-PROF-NEXT: Maximum internal block count: 0
+// BINARY-ID-RAW-PROF-NEXT: Total number of blocks: 3
+// BINARY-ID-RAW-PROF-NEXT: Total count: 3
 // BINARY-ID-RAW-PROF-NEXT: Binary IDs:
 // BINARY-ID-RAW-PROF-NEXT: {{[0-9a-f]+}}
 
@@ -69,6 +71,8 @@ int main() {
 // BINARY-ID-MERGE-PROF-NEXT: Total functions: 3
 // BINARY-ID-MERGE-PROF-NEXT: Maximum function count: 3
 // BINARY-ID-MERGE-PROF-NEXT: Maximum internal block count: 0
+// BINARY-ID-MERGE-PROF-NEXT: Total number of blocks: 3
+// BINARY-ID-MERGE-PROF-NEXT: Total count: 9
 // BINARY-ID-MERGE-PROF-NEXT: Binary IDs:
 // BINARY-ID-MERGE-PROF-NEXT: {{[0-9a-f]+}}
 
@@ -76,6 +80,8 @@ int main() {
 // BINARY-ID-INDEXED-PROF-NEXT: Total functions: 3
 // BINARY-ID-INDEXED-PROF-NEXT: Maximum function count: 3
 // BINARY-ID-INDEXED-PROF-NEXT: Maximum internal block count: 0
+// BINARY-ID-INDEXED-PROF-NEXT: Total number of blocks: 3
+// BINARY-ID-INDEXED-PROF-NEXT: Total count: 9
 // BINARY-ID-INDEXED-PROF-NEXT: Binary IDs:
 // BINARY-ID-INDEXED-PROF-NEXT: {{[0-9a-f]+}}
 
@@ -83,6 +89,8 @@ int main() {
 // BINARY-ID-SHARE-RAW-PROF-NEXT: Total functions: 3
 // BINARY-ID-SHARE-RAW-PROF-NEXT: Maximum function count: 1
 // BINARY-ID-SHARE-RAW-PROF-NEXT: Maximum internal block count: 0
+// BINARY-ID-SHARE-RAW-PROF-NEXT: Total number of blocks: 3
+// BINARY-ID-SHARE-RAW-PROF-NEXT: Total count: 3
 // BINARY-ID-SHARE-RAW-PROF-NEXT: Binary IDs:
 // BINARY-ID-SHARE-RAW-PROF-NEXT: {{[0-9a-f]+}}
 // BINARY-ID-SHARE-RAW-PROF-NEXT: {{[0-9a-f]+}}
@@ -92,6 +100,8 @@ int main() {
 // BINARY-ID-SHARE-INDEXED-PROF-NEXT: Total functions: 3
 // BINARY-ID-SHARE-INDEXED-PROF-NEXT: Maximum function count: 1
 // BINARY-ID-SHARE-INDEXED-PROF-NEXT: Maximum internal block count: 0
+// BINARY-ID-SHARE-INDEXED-PROF-NEXT: Total number of blocks: 3
+// BINARY-ID-SHARE-INDEXED-PROF-NEXT: Total count: 3
 // BINARY-ID-SHARE-INDEXED-PROF-NEXT: Binary IDs:
 // BINARY-ID-SHARE-INDEXED-PROF-NEXT: {{[0-9a-f]+}}
 // BINARY-ID-SHARE-INDEXED-PROF-NEXT: {{[0-9a-f]+}}
diff --git a/compiler-rt/test/profile/Linux/profile-version.c b/compiler-rt/test/profile/Linux/profile-version.c
index bffc602387ad50..7e20d1bee6cc5e 100644
--- a/compiler-rt/test/profile/Linux/profile-version.c
+++ b/compiler-rt/test/profile/Linux/profile-version.c
@@ -25,10 +25,14 @@ int main() {
 // RAW-PROF-NEXT: Total functions: 3
 // RAW-PROF-NEXT: Maximum function count: 1
 // RAW-PROF-NEXT: Maximum internal block count: 0
+// RAW-PROF-NEXT: Total number of blocks: 3
+// RAW-PROF-NEXT: Total count: 3
 // RAW-PROF-NEXT: Profile version: {{[0-9]+}}
 
 // INDEXED-PROF: Instrumentation level: Front-end
 // INDEXED-PROF-NEXT: Total functions: 3
 // INDEXED-PROF-NEXT: Maximum function count: 3
 // INDEXED-PROF-NEXT: Maximum internal block count: 0
+// INDEXED-PROF-NEXT: Total number of blocks: 3
+// INDEXED-PROF-NEXT: Total count: 9
 // INDEXED-PROF-NEXT: Profile version: {{[0-9]+}}
diff --git a/llvm/lib/IR/ProfileSummary.cpp b/llvm/lib/IR/ProfileSummary.cpp
index acb4c52e8918fc..59f29e5982dfb0 100644
--- a/llvm/lib/IR/ProfileSummary.cpp
+++ b/llvm/lib/IR/ProfileSummary.cpp
@@ -251,7 +251,7 @@ ProfileSummary *ProfileSummary::getFromMD(Metadata *MD) {
 void ProfileSummary::printSummary(raw_ostream &OS) const {
   OS << "Total functions: " << NumFunctions << "\n";
   OS << "Maximum function count: " << MaxFunctionCount << "\n";
-  OS << "Maximum block count: " << MaxCount << "\n";
+  OS << "Maximum internal block count: " << MaxInternalCount << "\n";
   OS << "Total number of blocks: " << NumCounts << "\n";
   OS << "Total count: " << TotalCount << "\n";
 }
@@ -259,9 +259,10 @@ void ProfileSummary::printSummary(raw_ostream &OS) const {
 void ProfileSummary::printDetailedSummary(raw_ostream &OS) const {
   OS << "Detailed summary:\n";
   for (const auto &Entry : DetailedSummary) {
-    OS << Entry.NumCounts << " blocks with count >= " << Entry.MinCount
-       << " account for "
-       << format("%0.6g", (float)Entry.Cutoff / Scale * 100)
-       << " percentage of the total counts.\n";
+    OS << format("%lu blocks (%.2f%%) with count >= %lu account for %0.6g%% of "
+                 "the total counts.\n",
+                 Entry.NumCounts,
+                 NumCounts ? (100.f * Entry.NumCounts / NumCounts) : 0,
+                 Entry.MinCount, 100.f * Entry.Cutoff / Scale);
   }
 }
diff --git a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
index 7b01324219115c..d2b07cf05fd240 100644
--- a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
+++ b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
@@ -153,47 +153,47 @@ RUN: llvm-profdata show -sample -detailed-summary %t3.proftext | FileCheck %s -c
 
 ; SUMMARY:      Total functions: 4
 ; SUMMARY-NEXT: Maximum function count: 32
-; SUMMARY-NEXT: Maximum block count: 362830
+; SUMMARY-NEXT: Maximum internal block count: 0
 ; SUMMARY-NEXT: Total number of blocks: 16
 ; SUMMARY-NEXT: Total count: 772562
 ; SUMMARY-NEXT: Detailed summary:
-; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 1 percentage of the total counts.
-; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 10 percentage of the total counts.
-; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 20 percentage of the total counts.
-; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 30 percentage of the total counts.
-; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 40 percentage of the total counts.
-; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 50 percentage of the total counts.
-; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 60 percentage of the total counts.
-; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 70 percentage of the total counts.
-; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 80 percentage of the total counts.
-; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 90 percentage of the total counts.
-; SUMMARY-NEXT: 3 blocks with count >= 23327 account for 95 percentage of the total counts.
-; SUMMARY-NEXT: 4 blocks with count >= 23324 account for 99 percentage of the total counts.
-; SUMMARY-NEXT: 4 blocks with count >= 23324 account for 99.9 percentage of the total counts.
-; SUMMARY-NEXT: 11 blocks with count >= 24 account for 99.99 percentage of the total counts.
-; SUMMARY-NEXT: 16 blocks with count >= 10 account for 99.999 percentage of the total counts.
-; SUMMARY-NEXT: 16 blocks with count >= 10 account for 99.9999 percentage of the total counts.
+; SUMMARY-NEXT: 1 blocks (6.25%) with count >= 362830 account for 1% of the total counts.
+; SUMMARY-NEXT: 1 blocks (6.25%) with count >= 362830 account for 10% of the total counts.
+; SUMMARY-NEXT: 1 blocks (6.25%) with count >= 362830 account for 20% of the total counts.
+; SUMMARY-NEXT: 1 blocks (6.25%) with count >= 362830 account for 30% of the total counts.
+; SUMMARY-NEXT: 1 blocks (6.25%) with count >= 362830 account for 40% of the total counts.
+; SUMMARY-NEXT: 2 blocks (12.50%) with count >= 362805 account for 50% of the total counts.
+; SUMMARY-NEXT: 2 blocks (12.50%) with count >= 362805 account for 60% of the total counts.
+; SUMMARY-NEXT: 2 blocks (12.50%) with count >= 362805 account for 70% of the total counts.
+; SUMMARY-NEXT: 2 blocks (12.50%) with count >= 362805 account for 80% of the total counts.
+; SUMMARY-NEXT: 2 blocks (12.50%) with count >= 362805 account for 90% of the total counts.
+; SUMMARY-NEXT: 3 blocks (18.75%) with count >= 23327 account for 95% of the total counts.
+; SUMMARY-NEXT: 4 blocks (25.00%) with count >= 23324 account for 99% of the total counts.
+; SUMMARY-NEXT: 4 blocks (25.00%) with count >= 23324 account for 99.9% of the total counts.
+; SUMMARY-NEXT: 11 blocks (68.75%) with count >= 24 account for 99.99% of the total counts.
+; SUMMARY-NEXT: 16 blocks (100.00%) with count >= 10 account for 99.999% of the total counts.
+; SUMMARY-NEXT: 16 blocks (100.00%) with count >= 10 account for 99.9999% of the total counts.
 
 
 ; SUMMARY-NEST:      Total functions: 4
 ; SUMMARY-NEST-NEXT: Maximum function count: 32
-; SUMMARY-NEST-NEXT: Maximum block count: 362830
+; SUMMARY-NEST-NEXT: Maximum internal block count: 0
 ; SUMMARY-NEST-NEXT: Total number of blocks: 15
 ; SUMMARY-NEST-NEXT: Total count: 772504
 ; SUMMARY-NEST-NEXT: Detailed summary:
-; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 1 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 10 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 20 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 30 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 40 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 50 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 60 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 70 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 80 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 90 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 3 blocks with count >= 23327 account for 95 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 4 blocks with count >= 23324 account for 99 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 4 blocks with count >= 23324 account for 99.9 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 10 blocks with count >= 21 account for 99.99 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 15 blocks with count >= 10 account for 99.999 percentage of the total counts.
-; SUMMARY-NEST-NEXT: 15 blocks with count >= 10 account for 99.9999 percentage of the total counts.
+; SUMMARY-NEST-NEXT: 1 blocks (6.67%) with count >= 362830 account for 1% of the total counts.
+; SUMMARY-NEST-NEXT: 1 blocks (6.67%) with count >= 362830 account for 10% of the total counts.
+; SUMMARY-NEST-NEXT: 1 blocks (6.67%) with count >= 362830 account for 20% of the total counts.
+; SUMMARY-NEST-NEXT: 1 blocks (6.67%) with count >= 362830 account for 30% of the total counts.
+; SUMMARY-NEST-NEXT: 1 blocks (6.67%) with count >= 362830 account for 40% of the total counts.
+; SUMMARY-NEST-NEXT: 2 blocks (13.33%) with count >= 362805 account for 50% of the total counts.
+; SUMMARY-NEST-NEXT: 2 blocks (13.33%) with count >= 362805 account for 60% of the total counts.
+; SUMMARY-NEST-NEXT: 2 blocks (13.33%) with count >= 362805 account for 70% of the total counts.
+; SUMMARY-NEST-NEXT: 2 blocks (13.33%) with count >= 362805 account for 80% of the total counts.
+; SUMMARY-NEST-NEXT: 2 blocks (13.33%) with count >= 362805 account for 90% of the total counts.
+; SUMMARY-NEST-NEXT: 3 blocks (20.00%) with count >= 23327 account for 95% of the total counts.
+; SUMMARY-NEST-NEXT: 4 blocks (26.67%) with count >= 23324 account for 99% of the total counts.
+; SUMMARY-NEST-NEXT: 4 blocks (26.67%) with count >= 23324 account for 99.9% of the total counts.
+; SUMMARY-NEST-NEXT: 10 blocks (66.67%) with count >= 21 account for 99.99% of the total counts.
+; SUMMARY-NEST-NEXT: 15 blocks (100.00%) with count >= 10 account for 99.999% of the total counts.
+; SUMMARY-NEST-NEXT: 15 blocks (100.00%) with count >= 10 account for 99.9999% of the total counts.
diff --git a/llvm/test/tools/llvm-profdata/general.proftext b/llvm/test/tools/llvm-profdata/general.proftext
index 2dfb8e8b34d57e..89762f2540f6a6 100644
--- a/llvm/test/tools/llvm-profdata/general.proftext
+++ b/llvm/test/tools/llvm-profdata/general.proftext
@@ -71,18 +71,18 @@ hex_hash
 # DETAILED-SUMMARY: Total number of blocks: 10
 # DETAILED-SUMMARY: Total count: 4539628424389557499
 # DETAILED-SUMMARY: Detailed summary:
-# DETAILED-SUMMARY: 3 blocks with count >= 576460752303423488 account for 80 percentage of the total counts.
-# DETAILED-SUMMARY: 4 blocks with count >= 288230376151711744 account for 90 percentage of the total counts.
-# DETAILED-SUMMARY: 4 blocks with count >= 288230376151711744 account for 95 percentage of the total counts.
-# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99 percentage of the total counts.
-# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99.9 percentage of the total counts.
-# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99.99 percentage of the total counts.
-# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99.999 percentage of the total counts.
+# DETAILED-SUMMARY: 3 blocks (30.00%) with count >= 576460752303423488 account for 80% of the total counts.
+# DETAILED-SUMMARY: 4 blocks (40.00%) with count >= 288230376151711744 account for 90% of the total counts.
+# DETAILED-SUMMARY: 4 blocks (40.00%) with count >= 288230376151711744 account for 95% of the total counts.
+# DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99% of the total counts.
+# DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.9% of the total counts.
+# DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.99% of the total counts.
+# DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.999% of the total counts.
 
 # RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-2
-# DETAILED-SUMMARY-2: 2 blocks with count >= 1152921504606846976 account for 60 percentage of the total counts.
+# DETAILED-SUMMARY-2: 2 blocks (28.57%) with count >= 1152921504606846976 account for 60% of the total counts.
 #
 # RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000,900000,999999 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-3
-# DETAILED-SUMMARY-3: 2 blocks with count >= 1152921504606846976 account for 60 percentage of the total counts.
-# DETAILED-SUMMARY-3: 4 blocks with count >= 288230376151711744 account for 90 percentage of the total counts.
-# DETAILED-SUMMARY-3: 6 blocks with count >= 72057594037927936 account for 99.9999 percentage of the total counts.
+# DETAILED-SUMMARY-3: 2 blocks (28.57%) with count >= 1152921504606846976 account for 60% of the total counts.
+# DETAILED-SUMMARY-3: 4 blocks (57.14%) with count >= 288230376151711744 account for 90% of the total counts.
+# DETAILED-SUMMARY-3: 6 blocks (85.71%) with count >= 72057594037927936 account for 99.9999% of the total counts.
diff --git a/llvm/test/tools/llvm-profdata/sample-summary.test b/llvm/test/tools/llvm-profdata/sample-summary.test
index 3326c9bb29806b..310cc8bfb721cd 100644
--- a/llvm/test/tools/llvm-profdata/sample-summary.test
+++ b/llvm/test/tools/llvm-profdata/sample-summary.test
@@ -2,23 +2,23 @@
 
 ; CHECK: Total functions: 3
 ; CHECK-NEXT: Maximum function count: 1437
-; CHECK-NEXT: Maximum block count: 2080
+; CHECK-NEXT: Maximum internal block count: 0
 ; CHECK-NEXT: Total number of blocks: 11
 ; CHECK-NEXT: Total count: 12943
 ; CHECK-NEXT: Detailed summary:
-; CHECK-NEXT: 1 blocks with count >= 2080 account for 1 percentage of the total counts.
-; CHECK-NEXT: 1 blocks with count >= 2080 account for 10 percentage of the total counts.
-; CHECK-NEXT: 2 blocks with count >= 2064 account for 20 percentage of the total counts.
-; CHECK-NEXT: 2 blocks with count >= 2064 account for 30 percentage of the total counts.
-; CHECK-NEXT: 3 blocks with count >= 2000 account for 40 percentage of the total counts.
-; CHECK-NEXT: 4 blocks with count >= 1437 account for 50 percentage of the total counts.
-; CHECK-NEXT: 6 blocks with count >= 1075 account for 60 percentage of the total counts.
-; CHECK-NEXT: 6 blocks with count >= 1075 account for 70 percentage of the total counts.
-; CHECK-NEXT: 7 blocks with count >= 1000 account for 80 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 90 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 95 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 99 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 99.9 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 99.99 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 99.999 percentage of the total counts.
-; CHECK-NEXT: 11 blocks with count >= 534 account for 99.9999 percentage of the total counts.
+; CHECK-NEXT: 1 blocks (9.09%) with count >= 2080 account for 1% of the total counts.
+; CHECK-NEXT: 1 blocks (9.09%) with count >= 2080 account for 10% of the total counts.
+; CHECK-NEXT: 2 blocks (18.18%) with count >= 2064 account for 20% of the total counts.
+; CHECK-NEXT: 2 blocks (18.18%) with count >= 2064 account for 30% of the total counts.
+; CHECK-NEXT: 3 blocks (27.27%) with count >= 2000 account for 40% of the total counts.
+; CHECK-NEXT: 4 blocks (36.36%) with count >= 1437 account for 50% of the total counts.
+; CHECK-NEXT: 6 blocks (54.55%) with count >= 1075 account for 60% of the total counts.
+; CHECK-NEXT: 6 blocks (54.55%) with count >= 1075 account for 70% of the total counts.
+; CHECK-NEXT: 7 blocks (63.64%) with count >= 1000 account for 80% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 90% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 95% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 99% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 99.9% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 99.99% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 99.999% of the total counts.
+; CHECK-NEXT: 11 blocks (100.00%) with count >= 534 account for 99.9999% of the total counts.
diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
index 20d4d2198ff449..c22646e45849ea 100644
--- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
+++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
@@ -98,19 +98,19 @@ MIX5-NEXT: Maximum internal block count: 2000
 MIX5-NEXT: Total number of blocks: 9
 MIX5-NEXT: Total count: 6525
 MIX5-NEXT: Detailed summary:
-MIX5-NEXT: 1 blocks with count >= 3000 account for 1 percentage of the total counts.
-MIX5-NEXT: 1 blocks with count >= 3000 account for 10 percentage of the total counts.
-MIX5-NEXT: 1 blocks with count >= 3000 account for 20 percentage of the total counts.
-MIX5-NEXT: 1 blocks with count >= 3000 account for 30 percentage of the total counts.
-MIX5-NEXT: 1 blocks with count >= 3000 account for 40 percentage of the total counts.
-MIX5-NEXT: 2 blocks with count >= 2000 account for 50 percentage of the total counts.
-MIX5-NEXT: 2 blocks with count >= 2000 account for 60 percentage of the total counts.
-MIX5-NEXT: 2 blocks with count >= 2000 account for 70 percentage of the total counts.
-MIX5-NEXT: 3 blocks with count >= 1000 account for...
[truncated]

@@ -251,17 +251,18 @@ ProfileSummary *ProfileSummary::getFromMD(Metadata *MD) {
void ProfileSummary::printSummary(raw_ostream &OS) const {
OS << "Total functions: " << NumFunctions << "\n";
OS << "Maximum function count: " << MaxFunctionCount << "\n";
OS << "Maximum block count: " << MaxCount << "\n";
OS << "Maximum internal block count: " << MaxInternalCount << "\n";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed the behavior here to dump MaxInternalCount instead of MaxCount because I think it requires fewer test changes. But I'm also open to changing this or including both logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "internal block" and what differentiate it from just "block"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe an "internal block" is a non-entry blocks while "block" includes the entry block, which is is reported in "function count".

@ellishg
Copy link
Contributor Author

ellishg commented Oct 2, 2024

Friendly ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt llvm:ir PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants