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

Chris Lattner lattner at cs.uiuc.edu
Mon May 1 15:03:36 PDT 2006



Changes in directory llvm/lib/CodeGen:

VirtRegMap.cpp updated: 1.64 -> 1.65
VirtRegMap.h updated: 1.20 -> 1.21
---
Log message:

Fix a latent bug that my spiller patch last week exposed: we were leaving
instructions in the virtregfolded map that were deleted.  Because they 
were deleted, newly allocated instructions could end up at the same address,
magically finding themselves in the map.  The solution is to remove entries
from the map when we delete the instructions.


---
Diffs of the changes:  (+7 -4)

 VirtRegMap.cpp |    4 ++++
 VirtRegMap.h   |    7 +++----
 2 files changed, 7 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.64 llvm/lib/CodeGen/VirtRegMap.cpp:1.65
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.64	Mon May  1 16:17:10 2006
+++ llvm/lib/CodeGen/VirtRegMap.cpp	Mon May  1 17:03:24 2006
@@ -730,6 +730,7 @@
           assert(VirtRegMap::isMod && "Can't be modref!");
           DEBUG(std::cerr << "Removed dead store:\t" << *MDSI->second);
           MBB.erase(MDSI->second);
+          VRM.RemoveFromFoldedVirtMap(MDSI->second);
           MaybeDeadStores.erase(MDSI);
           ++NumDSE;
         }
@@ -791,6 +792,7 @@
               ++NumDCE;
               DEBUG(std::cerr << "Removing now-noop copy: " << MI);
               MBB.erase(&MI);
+              VRM.RemoveFromFoldedVirtMap(&MI);
               goto ProcessNextInst;
             }
             Spills.ClobberPhysReg(VirtReg);
@@ -825,6 +827,7 @@
             ++NumDCE;
             DEBUG(std::cerr << "Removing now-noop copy: " << MI);
             MBB.erase(&MI);
+            VRM.RemoveFromFoldedVirtMap(&MI);
             goto ProcessNextInst;
           }
         }
@@ -835,6 +838,7 @@
           DEBUG(std::cerr << "Removed dead store:\t" << *LastStore);
           ++NumDSE;
           MBB.erase(LastStore);
+          VRM.RemoveFromFoldedVirtMap(LastStore);
         }
         LastStore = next(MII);
 


Index: llvm/lib/CodeGen/VirtRegMap.h
diff -u llvm/lib/CodeGen/VirtRegMap.h:1.20 llvm/lib/CodeGen/VirtRegMap.h:1.21
--- llvm/lib/CodeGen/VirtRegMap.h:1.20	Mon May  1 16:16:03 2006
+++ llvm/lib/CodeGen/VirtRegMap.h	Mon May  1 17:03:24 2006
@@ -137,11 +137,10 @@
       return MI2VirtMap.equal_range(MI);
     }
     
-    /// RemoveFromFoldedVirtMap - Given a machine instruction in the folded
-    /// instruction map, remove the entry in the folded instruction map.
+    /// RemoveFromFoldedVirtMap - If the specified machine instruction is in
+    /// the folded instruction map, remove its entry from the map.
     void RemoveFromFoldedVirtMap(MachineInstr *MI) {
-      bool ErasedAny = MI2VirtMap.erase(MI);
-      assert(ErasedAny && "Machine instr not in folded vreg map!");
+      MI2VirtMap.erase(MI);
     }
 
     void print(std::ostream &OS) const;






More information about the llvm-commits mailing list