Index: src/compiler/greedy-allocator.cc |
diff --git a/src/compiler/greedy-allocator.cc b/src/compiler/greedy-allocator.cc |
index d6f48a2716e2be223b05c46c526dcbc4ca5a7a79..4eb6f16da950b85579a01173c01e1eb5900dc39c 100644 |
--- a/src/compiler/greedy-allocator.cc |
+++ b/src/compiler/greedy-allocator.cc |
@@ -476,9 +476,25 @@ LifetimePosition GreedyAllocator::FindSplitPositionAfterCall( |
} |
+LifetimePosition GreedyAllocator::FindSplitPositionBeforeLoops( |
+ LiveRange* range) { |
+ LifetimePosition end = range->End(); |
+ if (end.ToInstructionIndex() >= code()->LastInstructionIndex()) { |
+ end = |
+ LifetimePosition::GapFromInstructionIndex(end.ToInstructionIndex() - 1); |
+ } |
+ LifetimePosition pos = FindOptimalSplitPos(range->Start(), end); |
+ pos = GetSplitPositionForInstruction(range, pos.ToInstructionIndex()); |
+ return pos; |
+} |
+ |
+ |
void GreedyAllocator::SplitOrSpillBlockedRange(LiveRange* range) { |
if (TrySplitAroundCalls(range)) return; |
- auto pos = GetLastResortSplitPosition(range, code()); |
+ |
+ LifetimePosition pos = FindSplitPositionBeforeLoops(range); |
+ |
+ if (!pos.IsValid()) pos = GetLastResortSplitPosition(range, code()); |
if (pos.IsValid()) { |
LiveRange* tail = Split(range, data(), pos); |
DCHECK(tail != range); |