[PATCH] D147366: [MLGO] Change MBB Profile Dump from using MBB numbers to MBB IDs
Aiden Grossman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 7 00:03:51 PDT 2023
aidengrossman updated this revision to Diff 511625.
aidengrossman marked 2 inline comments as done.
aidengrossman added a comment.
Address reviewer feedback.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147366/new/
https://reviews.llvm.org/D147366
Files:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/MLRegalloc/bb-profile-dump.ll
Index: llvm/test/CodeGen/MLRegalloc/bb-profile-dump.ll
===================================================================
--- llvm/test/CodeGen/MLRegalloc/bb-profile-dump.ll
+++ llvm/test/CodeGen/MLRegalloc/bb-profile-dump.ll
@@ -3,11 +3,13 @@
; Check that the basic block profile dump outputs data and in the correct
; format.
;
-; RUN: llc -mtriple=x86_64-linux-unknown -o /dev/null -mbb-profile-dump=- %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-linux-unknown -o /dev/null -basic-block-sections=labels -mbb-profile-dump=- %s | FileCheck %s
; bb profile dump is not supported on NVPTX
; UNSUPPORTED: target=nvptx{{.*}}
+; Check that given a simple case, we can return the default MBFI
+
define i64 @f2(i64 %a, i64 %b) {
%sum = add i64 %a, %b
ret i64 %sum
@@ -27,3 +29,11 @@
; CHECK-NEXT: f1,0,1.000000e+00
; CHECK-NEXT: f1,1,5.000000e-01
; CHECK-NEXT: f1,2,1.000000e+00
+
+; Check that if we pass -mbb-profile-dump but don't set -basic-block-sections,
+; we get an appropriate error message
+
+; RUN: not llc -mtriple=x86_64-linux-unknown -o /dev/null -mbb-profile-dump=- %s 2>&1 | FileCheck --check-prefix=NO-SECTIONS %s
+
+; NO-SECTIONS: <unknown>:0: error: Unable to find BB labels for MBB profile dump. -mbb-profile-dump must be called with -basic-block-sections=labels
+; NO-SECTIONS: <unknown>:0: error: Unable to find BB labels for MBB profile dump. -mbb-profile-dump must be called with -basic-block-sections=labels
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -133,7 +133,7 @@
"mbb-profile-dump", cl::Hidden,
cl::desc("Basic block profile dump for external cost modelling. If "
"matching up BBs with afterwards, the compilation must be "
- "performed with -fbasic-block-sections=labels. Enabling this "
+ "performed with -basic-block-sections=labels. Enabling this "
"flag during in-process ThinLTO is not supported."));
const char DWARFGroupName[] = "dwarf";
@@ -1924,14 +1924,19 @@
OutStreamer->addBlankLine();
- // Output MBB numbers, function names, and frequencies if the flag to dump
+ // Output MBB ids, function names, and frequencies if the flag to dump
// MBB profile information has been set
if (MBBProfileDumpFileOutput) {
+ if (!MF->hasBBLabels())
+ MF->getContext().reportError(
+ SMLoc(),
+ "Unable to find BB labels for MBB profile dump. -mbb-profile-dump "
+ "must be called with -basic-block-sections=labels");
MachineBlockFrequencyInfo &MBFI =
getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI();
for (const auto &MBB : *MF) {
*MBBProfileDumpFileOutput.get()
- << MF->getName() << "," << MBB.getNumber() << ","
+ << MF->getName() << "," << MBB.getBBID() << ","
<< MBFI.getBlockFreqRelativeToEntryBlock(&MBB) << "\n";
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147366.511625.patch
Type: text/x-patch
Size: 3031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230407/58647995/attachment.bin>
More information about the llvm-commits
mailing list