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

Chris Lattner lattner at cs.uiuc.edu
Mon May 1 14:16:15 PDT 2006



Changes in directory llvm/lib/CodeGen:

LiveIntervalAnalysis.cpp updated: 1.155 -> 1.156
VirtRegMap.cpp updated: 1.62 -> 1.63
VirtRegMap.h updated: 1.19 -> 1.20
---
Log message:

Remove previous patch, which wasn't quite right.


---
Diffs of the changes:  (+23 -24)

 LiveIntervalAnalysis.cpp |    4 +---
 VirtRegMap.cpp           |   30 ++++++++++++------------------
 VirtRegMap.h             |   13 ++++++++++---
 3 files changed, 23 insertions(+), 24 deletions(-)


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.155 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.156
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.155	Sun Apr 30 03:41:47 2006
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp	Mon May  1 16:16:03 2006
@@ -272,9 +272,7 @@
             if (lv_)
               lv_->instructionChanged(MI, fmi);
             MachineBasicBlock &MBB = *MI->getParent();
-            bool LiveOut = li.liveAt(getInstructionIndex(&MBB.back()) +
-                                     InstrSlots::NUM);
-            vrm.virtFolded(li.reg, MI, i, fmi, LiveOut);
+            vrm.virtFolded(li.reg, MI, i, fmi);
             mi2iMap_.erase(MI);
             i2miMap_[index/InstrSlots::NUM] = fmi;
             mi2iMap_[fmi] = index;


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.62 llvm/lib/CodeGen/VirtRegMap.cpp:1.63
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.62	Mon May  1 03:54:57 2006
+++ llvm/lib/CodeGen/VirtRegMap.cpp	Mon May  1 16:16:03 2006
@@ -81,8 +81,7 @@
 }
 
 void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
-                            unsigned OpNo, MachineInstr *NewMI,
-                            bool LiveOut) {
+                            unsigned OpNo, MachineInstr *NewMI) {
   // Move previous memory references folded to new instruction.
   MI2VirtMapTy::iterator IP = MI2VirtMap.lower_bound(NewMI);
   for (MI2VirtMapTy::iterator I = MI2VirtMap.lower_bound(OldMI),
@@ -97,7 +96,6 @@
     MRInfo = isRef;
   } else {
     MRInfo = OldMI->getOperand(OpNo).isUse() ? isModRef : isMod;
-    if (LiveOut) MRInfo = (ModRef)(MRInfo | isLiveOut);
   }
 
   // add new memory reference
@@ -133,12 +131,11 @@
 
 namespace {
   struct SimpleSpiller : public Spiller {
-    bool runOnMachineFunction(MachineFunction& mf, const VirtRegMap &VRM);
+    bool runOnMachineFunction(MachineFunction& mf, VirtRegMap &VRM);
   };
 }
 
-bool SimpleSpiller::runOnMachineFunction(MachineFunction &MF,
-                                         const VirtRegMap &VRM) {
+bool SimpleSpiller::runOnMachineFunction(MachineFunction &MF, VirtRegMap &VRM) {
   DEBUG(std::cerr << "********** REWRITE MACHINE CODE **********\n");
   DEBUG(std::cerr << "********** Function: "
                   << MF.getFunction()->getName() << '\n');
@@ -211,7 +208,7 @@
     const MRegisterInfo *MRI;
     const TargetInstrInfo *TII;
   public:
-    bool runOnMachineFunction(MachineFunction &MF, const VirtRegMap &VRM) {
+    bool runOnMachineFunction(MachineFunction &MF, VirtRegMap &VRM) {
       MRI = MF.getTarget().getRegisterInfo();
       TII = MF.getTarget().getInstrInfo();
       DEBUG(std::cerr << "\n**** Local spiller rewriting function '"
@@ -223,7 +220,7 @@
       return true;
     }
   private:
-    void RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM);
+    void RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM);
     void ClobberPhysReg(unsigned PR, std::map<int, unsigned> &SpillSlots,
                         std::multimap<unsigned, int> &PhysRegs);
     void ClobberPhysRegOnly(unsigned PR, std::map<int, unsigned> &SpillSlots,
@@ -484,7 +481,7 @@
 
 /// rewriteMBB - Keep track of which spills are available even after the
 /// register allocator is done with them.  If possible, avoid reloading vregs.
-void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
+void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
 
   DEBUG(std::cerr << MBB.getBasicBlock()->getName() << ":\n");
 
@@ -729,14 +726,11 @@
           MaybeDeadStores.erase(MDSI);
         else {
           // If we get here, the store is dead, nuke it now.
-          assert(!(MR & VirtRegMap::isRef) && "Can't be modref!");
-          // Don't nuke it if the value is needed in another block.
-          if (!(MR & VirtRegMap::isLiveOut)) {
-            DEBUG(std::cerr << " Killed store:\t" << *MDSI->second);
-            MBB.erase(MDSI->second);
-            MaybeDeadStores.erase(MDSI);
-            ++NumDSE;
-          }
+          assert(VirtRegMap::isMod && "Can't be modref!");
+          DEBUG(std::cerr << "Removed dead store:\t" << *MDSI->second);
+          MBB.erase(MDSI->second);
+          MaybeDeadStores.erase(MDSI);
+          ++NumDSE;
         }
       }
 
@@ -837,7 +831,7 @@
         // If there is a dead store to this stack slot, nuke it now.
         MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
         if (LastStore) {
-          DEBUG(std::cerr << " Killed store:\t" << *LastStore);
+          DEBUG(std::cerr << "Removed dead store:\t" << *LastStore);
           ++NumDSE;
           MBB.erase(LastStore);
         }


Index: llvm/lib/CodeGen/VirtRegMap.h
diff -u llvm/lib/CodeGen/VirtRegMap.h:1.19 llvm/lib/CodeGen/VirtRegMap.h:1.20
--- llvm/lib/CodeGen/VirtRegMap.h:1.19	Sun Apr 30 03:41:47 2006
+++ llvm/lib/CodeGen/VirtRegMap.h	Mon May  1 16:16:03 2006
@@ -26,7 +26,7 @@
 
   class VirtRegMap {
   public:
-    enum ModRef { isRef = 1, isMod = 2, isModRef = 3, isLiveOut = 4 };
+    enum ModRef { isRef = 1, isMod = 2, isModRef = 3 };
     typedef std::multimap<MachineInstr*,
                           std::pair<unsigned, ModRef> > MI2VirtMapTy;
 
@@ -128,7 +128,7 @@
     /// folded into newMI machine instruction.  The OpNum argument indicates the
     /// operand number of OldMI that is folded.
     void virtFolded(unsigned VirtReg, MachineInstr *OldMI, unsigned OpNum,
-                    MachineInstr *NewMI, bool LiveOut);
+                    MachineInstr *NewMI);
 
     /// @brief returns the virtual registers' values folded in memory
     /// operands of this instruction
@@ -136,6 +136,13 @@
     getFoldedVirts(MachineInstr* MI) const {
       return MI2VirtMap.equal_range(MI);
     }
+    
+    /// RemoveFromFoldedVirtMap - Given a machine instruction in the folded
+    /// instruction map, remove the entry in the folded instruction map.
+    void RemoveFromFoldedVirtMap(MachineInstr *MI) {
+      bool ErasedAny = MI2VirtMap.erase(MI);
+      assert(ErasedAny && "Machine instr not in folded vreg map!");
+    }
 
     void print(std::ostream &OS) const;
     void dump() const;
@@ -151,7 +158,7 @@
   struct Spiller {
     virtual ~Spiller();
     virtual bool runOnMachineFunction(MachineFunction &MF,
-                                      const VirtRegMap &VRM) = 0;
+                                      VirtRegMap &VRM) = 0;
   };
 
   /// createSpiller - Create an return a spiller object, as specified on the






More information about the llvm-commits mailing list