Skip to content

Commit d8873df

Browse files
authored
[AsmPrint] Dump raw frequencies in -mbb-profile-dump (#66818)
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.
1 parent b88cffe commit d8873df

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ void AsmPrinter::emitFunctionBody() {
19401940
for (const auto &MBB : *MF) {
19411941
*MBBProfileDumpFileOutput.get()
19421942
<< MF->getName() << "," << MBB.getBBID() << ","
1943-
<< MBFI.getBlockFreqRelativeToEntryBlock(&MBB) << "\n";
1943+
<< MBFI.getBlockFreq(&MBB).getFrequency() << "\n";
19441944
}
19451945
}
19461946
}

llvm/test/CodeGen/MLRegAlloc/bb-profile-dump.ll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ define i64 @f2(i64 %a, i64 %b) {
1212
ret i64 %sum
1313
}
1414

15+
; CHECK: f2,0,8
16+
1517
define i64 @f1() {
1618
%sum = call i64 @f2(i64 2, i64 2)
1719
%isEqual = icmp eq i64 %sum, 4
@@ -22,10 +24,9 @@ ifNotEqual:
2224
ret i64 %sum
2325
}
2426

25-
; CHECK: f2,0,1.000000e+00
26-
; CHECK-NEXT: f1,0,1.000000e+00
27-
; CHECK-NEXT: f1,1,5.000000e-01
28-
; CHECK-NEXT: f1,2,1.000000e+00
27+
; CHECK-NEXT: f1,0,16
28+
; CHECK-NEXT: f1,1,8
29+
; CHECK-NEXT: f1,2,16
2930

3031
; Check that if we pass -mbb-profile-dump but don't set -basic-block-sections,
3132
; we get an appropriate error message

0 commit comments

Comments
 (0)