[llvm] r325032 - [CodeGen] Print bundled instructions using the MIR syntax in -debug output

Francis Visoiu Mistrih via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 10:08:26 PST 2018


Author: thegameg
Date: Tue Feb 13 10:08:26 2018
New Revision: 325032

URL: http://llvm.org/viewvc/llvm-project?rev=325032&view=rev
Log:
[CodeGen] Print bundled instructions using the MIR syntax in -debug output

Old syntax:

BUNDLE implicit-def %r0, implicit-def %r1, implicit %r2
* %r0 = SOME_OP %r2
* %r1 = ANOTHER_OP internal %r0

New syntax:

BUNDLE implicit-def %r0, implicit-def %r1, implicit %r2 {
  %r0 = SOME_OP %r2
  %r1 = ANOTHER_OP internal %r0
}

Modified:
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
    llvm/trunk/test/CodeGen/ARM/sched-it-debug-nodes.mir

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=325032&r1=325031&r2=325032&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Tue Feb 13 10:08:26 2018
@@ -324,6 +324,7 @@ void MachineBasicBlock::print(raw_ostrea
 
   const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
   const MachineRegisterInfo &MRI = MF->getRegInfo();
+  const TargetInstrInfo &TII = *getParent()->getSubtarget().getInstrInfo();
   if (!livein_empty() && MRI.tracksLiveness()) {
     if (Indexes) OS << '\t';
     OS.indent(2) << "liveins: ";
@@ -384,19 +385,34 @@ void MachineBasicBlock::print(raw_ostrea
     OS << '\n';
   }
 
-  for (auto &I : instrs()) {
+  bool IsInBundle = false;
+  for (const MachineInstr &MI : instrs()) {
     if (Indexes) {
-      if (Indexes->hasIndex(I))
-        OS << Indexes->getInstructionIndex(I);
+      if (Indexes->hasIndex(MI))
+        OS << Indexes->getInstructionIndex(MI);
       OS << '\t';
     }
-    OS << '\t';
-    if (I.isInsideBundle())
-      OS << "  * ";
-    I.print(OS, MST, IsStandalone);
+
+    if (IsInBundle && !MI.isInsideBundle()) {
+      OS.indent(2) << "}\n";
+      IsInBundle = false;
+    }
+
+    OS.indent(IsInBundle ? 4 : 2);
+    MI.print(OS, MST, IsStandalone, /*SkipOpers=*/false, /*SkipDebugLoc=*/false,
+             &TII);
+
+    if (!IsInBundle && MI.getFlag(MachineInstr::BundledSucc)) {
+      OS << " {";
+      IsInBundle = true;
+    }
+
     OS << '\n';
   }
 
+  if (IsInBundle)
+    OS.indent(2) << "}\n";
+
   if (IrrLoopHeaderWeight) {
     if (Indexes) OS << '\t';
     OS << "    Irreducible loop header weight: "

Modified: llvm/trunk/test/CodeGen/ARM/sched-it-debug-nodes.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/sched-it-debug-nodes.mir?rev=325032&r1=325031&r2=325032&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/sched-it-debug-nodes.mir (original)
+++ llvm/trunk/test/CodeGen/ARM/sched-it-debug-nodes.mir Tue Feb 13 10:08:26 2018
@@ -32,9 +32,9 @@
   ; debug value as KILL'ed, resulting in a DEBUG_VALUE node changing codegen!  (or
   ; hopefully, triggering an assert).
 
-  ; CHECK: BUNDLE implicit-def dead $itstate
-  ; CHECK:  * DBG_VALUE debug-use $r1, debug-use $noreg, !"u"
-  ; CHECK-NOT:  * DBG_VALUE killed $r1, $noreg, !"u"
+  ; CHECK: BUNDLE implicit-def dead $itstate{{.*}} {
+  ; CHECK: DBG_VALUE debug-use $r1, debug-use $noreg, !"u"
+  ; CHECK-NOT: DBG_VALUE killed $r1, $noreg, !"u"
 
   declare arm_aapcscc void @g(%struct.s*, i8*, i32) #1
 




More information about the llvm-commits mailing list