Correctly clone FlaggedNodes.
[oota-llvm.git] / lib / CodeGen / RegAllocLocal.cpp
index 99fc6c9028ab7ba4a6d9b3e55c8af02570ba3e2e..5eceae4ec612a2c9e3fe68bdc108de51d7f577e9 100644 (file)
@@ -306,8 +306,7 @@ void RALocal::spillVirtReg(MachineBasicBlock &MBB,
     // If the instruction reads the register that's spilled, (e.g. this can
     // happen if it is a move to a physical register), then the spill
     // instruction is not a kill.
-    bool isKill = !(I != MBB.end() &&
-                    I->findRegisterUseOperandIdx(PhysReg) != -1);
+    bool isKill = !(I != MBB.end() && I->readsRegister(PhysReg));
     TII->storeRegToStackSlot(MBB, I, PhysReg, isKill, FrameIndex, RC);
     ++NumStores;   // Update statistics
   }
@@ -480,8 +479,9 @@ MachineInstr *RALocal::reloadVirtReg(MachineBasicBlock &MBB, MachineInstr *MI,
   // If the virtual register is already available, just update the instruction
   // and return.
   if (unsigned PR = getVirt2PhysRegMapSlot(VirtReg)) {
-    MarkPhysRegRecentlyUsed(PR);          // Already have this value available!
+    MarkPhysRegRecentlyUsed(PR);       // Already have this value available!
     MI->getOperand(OpNum).setReg(PR);  // Assign the input register
+    getVirtRegLastUse(VirtReg) = std::make_pair(MI, OpNum);
     return MI;
   }