Commit d806ca7b authored by Thibaud Michaud's avatar Thibaud Michaud Committed by V8 LUCI CQ

[regalloc] Do not resolve control-flow for deopt

Connecting moves can be inserted in the gap of the last instruction of a
block by the register allocator. The implicit assumption is that the
last instruction does not have any operand, so that the connecting move
does not invalidate any use of the destination operand.
Deoptimization breaks this assumption as it both terminates its block
and has operands. Omit the connecting move in this case to avoid
invalidating the deopt operands.

R=nicohartmann@chromium.org

Bug: v8:12218
Change-Id: Icce8e455949b19338ec7255dbb9b37963e857a6f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3211572Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77341}
parent 196a5275
......@@ -4829,7 +4829,8 @@ void LiveRangeConnector::ResolveControlFlow(Zone* local_zone) {
DCHECK_IMPLIES(
result.cur_cover_->TopLevel()->IsSpilledOnlyInDeferredBlocks(
data()) &&
!(pred_op.IsAnyRegister() && cur_op.IsAnyRegister()),
!(pred_op.IsAnyRegister() && cur_op.IsAnyRegister()) &&
move_loc != -1,
code()->GetInstructionBlock(move_loc)->IsDeferred());
}
iterator.Advance();
......@@ -4866,6 +4867,18 @@ int LiveRangeConnector::ResolveControlFlow(const InstructionBlock* block,
gap_index = block->first_instruction_index();
position = Instruction::START;
} else {
Instruction* last = code()->InstructionAt(pred->last_instruction_index());
// The connecting move might invalidate uses of the destination operand in
// the deoptimization call. See crbug.com/v8/12218. Omitting the move is
// safe since the deopt call exits the current code.
if (last->IsDeoptimizeCall()) {
return -1;
}
// In every other case the last instruction should not participate in
// register allocation, or it could interfere with the connecting move.
for (size_t i = 0; i < last->InputCount(); ++i) {
DCHECK(last->InputAt(i)->IsImmediate());
}
DCHECK_EQ(1, pred->SuccessorCount());
DCHECK(!code()
->InstructionAt(pred->last_instruction_index())
......
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