summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-01-19 10:34:37 -0800
committerGitHub <noreply@github.com>2017-01-19 10:34:37 -0800
commit00f432220444234e6ddca827f82cabcb6a2ef92a (patch)
tree341b4321c1f12545bf2198a10dee2cfa525355b4
parent665de854468175e9254ed7218fe7dd65bc5bc55e (diff)
downloadbinaryen-00f432220444234e6ddca827f82cabcb6a2ef92a.tar.gz
binaryen-00f432220444234e6ddca827f82cabcb6a2ef92a.tar.bz2
binaryen-00f432220444234e6ddca827f82cabcb6a2ef92a.zip
DCE even in -O0 (#884)
-rw-r--r--src/asm2wasm.h4
-rw-r--r--test/emcc_hello_world.fromasm.imprecise.no-opts21
-rw-r--r--test/emcc_hello_world.fromasm.no-opts21
-rw-r--r--test/two_sides.fromasm.imprecise.no-opts3
-rw-r--r--test/two_sides.fromasm.no-opts3
-rw-r--r--test/unit.fromasm.imprecise.no-opts6
-rw-r--r--test/unit.fromasm.no-opts6
-rw-r--r--test/wasm-only.fromasm.imprecise.no-opts5
-rw-r--r--test/wasm-only.fromasm.no-opts5
9 files changed, 5 insertions, 69 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index d8a2053be..77be6aad2 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -1029,8 +1029,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
passRunner.add("remove-unused-brs");
passRunner.add("optimize-instructions");
passRunner.add("post-emscripten");
- passRunner.add("dce"); // make sure to not emit unreachable code
}
+ // make sure to not emit unreachable code at all, even in -O0, as wasm rules for it are complex
+ // and changing.
+ passRunner.add("dce");
passRunner.run();
// apply memory growth, if relevant
diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts
index 9488b62c2..b4dcbcaa3 100644
--- a/test/emcc_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_hello_world.fromasm.imprecise.no-opts
@@ -5982,7 +5982,6 @@
(i32.const 9)
)
(br $label$break$L9)
- (br $switch)
)
)
(block
@@ -5993,7 +5992,6 @@
(get_local $$incdec$ptr169274)
)
(br $label$break$L9)
- (br $switch)
)
)
(nop)
@@ -7881,7 +7879,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -7907,7 +7904,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -7967,7 +7963,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -7999,7 +7994,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8031,7 +8025,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8057,7 +8050,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8117,7 +8109,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8136,7 +8127,6 @@
(br $label$continue$L1)
)
)
- (br $switch17)
)
)
(block
@@ -13145,7 +13135,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch17)
)
)
(block
@@ -14766,7 +14755,6 @@
(get_local $$6)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -14883,7 +14871,6 @@
(get_local $$15)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -14985,7 +14972,6 @@
(i32.const 0)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15107,7 +15093,6 @@
(get_local $$42)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15239,7 +15224,6 @@
(get_local $$56)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15347,7 +15331,6 @@
(i32.const 0)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15479,7 +15462,6 @@
(get_local $$81)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15587,7 +15569,6 @@
(i32.const 0)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15670,7 +15651,6 @@
(get_local $$103)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15753,7 +15733,6 @@
(get_local $$110)
)
(br $label$break$L1)
- (br $switch)
)
)
(br $label$break$L1)
diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts
index e12ecdb96..10cae59e8 100644
--- a/test/emcc_hello_world.fromasm.no-opts
+++ b/test/emcc_hello_world.fromasm.no-opts
@@ -5988,7 +5988,6 @@
(i32.const 9)
)
(br $label$break$L9)
- (br $switch)
)
)
(block
@@ -5999,7 +5998,6 @@
(get_local $$incdec$ptr169274)
)
(br $label$break$L9)
- (br $switch)
)
)
(nop)
@@ -7887,7 +7885,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -7913,7 +7910,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -7973,7 +7969,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8005,7 +8000,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8037,7 +8031,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8063,7 +8056,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8123,7 +8115,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch18)
)
)
(block
@@ -8142,7 +8133,6 @@
(br $label$continue$L1)
)
)
- (br $switch17)
)
)
(block
@@ -13151,7 +13141,6 @@
(get_local $$l10n$3)
)
(br $label$continue$L1)
- (br $switch17)
)
)
(block
@@ -14772,7 +14761,6 @@
(get_local $$6)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -14889,7 +14877,6 @@
(get_local $$15)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -14991,7 +14978,6 @@
(i32.const 0)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15113,7 +15099,6 @@
(get_local $$42)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15245,7 +15230,6 @@
(get_local $$56)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15353,7 +15337,6 @@
(i32.const 0)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15485,7 +15468,6 @@
(get_local $$81)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15593,7 +15575,6 @@
(i32.const 0)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15676,7 +15657,6 @@
(get_local $$103)
)
(br $label$break$L1)
- (br $switch)
)
)
(block
@@ -15759,7 +15739,6 @@
(get_local $$110)
)
(br $label$break$L1)
- (br $switch)
)
)
(br $label$break$L1)
diff --git a/test/two_sides.fromasm.imprecise.no-opts b/test/two_sides.fromasm.imprecise.no-opts
index 2abda5dca..94bca7245 100644
--- a/test/two_sides.fromasm.imprecise.no-opts
+++ b/test/two_sides.fromasm.imprecise.no-opts
@@ -79,8 +79,5 @@
)
)
)
- (return
- (i32.const 0)
- )
)
)
diff --git a/test/two_sides.fromasm.no-opts b/test/two_sides.fromasm.no-opts
index f49fc79b3..0976e4c90 100644
--- a/test/two_sides.fromasm.no-opts
+++ b/test/two_sides.fromasm.no-opts
@@ -81,8 +81,5 @@
)
)
)
- (return
- (i32.const 0)
- )
)
)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index 0dbdd7b50..eafbb32f7 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -301,7 +301,6 @@
(loop $while-in
(block $while-out
(br $while-out)
- (br $while-in)
)
)
(br $label$break$Lout)
@@ -311,10 +310,8 @@
(loop $while-in8
(block $while-out7
(br $label$break$Lout)
- (br $while-in8)
)
)
- (br $label$break$Lout)
)
)
(loop $label$continue$L1
@@ -335,7 +332,6 @@
)
(block
(br $label$break$L1)
- (br $switch10)
)
)
(block
@@ -347,7 +343,6 @@
)
(block
(br $label$break$L3)
- (br $switch10)
)
)
(br $label$break$L1)
@@ -1736,7 +1731,6 @@
(i32.const 14)
)
(br $while-out)
- (br $while-in)
)
)
(if
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index af5daebe0..29fede80c 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -307,7 +307,6 @@
(loop $while-in
(block $while-out
(br $while-out)
- (br $while-in)
)
)
(br $label$break$Lout)
@@ -317,10 +316,8 @@
(loop $while-in8
(block $while-out7
(br $label$break$Lout)
- (br $while-in8)
)
)
- (br $label$break$Lout)
)
)
(loop $label$continue$L1
@@ -341,7 +338,6 @@
)
(block
(br $label$break$L1)
- (br $switch10)
)
)
(block
@@ -353,7 +349,6 @@
)
(block
(br $label$break$L3)
- (br $switch10)
)
)
(br $label$break$L1)
@@ -1742,7 +1737,6 @@
(i32.const 14)
)
(br $while-out)
- (br $while-in)
)
)
(if
diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts
index 4db467f47..4e05d6bd3 100644
--- a/test/wasm-only.fromasm.imprecise.no-opts
+++ b/test/wasm-only.fromasm.imprecise.no-opts
@@ -732,10 +732,7 @@
(block
(if
(get_local $$2)
- (block
- (br $label$break$L1)
- (return)
- )
+ (br $label$break$L1)
)
(i32.store
(get_local $$0)
diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts
index e71e6b2b2..eae9c4597 100644
--- a/test/wasm-only.fromasm.no-opts
+++ b/test/wasm-only.fromasm.no-opts
@@ -780,10 +780,7 @@
(block
(if
(get_local $$2)
- (block
- (br $label$break$L1)
- (return)
- )
+ (br $label$break$L1)
)
(i32.store
(get_local $$0)