Reland "[turbofan] re-wire Unreachable to the graph end at EffectPhi's"

This is a reland of 2c0b1f6e9d

This fixes two bugs:
- Unreachable might have value uses even after being connected
to Throw, so the solution is to just not replace them with the Dead node
anymore.
- We didn't trigger initial visitation of the new Throw node.
  Re-visiting the changed End node takes care of this.


Original change's description:
> [turbofan] re-wire Unreachable to the graph end at EffectPhi's
>
> This avoids the EffectControlLinearizer stumbling upon unreachable
> code.
>
> Bug: chromium:958718
> Change-Id: I135c17813741e48e878a4624370eee1e06081031
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1605737
> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
> Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61434}

Bug: chromium:958718 chromium:962475 chromium:962474
Change-Id: I388a59912e6260a221cccc76102e0c4b00bff93e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1609791
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61482}
This commit is contained in:
Tobias Tebbi 2019-05-11 18:41:38 +02:00 committed by Commit Bot
parent c9a83486f3
commit 4329354ae8
2 changed files with 30 additions and 2 deletions

View File

@ -61,7 +61,7 @@ Reduction DeadCodeElimination::Reduce(Node* node) {
case IrOpcode::kPhi:
return ReducePhi(node);
case IrOpcode::kEffectPhi:
return PropagateDeadControl(node);
return ReduceEffectPhi(node);
case IrOpcode::kDeoptimize:
case IrOpcode::kReturn:
case IrOpcode::kTerminate:
@ -109,7 +109,6 @@ Reduction DeadCodeElimination::ReduceEnd(Node* node) {
return NoChange();
}
Reduction DeadCodeElimination::ReduceLoopOrMerge(Node* node) {
DCHECK(IrOpcode::IsMergeOpcode(node->opcode()));
Node::Inputs inputs = node->inputs();
@ -233,6 +232,34 @@ Reduction DeadCodeElimination::ReducePhi(Node* node) {
return NoChange();
}
Reduction DeadCodeElimination::ReduceEffectPhi(Node* node) {
DCHECK_EQ(IrOpcode::kEffectPhi, node->opcode());
Reduction reduction = PropagateDeadControl(node);
if (reduction.Changed()) return reduction;
Node* merge = NodeProperties::GetControlInput(node);
DCHECK(merge->opcode() == IrOpcode::kMerge ||
merge->opcode() == IrOpcode::kLoop);
int input_count = node->op()->EffectInputCount();
for (int i = 0; i < input_count; ++i) {
Node* effect = NodeProperties::GetEffectInput(node, i);
if (effect->opcode() == IrOpcode::kUnreachable) {
// If Unreachable hits an effect phi, we can re-connect the effect chain
// to the graph end and delete the corresponding inputs from the merge and
// phi nodes.
Node* control = NodeProperties::GetControlInput(merge, i);
Node* throw_node = graph_->NewNode(common_->Throw(), effect, control);
NodeProperties::MergeControlToEnd(graph_, common_, throw_node);
NodeProperties::ReplaceEffectInput(node, dead_, i);
NodeProperties::ReplaceControlInput(merge, dead_, i);
Revisit(merge);
Revisit(graph_->end());
reduction = Changed(node);
}
}
return reduction;
}
Reduction DeadCodeElimination::ReducePureNode(Node* node) {
DCHECK_EQ(0, node->op()->EffectInputCount());
if (node->opcode() == IrOpcode::kDeadValue) return NoChange();

View File

@ -53,6 +53,7 @@ class V8_EXPORT_PRIVATE DeadCodeElimination final
Reduction ReduceLoopExit(Node* node);
Reduction ReduceNode(Node* node);
Reduction ReducePhi(Node* node);
Reduction ReduceEffectPhi(Node* node);
Reduction ReducePureNode(Node* node);
Reduction ReduceUnreachableOrIfException(Node* node);
Reduction ReduceEffectNode(Node* node);