Make some changes suggested by Bill and Evan.
authorDavid Greene <greened@obbligato.org>
Wed, 22 Jul 2009 20:08:25 +0000 (20:08 +0000)
committerDavid Greene <greened@obbligato.org>
Wed, 22 Jul 2009 20:08:25 +0000 (20:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76775 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveInterval.h
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/SimpleRegisterCoalescing.cpp

index 52e43d3428978634d9eee91279b40e70b8064013..6910f418767524ef01d4f767f55d98914477c8ac 100644 (file)
@@ -572,6 +572,10 @@ namespace llvm {
     ///
     unsigned getSize() const;
 
+    /// ComputeJoinedWeight - Set the weight of a live interval after
+    /// Other has been merged into it.
+    void ComputeJoinedWeight(const LiveInterval &Other);
+
     bool operator<(const LiveInterval& other) const {
       return beginNumber() < other.beginNumber();
     }
index 0d2f6ba76a7c5894687f815c6a04bea6207639bf..0428105551064541dd6eea7da9436ef9d9fa92af 100644 (file)
@@ -503,23 +503,7 @@ void LiveInterval::join(LiveInterval &Other, const int *LHSValNoAssignments,
     InsertPos = addRangeFrom(*I, InsertPos);
   }
 
-  // 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
+  ComputeJoinedWeight(Other);
 
   // Update regalloc hint if currently there isn't one.
   if (TargetRegisterInfo::isVirtualRegister(reg) &&
@@ -809,6 +793,29 @@ unsigned LiveInterval::getSize() const {
   return Sum;
 }
 
+/// ComputeJoinedWeight - Set the weight of a live interval Joined
+/// after Other has been merged into it.
+void LiveInterval::ComputeJoinedWeight(const LiveInterval &Other) {
+  // 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 {
+    // Otherwise the weight stays the same
+    // Remove this assert if you have an iterative coalescer
+    assert(0 && "Joining from spilled interval");
+  }
+}
+
 std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) {
   return os << '[' << LR.start << ',' << LR.end << ':' << LR.valno->id << ")";
 }
index f5d85ab45441ce7d17e3728702e13be2914a16b9..49f7d9a45f893bb795ba2dd2efb7185a407e2908 100644 (file)
@@ -1970,23 +1970,7 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){
   LHS.addKills(LHSValNo, VNI->kills);
   LHS.MergeRangesInAsValue(RHS, LHSValNo);
 
-  // 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
+  LHS.ComputeJoinedWeight(RHS);
 
   // Update regalloc hint if both are virtual registers.
   if (TargetRegisterInfo::isVirtualRegister(LHS.reg) &&