[maglev] Allow loop phis to extend input lifetimes

The comment about loop phis not needing to extend their inputs'
lifetimes to the end of the outer loop was... wrong. Of course the input
into a inner loop phi needs to be kept alive for subsequent iterations
of the outer loop.

Bug: v8:7700
Change-Id: I4e5de510a7f0188524dd3206f9369b473c128019
Fixed: chromium:1406733
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4165088
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85287}
This commit is contained in:
Leszek Swirski 2023-01-13 15:57:39 +01:00 committed by V8 LUCI CQ
parent 59e5982838
commit 71dea568ee

View File

@ -244,27 +244,25 @@ class UseMarkingProcessor {
BasicBlock* target = node->target();
uint32_t use = node->id();
if (target->has_phi()) {
// Phis are potential users of nodes outside this loop, but only on
// initial loop entry, not on actual looping, so we don't need to record
// their other inputs for lifetime extension.
for (Phi* phi : *target->phis()) {
ValueNode* input = phi->input(i).node();
input->mark_use(use, &phi->input(i));
}
}
DCHECK(!loop_used_nodes_.empty());
LoopUsedNodes loop_used_nodes = std::move(loop_used_nodes_.back());
loop_used_nodes_.pop_back();
LoopUsedNodes* outer_loop_used_nodes = GetCurrentLoopUsedNodes();
if (target->has_phi()) {
for (Phi* phi : *target->phis()) {
ValueNode* input = phi->input(i).node();
MarkUse(input, use, &phi->input(i), outer_loop_used_nodes);
}
}
DCHECK_EQ(loop_used_nodes.header, target);
if (!loop_used_nodes.used_nodes.empty()) {
// Uses of nodes in this loop may need to propagate to an outer loop, so
// that they're lifetime is extended there too.
// TODO(leszeks): We only need to extend the lifetime in one outermost
// loop, allow nodes to be "moved" between lifetime extensions.
LoopUsedNodes* outer_loop_used_nodes = GetCurrentLoopUsedNodes();
base::Vector<Input> used_node_inputs =
compilation_info_->zone()->NewVector<Input>(
loop_used_nodes.used_nodes.size());