[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:
parent
2b93b8aa41
commit
b53c35a797
@ -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);
|
||||
}
|
||||
|
15
test/mjsunit/compiler/regress-491578.js
Normal file
15
test/mjsunit/compiler/regress-491578.js
Normal 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();
|
Loading…
Reference in New Issue
Block a user