Add some support for iterative coalescers to calculate a joined live
authorDavid Greene <greened@obbligato.org>
Tue, 21 Jul 2009 23:36:14 +0000 (23:36 +0000)
committerDavid Greene <greened@obbligato.org>
Tue, 21 Jul 2009 23:36:14 +0000 (23:36 +0000)
range's weight properly.  This is turned off right now in the sense that
you'll get an assert if you get into a situation that can only be caused
by an iterative coalescer.  All other code paths operate exactly as
before so there is no functional change with this patch.  The asserts
should be disabled if/when an iterative coalescer gets added to trunk.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76680 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveInterval.cpp
lib/CodeGen/SimpleRegisterCoalescing.cpp

index b786b1d85b0fb0c1721a5e7a425ac5e00e2f6693..0d2f6ba76a7c5894687f815c6a04bea6207639bf 100644 (file)
@@ -503,7 +503,23 @@ void LiveInterval::join(LiveInterval &Other, const int *LHSValNoAssignments,
     InsertPos = addRangeFrom(*I, InsertPos);
   }
 
-  weight += Other.weight;
+  // If either of these intervals was spilled, the weight is the
+  // weight of the non-spilled interval.  This can only happen with
+  // iterative coalescers.
+
+  if (weight == HUGE_VALF && !TargetRegisterInfo::isPhysicalRegister(reg)) {
+    // Remove this assert if you have an iterative coalescer
+    assert(0 && "Joining to spilled interval");
+    weight = Other.weight;
+  }
+  else if (Other.weight != HUGE_VALF) {
+    weight += Other.weight;
+  }
+  else {
+    // Remove this assert if you have an iterative coalescer
+    assert(0 && "Joining from spilled interval");
+  }
+  // Otherwise the weight stays the same
 
   // Update regalloc hint if currently there isn't one.
   if (TargetRegisterInfo::isVirtualRegister(reg) &&
index 12001d08b042d6d6de5a6e92387b346ba99643a6..f5d85ab45441ce7d17e3728702e13be2914a16b9 100644 (file)
@@ -1969,7 +1969,24 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){
     LHSValNo->setHasPHIKill(true);
   LHS.addKills(LHSValNo, VNI->kills);
   LHS.MergeRangesInAsValue(RHS, LHSValNo);
-  LHS.weight += RHS.weight;
+
+  // If either of these intervals was spilled, the weight is the
+  // weight of the non-spilled interval.  This can only happen
+  // with iterative coalescers.
+  if (LHS.weight == HUGE_VALF && !TargetRegisterInfo::isPhysicalRegister(LHS.reg)) {
+    // Remove this assert if you have an iterative coalescer
+    assert(0 && "Joining to spilled interval");
+    LHS.weight = RHS.weight;
+  }
+  else if (RHS.weight != HUGE_VALF) {
+    LHS.weight += RHS.weight;
+  }
+  else {
+    // Remove this assert if you have an iterative coalescer
+    assert(0 && "Joining from spilled interval");
+  }
+
+  // Otherwise the LHS weight stays the same
 
   // Update regalloc hint if both are virtual registers.
   if (TargetRegisterInfo::isVirtualRegister(LHS.reg) &&