Commit b10e8506 authored by mtrofin's avatar mtrofin Committed by Commit bot

Revert "Revert of [turbofan] Remove redundant code. (patchset #1 id:1

 of https://codereview.chromium.org/1428943004/ )"

This reverts commit 5f4828a1.

Maintaining the behavior of processing both ranges with spill ranges,
as well as those with spill operands.

BUG=

Review URL: https://codereview.chromium.org/1406223010

Cr-Commit-Position: refs/heads/master@{#31924}
parent 0609ed27
......@@ -368,7 +368,7 @@ void GreedyAllocator::AllocateRegisters() {
TRACE("Begin allocating function %s with the Greedy Allocator\n",
data()->debug_name());
SplitAndSpillRangesDefinedByMemoryOperand();
SplitAndSpillRangesDefinedByMemoryOperand(true);
GroupLiveRanges();
ScheduleAllocationCandidates();
PreallocateFixedRanges();
......
......@@ -2228,12 +2228,15 @@ LifetimePosition RegisterAllocator::GetSplitPositionForInstruction(
}
void RegisterAllocator::SplitAndSpillRangesDefinedByMemoryOperand() {
void RegisterAllocator::SplitAndSpillRangesDefinedByMemoryOperand(
bool operands_only) {
size_t initial_range_count = data()->live_ranges().size();
for (size_t i = 0; i < initial_range_count; ++i) {
TopLevelLiveRange* range = data()->live_ranges()[i];
if (!CanProcessRange(range)) continue;
if (!range->HasSpillOperand()) continue;
if (range->HasNoSpillType() || (operands_only && range->HasSpillRange())) {
continue;
}
LifetimePosition start = range->Start();
TRACE("Live range %d:%d is defined by a spill operand.\n",
......@@ -2416,7 +2419,7 @@ void LinearScanAllocator::AllocateRegisters() {
DCHECK(active_live_ranges().empty());
DCHECK(inactive_live_ranges().empty());
SplitAndSpillRangesDefinedByMemoryOperand();
SplitAndSpillRangesDefinedByMemoryOperand(false);
for (TopLevelLiveRange* range : data()->live_ranges()) {
if (!CanProcessRange(range)) continue;
......@@ -2450,28 +2453,6 @@ void LinearScanAllocator::AllocateRegisters() {
TRACE("Processing interval %d:%d start=%d\n", current->TopLevel()->vreg(),
current->relative_id(), position.value());
if (current->IsTopLevel() && !current->TopLevel()->HasNoSpillType()) {
TRACE("Live range %d:%d already has a spill operand\n",
current->TopLevel()->vreg(), current->relative_id());
auto next_pos = position;
if (next_pos.IsGapPosition()) {
next_pos = next_pos.NextStart();
}
auto pos = current->NextUsePositionRegisterIsBeneficial(next_pos);
// If the range already has a spill operand and it doesn't need a
// register immediately, split it and spill the first part of the range.
if (pos == nullptr) {
Spill(current);
continue;
} else if (pos->pos() > current->Start().NextStart()) {
// Do not spill live range eagerly if use position that can benefit from
// the register is too close to the start of live range.
SpillBetween(current, current->Start(), pos->pos());
DCHECK(UnhandledIsSorted());
continue;
}
}
if (current->IsTopLevel() && TryReuseSpillForPhi(current->TopLevel()))
continue;
......
......@@ -922,7 +922,7 @@ class RegisterAllocator : public ZoneObject {
// Find the optimal split for ranges defined by a memory operand, e.g.
// constants or function parameters passed on the stack.
void SplitAndSpillRangesDefinedByMemoryOperand();
void SplitAndSpillRangesDefinedByMemoryOperand(bool operands_only);
// Split the given range at the given position.
// If range starts at or after the given position then the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment