[llvm-commits] [llvm] r139603 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Sep 13 09:47:53 PDT 2011


Author: stoklund
Date: Tue Sep 13 11:47:53 2011
New Revision: 139603

URL: http://llvm.org/viewvc/llvm-project?rev=139603&view=rev
Log:
Use a separate LiveRangeCalc for the complement in spill modes.

The complement interval may overlap the other intervals created, so use
a separate LiveRangeCalc instance to compute its live range.

A LiveRangeCalc instance can only be shared among non-overlapping
intervals.

Modified:
    llvm/trunk/lib/CodeGen/SplitKit.cpp
    llvm/trunk/lib/CodeGen/SplitKit.h

Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=139603&r1=139602&r2=139603&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.cpp (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Sep 13 11:47:53 2011
@@ -319,7 +319,11 @@
   OpenIdx = 0;
   RegAssign.clear();
   Values.clear();
-  LRCalc.reset(&VRM.getMachineFunction());
+
+  // Reset the LiveRangeCalc instances needed for this spill mode.
+  LRCalc[0].reset(&VRM.getMachineFunction());
+  if (SpillMode)
+    LRCalc[1].reset(&VRM.getMachineFunction());
 
   // We don't need an AliasAnalysis since we will only be performing
   // cheap-as-a-copy remats anyway.
@@ -390,8 +394,8 @@
 // extendRange - Extend the live range to reach Idx.
 // Potentially create phi-def values.
 void SplitEditor::extendRange(unsigned RegIdx, SlotIndex Idx) {
-  LRCalc.extend(Edit->get(RegIdx), Idx.getNextSlot(),
-                LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
+  getLRCalc(RegIdx).extend(Edit->get(RegIdx), Idx.getNextSlot(),
+                         LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
 }
 
 VNInfo *SplitEditor::defFromParent(unsigned RegIdx,
@@ -633,6 +637,8 @@
         continue;
       }
 
+      LiveRangeCalc &LRC = getLRCalc(RegIdx);
+
       // This value has multiple defs in RegIdx, but it wasn't rematerialized,
       // so the live range is accurate. Add live-in blocks in [Start;End) to the
       // LiveInBlocks.
@@ -648,7 +654,7 @@
         DEBUG(dbgs() << ':' << VNI->id << "*BB#" << MBB->getNumber());
         // MBB has its own def. Is it also live-out?
         if (BlockEnd <= End)
-          LRCalc.setLiveOutValue(MBB, VNI);
+          LRC.setLiveOutValue(MBB, VNI);
 
         // Skip to the next block for live-in.
         ++MBB;
@@ -667,16 +673,16 @@
                                          std::min(BlockEnd, End).getPrevSlot());
           assert(VNI && "Missing def for complex mapped parent PHI");
           if (End >= BlockEnd)
-            LRCalc.setLiveOutValue(MBB, VNI); // Live-out as well.
+            LRC.setLiveOutValue(MBB, VNI); // Live-out as well.
         } else {
           // This block needs a live-in value.  The last block covered may not
           // be live-out.
           if (End < BlockEnd)
-            LRCalc.addLiveInBlock(LI, MDT[MBB], End);
+            LRC.addLiveInBlock(LI, MDT[MBB], End);
           else {
             // Live-through, and we don't know the value.
-            LRCalc.addLiveInBlock(LI, MDT[MBB]);
-            LRCalc.setLiveOutValue(MBB, 0);
+            LRC.addLiveInBlock(LI, MDT[MBB]);
+            LRC.setLiveOutValue(MBB, 0);
           }
         }
         BlockStart = BlockEnd;
@@ -687,7 +693,11 @@
     DEBUG(dbgs() << '\n');
   }
 
-  LRCalc.calculateValues(LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
+  LRCalc[0].calculateValues(LIS.getSlotIndexes(), &MDT,
+                            &LIS.getVNInfoAllocator());
+  if (SpillMode)
+    LRCalc[1].calculateValues(LIS.getSlotIndexes(), &MDT,
+                              &LIS.getVNInfoAllocator());
 
   return Skipped;
 }

Modified: llvm/trunk/lib/CodeGen/SplitKit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=139603&r1=139602&r2=139603&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.h (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Sep 13 11:47:53 2011
@@ -273,8 +273,17 @@
   ///    The new value has no live ranges anywhere.
   ValueMap Values;
 
-  /// LRCalc - Cache for computing live ranges and SSA update.
-  LiveRangeCalc LRCalc;
+  /// LRCalc - Cache for computing live ranges and SSA update.  Each instance
+  /// can only handle non-overlapping live ranges, so use a separate
+  /// LiveRangeCalc instance for the complement interval when in spill mode.
+  LiveRangeCalc LRCalc[2];
+
+  /// getLRCalc - Return the LRCalc to use for RegIdx.  In spill mode, the
+  /// complement interval can overlap the other intervals, so it gets its own
+  /// LRCalc instance.  When not in spill mode, all intervals can share one.
+  LiveRangeCalc &getLRCalc(unsigned RegIdx) {
+    return LRCalc[SpillMode != SM_Partition && RegIdx != 0];
+  }
 
   /// defValue - define a value in RegIdx from ParentVNI at Idx.
   /// Idx does not have to be ParentVNI->def, but it must be contained within





More information about the llvm-commits mailing list