Fix PR3667
[oota-llvm.git] / lib / CodeGen / VirtRegMap.cpp
index f288dcc87cfefa0cfb9edfd2df5cb5df31fca226..e2dc636e69119c00377748613022631b4aada493 100644 (file)
@@ -1599,6 +1599,12 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
 
             PotentialDeadStoreSlots.push_back(ReuseSlot);
           }
+
+          // Assumes this is the last use. IsKill will be unset if reg is reused
+          // unless it's a two-address operand.
+          if (ti == -1)
+            MI.getOperand(i).setIsKill();
+
           continue;
         }  // CanReuse
         
@@ -1764,6 +1770,11 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
                 DefMO = NextMII->findRegisterDefOperand(DestReg);
                 DefMO->setSubReg(SubIdx);
               }
+
+              // Mark is killed.
+              MachineOperand *KillOpnd = NextMII->findRegisterUseOperand(InReg);
+              KillOpnd->setIsKill();
+
               BackTracked = true;
             } else {
               DOUT << "Removing now-noop copy: " << MI;