summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/CoalesceLocals.cpp4
-rw-r--r--test/passes/coalesce-locals.txt10
-rw-r--r--test/passes/coalesce-locals.wast12
3 files changed, 25 insertions, 1 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp
index b36542a97..87eefb85c 100644
--- a/src/passes/CoalesceLocals.cpp
+++ b/src/passes/CoalesceLocals.cpp
@@ -196,7 +196,9 @@ struct CoalesceLocals : public WalkerPass<CFGWalker<CoalesceLocals, Visitor<Coal
if (auto* get = set->value->dynCast<GetLocal>()) return get;
if (auto* iff = set->value->dynCast<If>()) {
if (auto* get = iff->ifTrue->dynCast<GetLocal>()) return get;
- if (auto* get = iff->ifFalse->dynCast<GetLocal>()) return get;
+ if (iff->ifFalse) {
+ if (auto* get = iff->ifFalse->dynCast<GetLocal>()) return get;
+ }
}
return nullptr;
}
diff --git a/test/passes/coalesce-locals.txt b/test/passes/coalesce-locals.txt
index f8dc3ef0f..ed6838ae8 100644
--- a/test/passes/coalesce-locals.txt
+++ b/test/passes/coalesce-locals.txt
@@ -1112,4 +1112,14 @@
)
(i32.const 1)
)
+ (func $unused-tee-with-child-if-no-else (type $4) (param $0 i32)
+ (loop $label$0
+ (drop
+ (if
+ (br $label$0)
+ (nop)
+ )
+ )
+ )
+ )
)
diff --git a/test/passes/coalesce-locals.wast b/test/passes/coalesce-locals.wast
index 336c75e0e..d959cc820 100644
--- a/test/passes/coalesce-locals.wast
+++ b/test/passes/coalesce-locals.wast
@@ -1085,4 +1085,16 @@
)
(i32.const 1)
)
+ (func $unused-tee-with-child-if-no-else (param $0 i32)
+ (loop $label$0
+ (drop
+ (tee_local $0
+ (if
+ (br $label$0)
+ (nop)
+ )
+ )
+ )
+ )
+ )
)