- Add LiveVariables::replaceKillInstruction. This does a subset of instructionChanged...
authorEvan Cheng <evan.cheng@apple.com>
Thu, 3 Jul 2008 00:07:19 +0000 (00:07 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 3 Jul 2008 00:07:19 +0000 (00:07 +0000)
- CommuteInstruction copies kill / dead markers over to new instruction. So use replaceKillInstruction instead.

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

include/llvm/CodeGen/LiveVariables.h
lib/CodeGen/LiveVariables.cpp
lib/CodeGen/TwoAddressInstructionPass.cpp

index efa5f3c869fdd4b17f2e540b9e1e5d2817aeb347..bbefbe08c08b5f1d4aee37b9121dad62c0ef7eca 100644 (file)
@@ -189,6 +189,11 @@ public:
   /// the records for NewMI.
   void instructionChanged(MachineInstr *OldMI, MachineInstr *NewMI);
 
   /// the records for NewMI.
   void instructionChanged(MachineInstr *OldMI, MachineInstr *NewMI);
 
+  /// replaceKillInstruction - Update register kill info by replacing a kill
+  /// instruction with a new one.
+  void replaceKillInstruction(unsigned Reg, MachineInstr *OldMI,
+                              MachineInstr *NewMI);
+
   /// addVirtualRegisterKilled - Add information about the fact that the
   /// specified register is killed after being used by the specified
   /// instruction. If AddIfNotFound is true, add a implicit operand if it's
   /// addVirtualRegisterKilled - Add information about the fact that the
   /// specified register is killed after being used by the specified
   /// instruction. If AddIfNotFound is true, add a implicit operand if it's
index ab73c97ec9e8fbbdc8214ffb8d734909f74a26eb..ee4492b6ddc801a6668a4e4f15699617ef474203 100644 (file)
@@ -684,6 +684,15 @@ void LiveVariables::instructionChanged(MachineInstr *OldMI,
   }
 }
 
   }
 }
 
+/// replaceKillInstruction - Update register kill info by replacing a kill
+/// instruction with a new one.
+void LiveVariables::replaceKillInstruction(unsigned Reg, MachineInstr *OldMI,
+                                           MachineInstr *NewMI) {
+  VarInfo &VI = getVarInfo(Reg);
+  if (VI.removeKill(OldMI))
+    VI.Kills.push_back(NewMI);   // Yes, there was a kill of it
+}
+
 /// removeVirtualRegistersKilled - Remove all killed info for the specified
 /// instruction.
 void LiveVariables::removeVirtualRegistersKilled(MachineInstr *MI) {
 /// removeVirtualRegistersKilled - Remove all killed info for the specified
 /// instruction.
 void LiveVariables::removeVirtualRegistersKilled(MachineInstr *MI) {
index d2e5288d34b6cfb5f8b2ea28f04d1d47861445fe..480d6dd3897c278d3d555d3fec25bab784f9490f 100644 (file)
@@ -375,10 +375,9 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
                   DOUT << "2addr: COMMUTED TO: " << *NewMI;
                   // If the instruction changed to commute it, update livevar.
                   if (NewMI != mi) {
                   DOUT << "2addr: COMMUTED TO: " << *NewMI;
                   // If the instruction changed to commute it, update livevar.
                   if (NewMI != mi) {
-                    if (LV) {
+                    if (LV)
                       // Update live variables
                       // Update live variables
-                      LV->instructionChanged(mi, NewMI); 
-                    }
+                      LV->replaceKillInstruction(regC, mi, NewMI);
                     
                     mbbi->insert(mi, NewMI);           // Insert the new inst
                     mbbi->erase(mi);                   // Nuke the old inst.
                     
                     mbbi->insert(mi, NewMI);           // Insert the new inst
                     mbbi->erase(mi);                   // Nuke the old inst.