Add explicit keywords.
[oota-llvm.git] / lib / CodeGen / RegAllocLocal.cpp
index 12064a957c174eea6062307b0300e758fde71222..765e7ff96ff7e83a277b9114343ed6c817cef079 100644 (file)
@@ -303,17 +303,12 @@ void RALocal::spillVirtReg(MachineBasicBlock &MBB,
     const TargetRegisterClass *RC = MF->getRegInfo().getRegClass(VirtReg);
     int FrameIndex = getStackSpaceFor(VirtReg, RC);
     DOUT << " to stack slot #" << FrameIndex;
-    TII->storeRegToStackSlot(MBB, I, PhysReg, true, FrameIndex, RC);
-
     // 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.
-    if (I != MBB.end() && I->findRegisterUseOperandIdx(PhysReg) != -1) {
-      MachineBasicBlock::iterator StoreMI = prior(I);
-      int Idx = StoreMI->findRegisterUseOperandIdx(PhysReg, true);
-      assert(Idx != -1 && "Unrecognized spill instruction!");
-      StoreMI->getOperand(Idx).setIsKill(false);
-    }
+    bool isKill = !(I != MBB.end() &&
+                    I->findRegisterUseOperandIdx(PhysReg) != -1);
+    TII->storeRegToStackSlot(MBB, I, PhysReg, isKill, FrameIndex, RC);
     ++NumStores;   // Update statistics
   }
 
@@ -780,11 +775,12 @@ void RALocal::AllocateBasicBlock(MachineBasicBlock &MBB) {
 
   // Spill all physical registers holding virtual registers now.
   for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i)
-    if (PhysRegsUsed[i] != -1 && PhysRegsUsed[i] != -2)
+    if (PhysRegsUsed[i] != -1 && PhysRegsUsed[i] != -2) {
       if (unsigned VirtReg = PhysRegsUsed[i])
         spillVirtReg(MBB, MI, VirtReg, i);
       else
         removePhysReg(i);
+    }
 
 #if 0
   // This checking code is very expensive.