Index: src/IceRegAlloc.cpp |
diff --git a/src/IceRegAlloc.cpp b/src/IceRegAlloc.cpp |
index fcfe13e40cd1a946342f577a8c4d6c4d8ae23f87..10a02a3ee381dfd44c8574a75e16b735f3c56cf3 100644 |
--- a/src/IceRegAlloc.cpp |
+++ b/src/IceRegAlloc.cpp |
@@ -345,7 +345,17 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { |
Next = I; |
++Next; |
LiveRangeWrapper Item = *I; |
- if (Item.Var->getRegNumTmp() == MinWeightIndex) { |
+ // Note: The Item.overlaps(Cur) clause is not part of the |
+ // description of AssignMemLoc() in the original paper. But |
+ // there doesn't seem to be any need to evict an inactive |
+ // live range that doesn't overlap with the live range |
+ // currently being considered. It's especially bad if we |
+ // would end up evicting an infinite-weight but |
+ // currently-inactive live range. The most common situation |
+ // for this would be a scratch register kill set for call |
+ // instructions. |
+ if (Item.Var->getRegNumTmp() == MinWeightIndex && |
+ Item.overlaps(Cur)) { |
if (Func->getContext()->isVerbose(IceV_LinearScan)) { |
Str << "Evicting "; |
Item.dump(Func); |