[PATCH] D66500: [SlotIndexes] Only print slotindexes when required

Jinsong Ji via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 15:10:00 PDT 2019


jsji created this revision.
jsji added reviewers: stoklund, thegameg.
Herald added subscribers: llvm-commits, arphaman, hiraditya.
Herald added a project: LLVM.

When we print the IR with --print-after/before-*,
SlotIndexes will be printed whenever available (We haven't freed it).

This introduces some noises when we try to compare the IR
among different optimizations.

eg:
-print-before=machine-cp will print SlotIndexes for 1st machine-cp
pass, but NOT for 2nd machine-cp;
-print-after=machine-cp will NOT print SlotIndexes for both
machine-cp passes.
So SlotIndexes in 1st pass introduce noises when differing these IRs.

This patch simply hide the slotindex by default, but introduce an option to
revert to old behavior, print indexes if required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66500

Files:
  llvm/lib/CodeGen/MachineBasicBlock.cpp


Index: llvm/lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -39,6 +39,12 @@
 
 #define DEBUG_TYPE "codegen"
 
+static cl::opt<bool> PrintSlotIndexes(
+    "print-slotindexes",
+    cl::desc("When printing machine IR, annotate instructions and blocks with "
+             "SlotIndexes when available"),
+    cl::init(false), cl::Hidden);
+
 MachineBasicBlock::MachineBasicBlock(MachineFunction &MF, const BasicBlock *B)
     : BB(B), Number(-1), xParent(&MF) {
   Insts.Parent = this;
@@ -291,7 +297,7 @@
     return;
   }
 
-  if (Indexes)
+  if (Indexes && PrintSlotIndexes)
     OS << Indexes->getMBBStartIdx(this) << '\t';
 
   OS << "bb." << getNumber();
@@ -402,7 +408,7 @@
 
   bool IsInBundle = false;
   for (const MachineInstr &MI : instrs()) {
-    if (Indexes) {
+    if (Indexes && PrintSlotIndexes) {
       if (Indexes->hasIndex(MI))
         OS << Indexes->getInstructionIndex(MI);
       OS << '\t';


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66500.216265.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190820/f1ad31fb/attachment.bin>


More information about the llvm-commits mailing list