[llvm-branch-commits] [llvm-branch] r102656 - in /llvm/branches/Apple/Morbo: include/llvm/ADT/DenseMapInfo.h lib/CodeGen/VirtRegRewriter.cpp

Evan Cheng evan.cheng at apple.com
Thu Apr 29 11:59:36 PDT 2010


Author: evancheng
Date: Thu Apr 29 13:59:35 2010
New Revision: 102656

URL: http://llvm.org/viewvc/llvm-project?rev=102656&view=rev
Log:
Merge 102652 and 102654.

Modified:
    llvm/branches/Apple/Morbo/include/llvm/ADT/DenseMapInfo.h
    llvm/branches/Apple/Morbo/lib/CodeGen/VirtRegRewriter.cpp

Modified: llvm/branches/Apple/Morbo/include/llvm/ADT/DenseMapInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/ADT/DenseMapInfo.h?rev=102656&r1=102655&r2=102656&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/ADT/DenseMapInfo.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/ADT/DenseMapInfo.h Thu Apr 29 13:59:35 2010
@@ -92,6 +92,16 @@
   }
 };
 
+// Provide DenseMapInfo for ints.
+template<> struct DenseMapInfo<int> {
+  static inline int getEmptyKey() { return 0x7fffffff; }
+  static inline int getTombstoneKey() { return -0x7fffffff - 1; }
+  static unsigned getHashValue(const int& Val) { return (unsigned)(Val * 37); }
+  static bool isEqual(const int& LHS, const int& RHS) {
+    return LHS == RHS;
+  }
+};
+
 // Provide DenseMapInfo for long longs.
 template<> struct DenseMapInfo<long long> {
   static inline long long getEmptyKey() { return 0x7fffffffffffffffLL; }

Modified: llvm/branches/Apple/Morbo/lib/CodeGen/VirtRegRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/VirtRegRewriter.cpp?rev=102656&r1=102655&r2=102656&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/VirtRegRewriter.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/VirtRegRewriter.cpp Thu Apr 29 13:59:35 2010
@@ -1064,6 +1064,7 @@
   VirtRegMap *VRM;
   BitVector AllocatableRegs;
   DenseMap<MachineInstr*, unsigned> DistanceMap;
+  DenseMap<int, SmallVector<MachineInstr*,4> > Slot2DbgValues;
 
   MachineBasicBlock *MBB;       // Basic block currently being processed.
 
@@ -1188,12 +1189,24 @@
   // Mark unused spill slots.
   MachineFrameInfo *MFI = MF.getFrameInfo();
   int SS = VRM->getLowSpillSlot();
-  if (SS != VirtRegMap::NO_STACK_SLOT)
-    for (int e = VRM->getHighSpillSlot(); SS <= e; ++SS)
+  if (SS != VirtRegMap::NO_STACK_SLOT) {
+    for (int e = VRM->getHighSpillSlot(); SS <= e; ++SS) {
+      SmallVector<MachineInstr*, 4> &DbgValues = Slot2DbgValues[SS];
       if (!VRM->isSpillSlotUsed(SS)) {
         MFI->RemoveStackObject(SS);
+        for (unsigned j = 0, ee = DbgValues.size(); j != ee; ++j) {
+          MachineInstr *DVMI = DbgValues[j];
+          MachineBasicBlock *DVMBB = DVMI->getParent();
+          DEBUG(dbgs() << "Removing debug info referencing FI#" << SS << '\n');
+          VRM->RemoveMachineInstrFromMaps(DVMI);
+          DVMBB->erase(DVMI);
+        }
         ++NumDSS;
       }
+      DbgValues.clear();
+    }
+  }
+  Slot2DbgValues.clear();
 
   return true;
 }
@@ -1903,6 +1916,10 @@
     bool BackTracked = false;
     MachineInstr &MI = *MII;
 
+    // Remember DbgValue's which reference stack slots.
+    if (MI.isDebugValue() && MI.getOperand(0).isFI())
+      Slot2DbgValues[MI.getOperand(0).getIndex()].push_back(&MI);
+
     /// ReusedOperands - Keep track of operand reuse in case we need to undo
     /// reuse.
     ReuseInfo ReusedOperands(MI, TRI);





More information about the llvm-branch-commits mailing list