diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-23 18:12:44 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-24 09:10:13 -0700 |
commit | c2dfbb512297e0d008de6ffad4a97799e68b3ed1 (patch) | |
tree | eeee4ee7128477c2c7810c8357eb22fd94e72998 | |
parent | 759bafb906ba3addc5ab470ca41455ef452f30ab (diff) | |
download | binaryen-c2dfbb512297e0d008de6ffad4a97799e68b3ed1.tar.gz binaryen-c2dfbb512297e0d008de6ffad4a97799e68b3ed1.tar.bz2 binaryen-c2dfbb512297e0d008de6ffad4a97799e68b3ed1.zip |
vacuum dead code after br_table
-rw-r--r-- | src/passes/Vacuum.cpp | 3 | ||||
-rw-r--r-- | test/passes/vacuum.txt | 5 | ||||
-rw-r--r-- | test/passes/vacuum.wast | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index ed868f2f9..12565f603 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -43,7 +43,8 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum, Visitor<Vacuum>>> { } // if this is an unconditional br, the rest is dead code Break* br = list[z - skip]->dynCast<Break>(); - if (br && !br->condition) { + Switch* sw = list[z - skip]->dynCast<Switch>(); + if ((br && !br->condition) || sw) { list.resize(z - skip + 1); needResize = false; break; diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index a6c7f22f0..103dbc6bc 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -11,5 +11,10 @@ (block $waka2 (br $waka2) ) + (block $waka3 + (br_table $waka3 $waka3 $waka3 + (i32.const 57) + ) + ) ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index dda86804e..a0c638eb8 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -17,6 +17,12 @@ (br $waka2) (i32.const 56) ) + (block $waka3 + (br_table $waka3 $waka3 $waka3 + (i32.const 57) + ) + (i32.const 58) + ) ) ) |