[llvm] [AsmPrint] Dump raw frequencies in `-mbb-profile-dump` (PR #66818)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 13:50:07 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlgo

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/66818.diff


2 Files Affected:

- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+1-1) 
- (modified) llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll (+4-4) 


``````````diff
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 2ce08a2ff43955b..0c4ea1b3d9f04d9 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 e0ac148456cacbb..60a1fafc3c92c80 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

``````````

</details>


https://github.com/llvm/llvm-project/pull/66818


More information about the llvm-commits mailing list