MIR Printer: Extract the code that prints IR slots to a separate function. NFC.
authorAlex Lorenz <arphaman@gmail.com>
Wed, 19 Aug 2015 23:24:37 +0000 (23:24 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 19 Aug 2015 23:24:37 +0000 (23:24 +0000)
This code can be reused when printing references to unnamed local IR values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245519 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MIRPrinter.cpp

index 759a8d3234d56267353b5b936e1184602ed796d5..df2f441a031c5dc18042d89d535610abbd716501 100644 (file)
@@ -581,6 +581,13 @@ void MIPrinter::printMBBReference(const MachineBasicBlock &MBB) {
   }
 }
 
+static void printIRSlotNumber(raw_ostream &OS, int Slot) {
+  if (Slot == -1)
+    OS << "<badref>";
+  else
+    OS << Slot;
+}
+
 void MIPrinter::printIRBlockReference(const BasicBlock &BB) {
   OS << "%ir-block.";
   if (BB.hasName()) {
@@ -597,10 +604,7 @@ void MIPrinter::printIRBlockReference(const BasicBlock &BB) {
     CustomMST.incorporateFunction(*F);
     Slot = CustomMST.getLocalSlot(&BB);
   }
-  if (Slot == -1)
-    OS << "<badref>";
-  else
-    OS << Slot;
+  printIRSlotNumber(OS, Slot);
 }
 
 void MIPrinter::printIRValueReference(const Value &V) {