Stop precomputing last split points, query the SplitAnalysis cache on demand.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 5 Apr 2011 04:20:29 +0000 (04:20 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 5 Apr 2011 04:20:29 +0000 (04:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128875 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAllocGreedy.cpp
lib/CodeGen/SplitKit.cpp
lib/CodeGen/SplitKit.h

index 563c9bb0960c13a34f44f7f31c4694dc0a4e78a2..4814cba9aafab8885fd8f1164a28c7024c3af195 100644 (file)
@@ -445,7 +445,7 @@ float RAGreedy::calcSplitConstraints(unsigned PhysReg) {
 
     // Interference for the live-out value.
     if (BI.LiveOut) {
-      if (Intf.last() >= BI.LastSplitPoint)
+      if (Intf.last() >= SA->getLastSplitPoint(BC.Number))
         BC.Exit = SpillPlacement::MustSpill, Ins += BI.Uses;
       else if (!BI.Uses)
         BC.Exit = SpillPlacement::PrefSpill;
@@ -530,9 +530,9 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg, unsigned PhysReg,
     Intf.moveToBlock(BI.MBB->getNumber());
     DEBUG(dbgs() << "BB#" << BI.MBB->getNumber() << " -> EB#"
                  << Bundles->getBundle(BI.MBB->getNumber(), 1)
-                 << " [" << Start << ';' << BI.LastSplitPoint << '-'
-                 << Stop << ") intf [" << Intf.first() << ';' << Intf.last()
-                 << ')');
+                 << " [" << Start << ';'
+                 << SA->getLastSplitPoint(BI.MBB->getNumber()) << '-' << Stop
+                 << ") intf [" << Intf.first() << ';' << Intf.last() << ')');
 
     // The interference interval should either be invalid or overlap MBB.
     assert((!Intf.hasInterference() || Intf.first() < Stop)
@@ -588,6 +588,7 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg, unsigned PhysReg,
       continue;
     }
 
+    SlotIndex LastSplitPoint = SA->getLastSplitPoint(BI.MBB->getNumber());
     if (Intf.last().getBoundaryIndex() < BI.LastUse) {
       // There are interference-free uses at the end of the block.
       // Find the first use that can get the live-out register.
@@ -598,11 +599,11 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg, unsigned PhysReg,
       SlotIndex Use = *UI;
       assert(Use <= BI.LastUse && "Couldn't find last use");
       // Only attempt a split befroe the last split point.
-      if (Use.getBaseIndex() <= BI.LastSplitPoint) {
+      if (Use.getBaseIndex() <= LastSplitPoint) {
         DEBUG(dbgs() << ", free use at " << Use << ".\n");
         SlotIndex SegStart = SE->enterIntvBefore(Use);
         assert(SegStart >= Intf.last() && "Couldn't avoid interference");
-        assert(SegStart < BI.LastSplitPoint && "Impossible split point");
+        assert(SegStart < LastSplitPoint && "Impossible split point");
         SE->useIntv(SegStart, Stop);
         continue;
       }
@@ -630,7 +631,8 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg, unsigned PhysReg,
     Intf.moveToBlock(BI.MBB->getNumber());
     DEBUG(dbgs() << "EB#" << Bundles->getBundle(BI.MBB->getNumber(), 0)
                  << " -> BB#" << BI.MBB->getNumber() << " [" << Start << ';'
-                 << BI.LastSplitPoint << '-' << Stop << ')');
+                 << SA->getLastSplitPoint(BI.MBB->getNumber()) << '-' << Stop
+                 << ')');
 
     // Check interference entering the block.
     if (!Intf.hasInterference()) {
@@ -654,9 +656,10 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg, unsigned PhysReg,
         continue;
       }
       if (!RegOut) {
+        SlotIndex LastSplitPoint = SA->getLastSplitPoint(BI.MBB->getNumber());
         // Block is live-through, but exit bundle is on the stack.
         // Spill immediately after the last use.
-        if (BI.LastUse < BI.LastSplitPoint) {
+        if (BI.LastUse < LastSplitPoint) {
           DEBUG(dbgs() << ", uses, stack-out.\n");
           SE->useIntv(Start, SE->leaveIntvAfter(BI.LastUse));
           continue;
@@ -664,8 +667,8 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg, unsigned PhysReg,
         // The last use is after the last split point, it is probably an
         // indirect jump.
         DEBUG(dbgs() << ", uses at " << BI.LastUse << " after split point "
-                     << BI.LastSplitPoint << ", stack-out.\n");
-        SlotIndex SegEnd = SE->leaveIntvBefore(BI.LastSplitPoint);
+                     << LastSplitPoint << ", stack-out.\n");
+        SlotIndex SegEnd = SE->leaveIntvBefore(LastSplitPoint);
         SE->useIntv(Start, SegEnd);
         // Run a double interval from the split to the last use.
         // This makes it possible to spill the complement without affecting the
index 3974cb3ef67db51ad940114b8a5012fbd2edebc8..0b59a28c06179d2104328da5df2b9177a8c35871 100644 (file)
@@ -151,12 +151,6 @@ bool SplitAnalysis::calcLiveBlockInfo() {
     SlotIndex Start, Stop;
     tie(Start, Stop) = LIS.getSlotIndexes()->getMBBRange(BI.MBB);
 
-    // The last split point is the latest possible insertion point that dominates
-    // all successor blocks. If interference reaches LastSplitPoint, it is not
-    // possible to insert a split or reload that makes CurLI live in the
-    // outgoing bundle.
-    BI.LastSplitPoint = getLastSplitPoint(BI.MBB->getNumber());
-
     // LVI is the first live segment overlapping MBB.
     BI.LiveIn = LVI->start <= Start;
     if (!BI.LiveIn)
@@ -947,13 +941,14 @@ void SplitEditor::splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks) {
       continue;
 
     openIntv();
+    SlotIndex LastSplitPoint = SA.getLastSplitPoint(BI.MBB->getNumber());
     SlotIndex SegStart = enterIntvBefore(std::min(BI.FirstUse,
-                                                  BI.LastSplitPoint));
-    if (!BI.LiveOut || BI.LastUse < BI.LastSplitPoint) {
+                                                  LastSplitPoint));
+    if (!BI.LiveOut || BI.LastUse < LastSplitPoint) {
       useIntv(SegStart, leaveIntvAfter(BI.LastUse));
     } else {
       // The last use is after the last valid split point.
-      SlotIndex SegStop = leaveIntvBefore(BI.LastSplitPoint);
+      SlotIndex SegStop = leaveIntvBefore(LastSplitPoint);
       useIntv(SegStart, SegStop);
       overlapIntv(SegStop, BI.LastUse);
     }
index bf936321d325c7165b31f58a066771224c7203b2..50f8dcfbd1ebf990528b38623933b50acad8c3b7 100644 (file)
@@ -77,8 +77,6 @@ public:
     SlotIndex LastUse;    ///< Last instr using current reg.
     SlotIndex Kill;       ///< Interval end point inside block.
     SlotIndex Def;        ///< Interval start point inside block.
-    /// Last possible point for splitting live ranges.
-    SlotIndex LastSplitPoint;
     bool Uses;            ///< Current reg has uses or defs in block.
     bool LiveThrough;     ///< Live in whole block (Templ 5. or 6. above).
     bool LiveIn;          ///< Current reg is live in.