Commit 5f138ac1 authored by Stephan Herhut's avatar Stephan Herhut Committed by Commit Bot

[regalloc] Fix register hints being ignored

When adding the new heuristic to allocate registers that do not
take part in hinting first, I managed to break hinting for most
cases. This change makes hinting operational again.

Bug: chromium:920106
Change-Id: I0f460a66196087266dcb70a7a0e5569124bdd2ff
Reviewed-on: https://chromium-review.googlesource.com/c/1402791Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58669}
parent 25dde52d
...@@ -3181,9 +3181,10 @@ bool LinearScanAllocator::TryAllocateFreeReg( ...@@ -3181,9 +3181,10 @@ bool LinearScanAllocator::TryAllocateFreeReg(
// cloberred after the call except for the argument registers, which are // cloberred after the call except for the argument registers, which are
// set before the call. Hence, the argument registers always get ignored, // set before the call. Hence, the argument registers always get ignored,
// as their available time is shorter. // as their available time is shorter.
int reg; int hint_reg = kUnassignedRegister;
if (current->FirstHintPosition(&reg) == nullptr) { int reg = codes[0];
reg = codes[0]; if (current->FirstHintPosition(&hint_reg) != nullptr) {
reg = hint_reg;
} }
for (int i = 0; i < num_codes; ++i) { for (int i = 0; i < num_codes; ++i) {
int code = codes[i]; int code = codes[i];
...@@ -3191,7 +3192,7 @@ bool LinearScanAllocator::TryAllocateFreeReg( ...@@ -3191,7 +3192,7 @@ bool LinearScanAllocator::TryAllocateFreeReg(
int candidate_free = free_until_pos[code].ToInstructionIndex(); int candidate_free = free_until_pos[code].ToInstructionIndex();
int current_free = free_until_pos[reg].ToInstructionIndex(); int current_free = free_until_pos[reg].ToInstructionIndex();
if (candidate_free > current_free || if (candidate_free > current_free ||
(candidate_free == current_free && (candidate_free == current_free && reg != hint_reg &&
!data()->HasFixedUse(current->representation(), code))) { !data()->HasFixedUse(current->representation(), code))) {
reg = code; reg = code;
} }
......
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