From c3f694fad7247c03c18aaa9d121ce5f4bd85d1a7 Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Tue, 19 Sep 2023 13:38:50 -0700 Subject: [PATCH 1/2] [AsmPrint] Dump raw frequencies in `-mbb-profile-dump` We were losing the function entry count, which is useful to check profile quality. For the original cases where we want entrypoint-relative MBB frequencies, the user would just need to divide these values by the entrypoint (first MBB, with ID=0) value. --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 2ce08a2ff4395..0c4ea1b3d9f04 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1940,7 +1940,7 @@ void AsmPrinter::emitFunctionBody() { for (const auto &MBB : *MF) { *MBBProfileDumpFileOutput.get() << MF->getName() << "," << MBB.getBBID() << "," - << MBFI.getBlockFreqRelativeToEntryBlock(&MBB) << "\n"; + << MBFI.getBlockFreq(&MBB).getFrequency() << "\n"; } } } diff --git a/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll b/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll index e0ac148456cac..60a1fafc3c92c 100644 --- a/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll +++ b/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll @@ -22,10 +22,10 @@ ifNotEqual: ret i64 %sum } -; CHECK: f2,0,1.000000e+00 -; CHECK-NEXT: f1,0,1.000000e+00 -; CHECK-NEXT: f1,1,5.000000e-01 -; CHECK-NEXT: f1,2,1.000000e+00 +; CHECK: f2,0,8 +; CHECK-NEXT: f1,0,16 +; CHECK-NEXT: f1,1,8 +; CHECK-NEXT: f1,2,16 ; Check that if we pass -mbb-profile-dump but don't set -basic-block-sections, ; we get an appropriate error message From 86cec34b27518380dae9f5ca5300719d6f593b84 Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Tue, 19 Sep 2023 14:32:12 -0700 Subject: [PATCH 2/2] address Snehasish's feedback --- llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll b/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll index 60a1fafc3c92c..934c281219d4a 100644 --- a/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll +++ b/llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll @@ -12,6 +12,8 @@ define i64 @f2(i64 %a, i64 %b) { ret i64 %sum } +; CHECK: f2,0,8 + define i64 @f1() { %sum = call i64 @f2(i64 2, i64 2) %isEqual = icmp eq i64 %sum, 4 @@ -22,7 +24,6 @@ ifNotEqual: ret i64 %sum } -; CHECK: f2,0,8 ; CHECK-NEXT: f1,0,16 ; CHECK-NEXT: f1,1,8 ; CHECK-NEXT: f1,2,16