Fix up instruction classes for Thumb2 RSB instructions to be consistent with
[oota-llvm.git] / lib / CodeGen / RegAllocLocal.cpp
index 8106a36c9b488634fe222bc7d5f27828a0f185e3..321ae12def5710554a64c8b1efcd55a600f78c69 100644 (file)
@@ -301,6 +301,16 @@ void RALocal::storeVirtReg(MachineBasicBlock &MBB,
   DEBUG(dbgs() << " to stack slot #" << FrameIndex);
   TII->storeRegToStackSlot(MBB, I, PhysReg, isKill, FrameIndex, RC, TRI);
   ++NumStores;   // Update statistics
+
+  // Mark the spill instruction as last use if we're not killing the register.
+  if (!isKill) {
+    MachineInstr *Spill = llvm::prior(I);
+    int OpNum = Spill->findRegisterUseOperandIdx(PhysReg);
+    if (OpNum < 0)
+      getVirtRegLastUse(VirtReg) = std::make_pair((MachineInstr*)0, 0);
+    else
+      getVirtRegLastUse(VirtReg) = std::make_pair(Spill, OpNum);
+  }
 }
 
 /// spillVirtReg - This method spills the value specified by PhysReg into the