summaryrefslogtreecommitdiff
path: root/src/passes/Flatten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/Flatten.cpp')
-rw-r--r--src/passes/Flatten.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp
index 00130838e..53fd6a02b 100644
--- a/src/passes/Flatten.cpp
+++ b/src/passes/Flatten.cpp
@@ -46,6 +46,8 @@
// anything else is written to a local earlier.
// 2. Disallow block, loop, and if return values, i.e., do not use
// control flow to pass around values.
+// 3. Disallow tee_local, setting a local is always done in a set_local
+// on a non-nested-expression location.
//
#include <wasm.h>
@@ -185,7 +187,19 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress
ourPreludes.swap(iter->second);
}
// special handling
- if (auto* br = curr->dynCast<Break>()) {
+ if (auto* set = curr->dynCast<SetLocal>()) {
+ if (set->isTee()) {
+ // we disallow tee_local
+ if (set->value->type == unreachable) {
+ replaceCurrent(set->value); // trivial, no set happens
+ } else {
+ // use a set in a prelude + a get
+ set->setTee(false);
+ ourPreludes.push_back(set);
+ replaceCurrent(builder.makeGetLocal(set->index, set->value->type));
+ }
+ }
+ } else if (auto* br = curr->dynCast<Break>()) {
if (br->value) {
auto type = br->value->type;
if (isConcreteWasmType(type)) {