Commit b53c35a7 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Properly kill Terminate nodes when removing loops.

BUG=chromium:491578
LOG=n
R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28621}
parent 2b93b8aa
......@@ -439,10 +439,16 @@ class ControlReducerImpl final : public AdvancedReducer {
if (live == 0) return dead(); // no remaining inputs.
// Gather phis and effect phis to be edited.
// Gather terminates, phis and effect phis to be edited.
NodeVector phis(zone_);
Node* terminate = nullptr;
for (Node* const use : node->uses()) {
if (NodeProperties::IsPhi(use)) phis.push_back(use);
if (NodeProperties::IsPhi(use)) {
phis.push_back(use);
} else if (use->opcode() == IrOpcode::kTerminate) {
DCHECK_NULL(terminate);
terminate = use;
}
}
if (live == 1) {
......@@ -450,6 +456,8 @@ class ControlReducerImpl final : public AdvancedReducer {
for (Node* const phi : phis) {
Replace(phi, phi->InputAt(live_index));
}
// The terminate is not needed anymore.
if (terminate) Replace(terminate, dead());
// The merge itself is redundant.
return node->InputAt(live_index);
}
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
function foo(x) {
if (x === undefined) return;
while (true) {
while (1 || 2) { }
f();
}
}
%OptimizeFunctionOnNextCall(foo);
foo();
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