Index: src/compiler/common-operator-reducer.cc |
diff --git a/src/compiler/common-operator-reducer.cc b/src/compiler/common-operator-reducer.cc |
index be4d802f818d06c140a4b2ac7b6b50679a3b7e99..acb7f26cf9dcdb7413193e5f900e8d235ee8d90c 100644 |
--- a/src/compiler/common-operator-reducer.cc |
+++ b/src/compiler/common-operator-reducer.cc |
@@ -303,8 +303,16 @@ Reduction CommonOperatorReducer::ReducePhi(Node* node) { |
Reduction CommonOperatorReducer::ReduceReturn(Node* node) { |
DCHECK_EQ(IrOpcode::kReturn, node->opcode()); |
Node* const value = node->InputAt(0); |
- Node* const effect = node->InputAt(1); |
- Node* const control = node->InputAt(2); |
+ Node* effect = NodeProperties::GetEffectInput(node); |
+ Node* const control = NodeProperties::GetControlInput(node); |
+ bool changed = false; |
+ if (effect->opcode() == IrOpcode::kCheckpoint) { |
+ // Any {Return} node can never be used to insert a deoptimization point, |
+ // hence checkpoints can be cut out of the effect chain flowing into it. |
+ effect = NodeProperties::GetEffectInput(effect); |
+ NodeProperties::ReplaceEffectInput(node, effect); |
+ changed = true; |
+ } |
if (value->opcode() == IrOpcode::kPhi && |
NodeProperties::GetControlInput(value) == control && |
effect->opcode() == IrOpcode::kEffectPhi && |
@@ -329,7 +337,7 @@ Reduction CommonOperatorReducer::ReduceReturn(Node* node) { |
Replace(control, dead()); |
return Replace(dead()); |
} |
- return NoChange(); |
+ return changed ? Changed(node) : NoChange(); |
} |