Index: src/compiler/ast-graph-builder.cc |
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
index 8d0a465bbc07af19878710502914f4c593ffb175..0b60bd03ffdc937f08d51ee5036da77b62c4e049 100644 |
--- a/src/compiler/ast-graph-builder.cc |
+++ b/src/compiler/ast-graph-builder.cc |
@@ -3660,6 +3660,14 @@ void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned, |
Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); |
UpdateEffectDependency(effect); |
+ // Connect the loop to end via Terminate if it's not marked as unreachable. |
+ if (!IsMarkedAsUnreachable()) { |
+ // Connect the Loop node to end via a Terminate node. |
+ Node* terminate = builder_->graph()->NewNode( |
+ builder_->common()->Terminate(), effect, control); |
+ builder_->exit_controls_.push_back(terminate); |
+ } |
+ |
if (builder_->info()->is_osr()) { |
// Introduce phis for all context values in the case of an OSR graph. |
for (int i = 0; i < static_cast<int>(contexts()->size()); ++i) { |