[llvm-branch-commits] [llvm-branch] r72852 - in /llvm/branches/Apple/Bender: lib/CodeGen/VirtRegRewriter.cpp test/CodeGen/X86/2009-06-02-RewriterBug.ll

Bill Wendling isanbard at gmail.com
Wed Jun 3 23:55:39 PDT 2009


Author: void
Date: Thu Jun  4 01:55:38 2009
New Revision: 72852

URL: http://llvm.org/viewvc/llvm-project?rev=72852&view=rev
Log:
--- Merging r72758 into '.':
A    test/CodeGen/X86/2009-06-02-RewriterBug.ll
U    lib/CodeGen/VirtRegRewriter.cpp

Fix for PR4225: When rewriter reuse a value in a physical register , it clear
the register kill operand marker and its kill ops information. However, the
cleared operand may be a def of a super-register. Clear the kill ops info for
the super-register's sub-registers as well.

Added:
    llvm/branches/Apple/Bender/test/CodeGen/X86/2009-06-02-RewriterBug.ll
      - copied unchanged from r72758, llvm/trunk/test/CodeGen/X86/2009-06-02-RewriterBug.ll
Modified:
    llvm/branches/Apple/Bender/lib/CodeGen/VirtRegRewriter.cpp

Modified: llvm/branches/Apple/Bender/lib/CodeGen/VirtRegRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Bender/lib/CodeGen/VirtRegRewriter.cpp?rev=72852&r1=72851&r2=72852&view=diff

==============================================================================
--- llvm/branches/Apple/Bender/lib/CodeGen/VirtRegRewriter.cpp (original)
+++ llvm/branches/Apple/Bender/lib/CodeGen/VirtRegRewriter.cpp Thu Jun  4 01:55:38 2009
@@ -374,9 +374,11 @@
                            std::vector<MachineOperand*> &KillOps) {
   if (RegKills[Reg]) {
     KillOps[Reg]->setIsKill(false);
-    KillOps[Reg] = NULL;
-    RegKills.reset(Reg);
-    for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) {
+    // KillOps[Reg] might be a def of a super-register.
+    unsigned KReg = KillOps[Reg]->getReg();
+    KillOps[KReg] = NULL;
+    RegKills.reset(KReg);
+    for (const unsigned *SR = TRI->getSubRegisters(KReg); *SR; ++SR) {
       if (RegKills[*SR]) {
         KillOps[*SR]->setIsKill(false);
         KillOps[*SR] = NULL;
@@ -479,8 +481,18 @@
       // That can't be right. Register is killed but not re-defined and it's
       // being reused. Let's fix that.
       KillOps[Reg]->setIsKill(false);
-      KillOps[Reg] = NULL;
-      RegKills.reset(Reg);
+      // KillOps[Reg] might be a def of a super-register.
+      unsigned KReg = KillOps[Reg]->getReg();
+      KillOps[KReg] = NULL;
+      RegKills.reset(KReg);
+
+      // Must be a def of a super-register. Its other sub-regsters are no
+      // longer killed as well.
+      for (const unsigned *SR = TRI->getSubRegisters(KReg); *SR; ++SR) {
+        KillOps[*SR] = NULL;
+        RegKills.reset(*SR);
+      }
+
       if (!MI.isRegTiedToDefOperand(i))
         // Unless it's a two-address operand, this is the new kill.
         MO.setIsKill();
@@ -1045,6 +1057,8 @@
       VRM.RemoveMachineInstrFromMaps(&NextMI);
       MBB.erase(&NextMI);
       ++NumModRefUnfold;
+      if (NextMII == MBB.end())
+        break;
     } while (FoldsStackSlotModRef(*NextMII, SS, PhysReg, TII, TRI, VRM));
 
     // Store the value back into SS.





More information about the llvm-branch-commits mailing list