[llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 5 11:31:24 PDT 2005



Changes in directory llvm/lib/CodeGen:

VirtRegMap.cpp updated: 1.40 -> 1.41
---
Log message:

Fix a bug in the local spiller, where we could take code like this:

  store r12 -> [ss#2]
  R3 = load [ss#1]
  use R3
  R3 = load [ss#2]
  R4 = load [ss#1]

and turn it into this code:

  store R12 -> [ss#2]
  R3 = load [ss#1]
  use R3
  R3 = R12
  R4 = R3    <- oops!

The problem was that promoting R3 = load[ss#2] to a copy missed the fact that
the instruction invalidated R3 at that point.



---
Diffs of the changes:  (+5 -5)

 VirtRegMap.cpp |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.40 llvm/lib/CodeGen/VirtRegMap.cpp:1.41
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.40	Thu Sep 29 20:29:00 2005
+++ llvm/lib/CodeGen/VirtRegMap.cpp	Wed Oct  5 13:30:19 2005
@@ -490,11 +490,11 @@
             if (DestReg != It->second) {
               MRI->copyRegToReg(MBB, &MI, DestReg, It->second,
                                 MF.getSSARegMap()->getRegClass(VirtReg));
-              // Revisit the copy if the destination is a vreg.
-              if (MRegisterInfo::isVirtualRegister(DestReg)) {
-                NextMII = &MI;
-                --NextMII;  // backtrack to the copy.
-              }
+              // Revisit the copy so we make sure to notice the effects of the
+              // operation on the destreg (either needing to RA it if it's 
+              // virtual or needing to clobber any values if it's physical).
+              NextMII = &MI;
+              --NextMII;  // backtrack to the copy.
             }
             MBB.erase(&MI);
             goto ProcessNextInst;






More information about the llvm-commits mailing list