[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}
This commit is contained in:
bmeurer 2015-05-26 03:47:55 -07:00 committed by Commit bot
parent 2b93b8aa41
commit b53c35a797
2 changed files with 25 additions and 2 deletions

View File

@ -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);
}

View File

@ -0,0 +1,15 @@
// 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();