summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-11 15:00:14 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-13 11:54:03 -0700
commit485166f4a184543fda936b8c458f0f4b74c0368f (patch)
tree547fd17d1207dd7191c8891c402b520cdc5dcc54
parentcf6c4cff644b87b4c9688931e2924e2d73b9998f (diff)
downloadbinaryen-485166f4a184543fda936b8c458f0f4b74c0368f.tar.gz
binaryen-485166f4a184543fda936b8c458f0f4b74c0368f.tar.bz2
binaryen-485166f4a184543fda936b8c458f0f4b74c0368f.zip
fix handling of an if in a tee without an else, in coalesce-locals
-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)
+ )
+ )
+ )
+ )
+ )
)