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(
// cloberred after the call except for the argument registers, which are
// set before the call. Hence, the argument registers always get ignored,
// as their available time is shorter.
int reg;
if (current->FirstHintPosition(&reg) == nullptr) {
reg = codes[0];
int hint_reg = kUnassignedRegister;
int reg = codes[0];
if (current->FirstHintPosition(&hint_reg) != nullptr) {
reg = hint_reg;
}
for (int i = 0; i < num_codes; ++i) {
int code = codes[i];
......@@ -3191,7 +3192,7 @@ bool LinearScanAllocator::TryAllocateFreeReg(
int candidate_free = free_until_pos[code].ToInstructionIndex();
int current_free = free_until_pos[reg].ToInstructionIndex();
if (candidate_free > current_free ||
(candidate_free == current_free &&
(candidate_free == current_free && reg != hint_reg &&
!data()->HasFixedUse(current->representation(), 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