[llvm] r369650 - [SlotIndexes] Add print-slotindexes to disable printing slotindexes

Jinsong Ji via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 06:44:48 PDT 2019


Author: jsji
Date: Thu Aug 22 06:44:47 2019
New Revision: 369650

URL: http://llvm.org/viewvc/llvm-project?rev=369650&view=rev
Log:
[SlotIndexes] Add print-slotindexes to disable printing slotindexes

Summary:
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 introduces an option to hide indexes.

Reviewers: stoklund, thegameg, qcolombet

Reviewed By: thegameg

Subscribers: hiraditya, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66500

Added:
    llvm/trunk/test/Other/print-slotindexes.ll
Modified:
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=369650&r1=369649&r2=369650&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Thu Aug 22 06:44:47 2019
@@ -39,6 +39,12 @@ using namespace llvm;
 
 #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(true), cl::Hidden);
+
 MachineBasicBlock::MachineBasicBlock(MachineFunction &MF, const BasicBlock *B)
     : BB(B), Number(-1), xParent(&MF) {
   Insts.Parent = this;
@@ -291,7 +297,7 @@ void MachineBasicBlock::print(raw_ostrea
     return;
   }
 
-  if (Indexes)
+  if (Indexes && PrintSlotIndexes)
     OS << Indexes->getMBBStartIdx(this) << '\t';
 
   OS << "bb." << getNumber();
@@ -402,7 +408,7 @@ void MachineBasicBlock::print(raw_ostrea
 
   bool IsInBundle = false;
   for (const MachineInstr &MI : instrs()) {
-    if (Indexes) {
+    if (Indexes && PrintSlotIndexes) {
       if (Indexes->hasIndex(MI))
         OS << Indexes->getInstructionIndex(MI);
       OS << '\t';

Added: llvm/trunk/test/Other/print-slotindexes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/print-slotindexes.ll?rev=369650&view=auto
==============================================================================
--- llvm/trunk/test/Other/print-slotindexes.ll (added)
+++ llvm/trunk/test/Other/print-slotindexes.ll Thu Aug 22 06:44:47 2019
@@ -0,0 +1,12 @@
+; RUN: llc -print-after=slotindexes < %s 2>&1 | FileCheck %s --check-prefixes=ALL,SI 
+; RUN: llc -print-after=slotindexes -print-slotindexes=false < %s 2>&1 | FileCheck %s --check-prefixes=ALL,NOSI
+; REQUIRES: default_triple
+define void @foo(){
+  ret void
+}
+
+;CHECK: IR Dump {{.*}}
+;CHECK: # Machine code for function foo{{.*}}
+;SI: {{[0-9]+}}B bb.0 (%ir-block.0)
+;NOSI: {{^}}bb.0 (%ir-block.0)
+




More information about the llvm-commits mailing list