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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Sorry for the delay.
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
1939 | Currently, these IDs are only generated with -basic-block-sections=labels|list, but IIUC -mbb-profile-dump does not require these flags. We can either have these IDs always generated, or add sanity checks to make sure -mbb-profile-dump is always used with -basic-block-sections. | |
llvm/test/CodeGen/MLRegalloc/bb-profile-dump.ll | ||
6 | It's interesting that this works. Maybe just use -basic-block-sections=labels to be safe. |
All good on the timing. Thanks for the review!
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
1939 | We are requiring -basic-block-sections=labels according to the help string, but we aren't checking if both are enabled at the same time. I've added a check (and test) to ensure that the MachineFunction we're going over has BB labels. The check emits an error otherwise. |
llvm/test/CodeGen/MLRegalloc/bb-profile-dump.ll | ||
---|---|---|
39 | Remove this redundant line. |
Currently, these IDs are only generated with -basic-block-sections=labels|list, but IIUC -mbb-profile-dump does not require these flags. We can either have these IDs always generated, or add sanity checks to make sure -mbb-profile-dump is always used with -basic-block-sections.