[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.
This commit is contained in:
Mircea Trofin 2023-09-19 14:37:06 -07:00 committed by GitHub
parent b88cffeafd
commit d8873df4dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -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";
}
}
}

View File

@ -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,10 +24,9 @@ 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-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