[PATCH] D137467: [NFC][BlockPlacement]Add an option to renumber blocks based on function layout order.
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 4 14:52:27 PDT 2022
mingmingl created this revision.
mingmingl added reviewers: davidxl, Carrot.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mingmingl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Use case:
- When block layout is visualized after MBP pass, the basic blocks
are labeled in layout order; meanwhile blocks could be numbered in a
different order.
- As a result, it's hard to map between the graph and pass output. With this option on, the basic blocks are renumbered in function layout order.
This option is only useful when a function is to be visualized (i.e., when view options are on) to make it debugging only.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137467
Files:
llvm/lib/CodeGen/MachineBlockPlacement.cpp
Index: llvm/lib/CodeGen/MachineBlockPlacement.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -201,6 +201,18 @@
cl::init(2),
cl::Hidden);
+// Use case: When block layout is visualized after MBP pass, the basic blocks
+// are labeled in layout order; meanwhile blocks could be numbered in a
+// different order. It's hard to map between the graph and pass output.
+// With this option on, the basic blocks are renumbered in function layout
+// order. For debugging only.
+static cl::opt<bool> RenumberBlocksBeforeView(
+ "renumber-blocks-before-view",
+ cl::desc(
+ "If true, basic blocks are re-numbered before MBP layout is printed "
+ "into a dot graph. Only used when a function is being printed."),
+ cl::init(false), cl::Hidden);
+
extern cl::opt<bool> EnableExtTspBlockPlacement;
extern cl::opt<bool> ApplyExtTspWithoutProfile;
@@ -3466,6 +3478,8 @@
if (ViewBlockLayoutWithBFI != GVDT_None &&
(ViewBlockFreqFuncName.empty() ||
F->getFunction().getName().equals(ViewBlockFreqFuncName))) {
+ if (RenumberBlocksBeforeView)
+ MF.RenumberBlocks();
MBFI->view("MBP." + MF.getName(), false);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137467.473346.patch
Type: text/x-patch
Size: 1289 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221104/fafb3543/attachment.bin>
More information about the llvm-commits
mailing list