Skip to content

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

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

Merged
merged 1 commit into from
Jan 23, 2025

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.

@ellishg ellishg requested review from ZequanWu, htyu and WenleiHe August 24, 2024 02:03
@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations llvm:ir labels Aug 24, 2024
@llvmbot
Copy link
Member

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

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.
@ellishg
Copy link
Contributor Author

ellishg commented Jan 23, 2025

I've just rebased to main. Does anyone think this patch will cause any issues? I believe it will mostly impact reporting via -detailed-summary.

Copy link
Contributor

@wlei-llvm wlei-llvm left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement, LGTM.

@ellishg ellishg merged commit a245309 into llvm:main Jan 23, 2025
6 of 8 checks passed
@ellishg ellishg deleted the profdata-show branch January 23, 2025 17:30
ellishg added a commit that referenced this pull request Jan 23, 2025
XFAIL `llvm/test/tools/llvm-profdata/general.proftext` after it was
accidentally broken by
#105915. I will follow up to
get this fixed.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 23, 2025
XFAIL `llvm/test/tools/llvm-profdata/general.proftext` after it was
accidentally broken by
llvm/llvm-project#105915. I will follow up to
get this fixed.
@vitalybuka
Copy link
Collaborator

Looks like from this patch https://lab.llvm.org/buildbot/#/builders/107/builds/7329

CC @thurstond

@ellishg
Copy link
Contributor Author

ellishg commented Jan 23, 2025

Looks like from this patch https://lab.llvm.org/buildbot/#/builders/107/builds/7329

CC @thurstond

Yeah, sorry about that. I XFAILed the test in #124165 and properly fixed in #124169.

@vitalybuka
Copy link
Collaborator

Looks like from this patch https://lab.llvm.org/buildbot/#/builders/107/builds/7329
CC @thurstond

Yeah, sorry about that. I XFAILed the test in #124165 and properly fixed in #124169.

Please revert the original patch if fix needs more reviews.

ellishg added a commit that referenced this pull request Jan 23, 2025
The detailed summary format was changed in
#105915 which broke
`llvm/test/tools/llvm-profdata/general.proftext` (XFAILed in
#124165). Apparently the
behavior of `%lu` is different between Linux and Windows, so I reverted
back to using `<<` style formats.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 23, 2025
…24169)

The detailed summary format was changed in
llvm/llvm-project#105915 which broke
`llvm/test/tools/llvm-profdata/general.proftext` (XFAILed in
llvm/llvm-project#124165). Apparently the
behavior of `%lu` is different between Linux and Windows, so I reverted
back to using `<<` style formats.
@vitalybuka
Copy link
Collaborator

@antmox
Copy link
Contributor

antmox commented Jan 24, 2025

Also broke clang-arm64-windows-msvc : https://lab.llvm.org/buildbot/#/builders/161/builds/4261

@ellishg
Copy link
Contributor Author

ellishg commented Jan 24, 2025

Thanks @vitalybuka and @antmox. Should be fixed by #124318.

ellishg added a commit that referenced this pull request Jan 24, 2025
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 24, 2025
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.

6 participants