[GlobalISel] Dump all instructions inserted by selector.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 8 Nov 2016 19:27:13 +0000 (19:27 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 8 Nov 2016 19:27:13 +0000 (19:27 +0000)
This is helpful when multiple instructions are inserted.

llvm-svn: 286273

llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp

index 653c242..6688142 100644 (file)
@@ -113,13 +113,19 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
 
       if (!ISel->select(MI)) {
         if (TPC.isGlobalISelAbortEnabled())
-          // FIXME: It would be nice to dump all inserted instructions.  It's
-          // not
-          // obvious how, esp. considering select() can insert after MI.
           reportSelectionError(MI, "Cannot select");
         Failed = true;
         break;
       }
+
+      // Dump the range of instructions that MI expanded into.
+      DEBUG({
+        auto InsertedBegin = ReachedBegin ? MBB->begin() : std::next(MII);
+        dbgs() << "Into:\n";
+        for (auto &InsertedMI : make_range(InsertedBegin, AfterIt))
+          dbgs() << "  " << InsertedMI;
+        dbgs() << '\n';
+      });
     }
   }