[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 Mar 31 18:59:11 PDT 2023
aidengrossman created this revision.
Herald added subscribers: hiraditya, qcolombet, MatzeB.
Herald added a project: All.
aidengrossman requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currenty, setting the -mbb-profile-dump dumps a CSV file with blocks
inside an individual function identified by their MBB numbers. This
patch changes the MBBs to be identified by their ID which is set at MBB
creation and not changed afterwards, making it inherently stable
throughout the backend. This alleviates concerns with the MBB IDs
changing between the profile dump and what ends up in the final object
file. The MBBs inside the SHT_LLVM_BB_ADDR_MAP sections are also
identified using their MBB ID rather than number, so if we want to match
them up we need to identify the MBBs here by number.
Repository:
rG LLVM Github Monorepo
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,7 +3,7 @@
; 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=list -mbb-profile-dump=- %s | FileCheck %s
; bb profile dump is not supported on NVPTX
; UNSUPPORTED: target=nvptx{{.*}}
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1924,14 +1924,14 @@
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) {
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.510160.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230401/98a869e7/attachment.bin>
More information about the llvm-commits
mailing list