summaryrefslogtreecommitdiff
path: root/src/passes/Outlining.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Outlining.cpp')
-rw-r--r--src/passes/Outlining.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/passes/Outlining.cpp b/src/passes/Outlining.cpp
index f799d2c7a..51d000745 100644
--- a/src/passes/Outlining.cpp
+++ b/src/passes/Outlining.cpp
@@ -100,8 +100,20 @@ struct ReconstructStringifyWalker
existingBuilder.push(curr->iff->condition);
ASSERT_OK(existingBuilder.visitIfStart(curr->iff));
DBG(desc = "If Start for ");
+ } else if (reason.getElseStart()) {
+ ASSERT_OK(existingBuilder.visitElse());
+ DBG(desc = "Else Start at ");
} else if (reason.getEnd()) {
ASSERT_OK(existingBuilder.visitEnd());
+ // Outlining performs an unnested walk of the Wasm module, visiting
+ // each scope one at a time. IRBuilder, in contrast, expects to
+ // visit several nested scopes at a time. Thus, calling end() finalizes
+ // the control flow and places it on IRBuilder's internal stack, ready for
+ // the enclosing scope to consume its expressions off the stack. Since
+ // outlining walks unnested, the enclosing scope never arrives to retrieve
+ // its expressions off the stack, so we must call build() after visitEnd()
+ // to clear the internal stack IRBuilder manages.
+ ASSERT_OK(existingBuilder.build());
DBG(desc = "End for ");
} else {
DBG(desc = "addUniqueSymbol for unimplemented control flow ");