Add an MF argument to MI::copyImplicitOps().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 20 Dec 2012 22:54:02 +0000 (22:54 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 20 Dec 2012 22:54:02 +0000 (22:54 +0000)
This function is often used to decorate dangling instructions, so a
context reference is required to allocate memory for the operands.

Also add a corresponding MachineInstrBuilder method.

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

include/llvm/CodeGen/MachineInstr.h
include/llvm/CodeGen/MachineInstrBuilder.h
lib/CodeGen/MachineInstr.cpp
lib/Target/ARM/ARMFrameLowering.cpp
lib/Target/ARM/ARMLoadStoreOptimizer.cpp
lib/Target/ARM/Thumb1FrameLowering.cpp
lib/Target/X86/X86FrameLowering.cpp

index 00df495c44b19df2f598d30f01ea70ab08d921e4..c34711cb336fcb1af663fb3e72f700c223020541 100644 (file)
@@ -929,7 +929,7 @@ public:
 
   /// copyImplicitOps - Copy implicit register operands from specified
   /// instruction to this instruction.
-  void copyImplicitOps(const MachineInstr *MI);
+  void copyImplicitOps(MachineFunction &MF, const MachineInstr *MI);
 
   //
   // Debugging support
index 0fc284cbd8522d54d0745736f66406bd3b34aec0..a2d3d63bdbbd11e063f757fdc28688532fca6f5e 100644 (file)
@@ -208,6 +208,12 @@ public:
       }
     }
   }
+
+  /// Copy all the implicit operands from OtherMI onto this one.
+  const MachineInstrBuilder &copyImplicitOps(const MachineInstr *OtherMI) {
+    MI->copyImplicitOps(*MF, OtherMI);
+    return *this;
+  }
 };
 
 /// BuildMI - Builder interface.  Specify how to create the initial instruction
index fff4a67e41d5942ee8e85cf5d0eb6ef860b50b8a..a98949025a26dd3e4abbd66681e93c0b839adef8 100644 (file)
@@ -1403,12 +1403,13 @@ bool MachineInstr::allDefsAreDead() const {
 
 /// copyImplicitOps - Copy implicit register operands from specified
 /// instruction to this instruction.
-void MachineInstr::copyImplicitOps(const MachineInstr *MI) {
+void MachineInstr::copyImplicitOps(MachineFunction &MF,
+                                   const MachineInstr *MI) {
   for (unsigned i = MI->getDesc().getNumOperands(), e = MI->getNumOperands();
        i != e; ++i) {
     const MachineOperand &MO = MI->getOperand(i);
     if (MO.isReg() && MO.isImplicit())
-      addOperand(MO);
+      addOperand(MF, MO);
   }
 }
 
index 297d0c016bb45664b55fd7b80d0e52fd03688e2c..c9591ea27c86d27806ed938951c520c65852f15c 100644 (file)
@@ -696,7 +696,7 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
       for (unsigned i = 0, e = Regs.size(); i < e; ++i)
         MIB.addReg(Regs[i], getDefRegState(true));
       if (DeleteRet) {
-        MIB->copyImplicitOps(&*MI);
+        MIB.copyImplicitOps(&*MI);
         MI->eraseFromParent();
       }
       MI = MIB;
index a13f917d9e2897b92a2f1b6712b524c307a2becd..ec728b8b2784f0348f52f91678f9cc34d5e82c0a 100644 (file)
@@ -1408,7 +1408,7 @@ bool ARMLoadStoreOpt::MergeReturnIntoLDM(MachineBasicBlock &MBB) {
               Opcode == ARM::LDMIA_UPD) && "Unsupported multiple load-return!");
       PrevMI->setDesc(TII->get(NewOpc));
       MO.setReg(ARM::PC);
-      PrevMI->copyImplicitOps(&*MBBI);
+      PrevMI->copyImplicitOps(*MBB.getParent(), &*MBBI);
       MBB.erase(MBBI);
       return true;
     }
index edd73c20c0bef00a347ee8ae5789ea70cc002980..123ada67e18e5c89d5655c8c585288e75a670e7a 100644 (file)
@@ -281,7 +281,7 @@ void Thumb1FrameLowering::emitEpilogue(MachineFunction &MF,
       BuildMI(MBB, MBBI, dl, TII.get(ARM::tBX_RET_vararg))
       .addReg(ARM::R3, RegState::Kill);
     AddDefaultPred(MIB);
-    MIB->copyImplicitOps(&*MBBI);
+    MIB.copyImplicitOps(&*MBBI);
     // erase the old tBX_RET instruction
     MBB.erase(MBBI);
   }
@@ -352,7 +352,7 @@ restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
         continue;
       Reg = ARM::PC;
       (*MIB).setDesc(TII.get(ARM::tPOP_RET));
-      MIB->copyImplicitOps(&*MI);
+      MIB.copyImplicitOps(&*MI);
       MI = MBB.erase(MI);
     }
     MIB.addReg(Reg, getDefRegState(true));
index 3deec5cd7f688eabf4c46dc2195bd12bb59dbd9b..1d5457297d03982288a126df6d7d378903ec98a3 100644 (file)
@@ -1138,7 +1138,7 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
     }
 
     MachineInstr *NewMI = prior(MBBI);
-    NewMI->copyImplicitOps(MBBI);
+    NewMI->copyImplicitOps(MF, MBBI);
 
     // Delete the pseudo instruction TCRETURN.
     MBB.erase(MBBI);