summaryrefslogtreecommitdiff
path: root/src/passes/stringify-walker.h
diff options
context:
space:
mode:
authorAshley Nelson <nashley@google.com>2023-12-06 22:25:53 -0800
committerGitHub <noreply@github.com>2023-12-06 22:25:53 -0800
commitb8cf38693103127913a12240cbbcabe8ff47c719 (patch)
treef95493abaeddfbd95bcc3e80edde1a367e556174 /src/passes/stringify-walker.h
parent89ad929e11b43c0224d32fd6cffb0eb851586f88 (diff)
downloadbinaryen-b8cf38693103127913a12240cbbcabe8ff47c719.tar.gz
binaryen-b8cf38693103127913a12240cbbcabe8ff47c719.tar.bz2
binaryen-b8cf38693103127913a12240cbbcabe8ff47c719.zip
[Outlining] Fix outlining control flow
Changes the controlFlowQueue used in stringify-walker to push values of Expression*, This ensures that we walk the Wasm module in the same order, regardless of whether the control flow expression is outlined. Reviewers: tlively Reviewed By: tlively Pull Request: https://github.com/WebAssembly/binaryen/pull/6139
Diffstat (limited to 'src/passes/stringify-walker.h')
-rw-r--r--src/passes/stringify-walker.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/passes/stringify-walker.h b/src/passes/stringify-walker.h
index eb4a4482b..6f50f58d4 100644
--- a/src/passes/stringify-walker.h
+++ b/src/passes/stringify-walker.h
@@ -82,9 +82,7 @@ struct StringifyWalker
If* iff;
};
- struct ElseStart {
- If* iff;
- };
+ struct ElseStart {};
struct LoopStart {
Loop* loop;
@@ -119,8 +117,8 @@ struct StringifyWalker
static SeparatorReason makeIfStart(If* iff) {
return SeparatorReason(IfStart{iff});
}
- static SeparatorReason makeElseStart(If* iff) {
- return SeparatorReason(ElseStart{iff});
+ static SeparatorReason makeElseStart() {
+ return SeparatorReason(ElseStart{});
}
static SeparatorReason makeLoopStart(Loop* loop) {
return SeparatorReason(LoopStart{loop});
@@ -170,7 +168,11 @@ struct StringifyWalker
return o << "~~~Undefined in operator<< overload~~~";
}
- std::queue<Expression**> controlFlowQueue;
+ // To ensure control flow children are walked consistently during outlining,
+ // we push a copy of the control flow expression. This avoids an issue where
+ // control flow no longer points to the same expression after being
+ // outlined into a new function.
+ std::queue<Expression*> controlFlowQueue;
/*
* To initiate the walk, subclasses should call walkModule with a pointer to