]> granicus.if.org Git - llvm/commitdiff
CodeGen: Add the other BuildMI overload for MachineInstr&
authorJustin Bogner <mail@justinbogner.com>
Thu, 30 Jun 2016 18:32:12 +0000 (18:32 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 30 Jun 2016 18:32:12 +0000 (18:32 +0000)
The change in r274193 missed this variant.

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

include/llvm/CodeGen/MachineInstrBuilder.h

index da0afc320357601886bc96a2e06a61d10b01658e..37b67aa0cf5c0aef8d32929aa68d23df500b264f 100644 (file)
@@ -320,16 +320,20 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
   return MachineInstrBuilder(MF, MI);
 }
 
-inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I,
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I,
                                    const DebugLoc &DL,
                                    const MCInstrDesc &MCID) {
-  if (I->isInsideBundle()) {
-    MachineBasicBlock::instr_iterator MII(I);
-    return BuildMI(BB, MII, DL, MCID);
-  }
+  // Calling the overload for instr_iterator is always correct.  However, the
+  // definition is not available in headers, so inline the check.
+  if (I.isInsideBundle())
+    return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID);
+  return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID);
+}
 
-  MachineBasicBlock::iterator MII = I;
-  return BuildMI(BB, MII, DL, MCID);
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I,
+                                   const DebugLoc &DL,
+                                   const MCInstrDesc &MCID) {
+  return BuildMI(BB, *I, DL, MCID);
 }
 
 /// This version of the builder inserts the newly-built instruction at the end