diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-01-12 12:24:55 -0800 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-01-12 12:24:55 -0800 |
commit | 7e933f4e5a8870e7dfa282c86cfd9b6c49118d0a (patch) | |
tree | 081b8204cd6d3333ba06c8233d382981381c59af | |
parent | 9ccea0e0f97538c8c2349144e83c20bbc6c8c413 (diff) | |
download | binaryen-7e933f4e5a8870e7dfa282c86cfd9b6c49118d0a.tar.gz binaryen-7e933f4e5a8870e7dfa282c86cfd9b6c49118d0a.tar.bz2 binaryen-7e933f4e5a8870e7dfa282c86cfd9b6c49118d0a.zip |
add a test showing unreachable code after a return
-rw-r--r-- | test/wasm-only.asm.js | 23 | ||||
-rw-r--r-- | test/wasm-only.fromasm | 30 | ||||
-rw-r--r-- | test/wasm-only.fromasm.imprecise | 30 | ||||
-rw-r--r-- | test/wasm-only.fromasm.imprecise.no-opts | 41 | ||||
-rw-r--r-- | test/wasm-only.fromasm.no-opts | 41 |
5 files changed, 165 insertions, 0 deletions
diff --git a/test/wasm-only.asm.js b/test/wasm-only.asm.js index cf0119cd7..3adacf5be 100644 --- a/test/wasm-only.asm.js +++ b/test/wasm-only.asm.js @@ -226,6 +226,28 @@ function asm(global, env, buffer) { } return $waka | 0; } + function unreachable_leftovers($0,$1,$2) { + $0 = $0|0; + $1 = $1|0; + $2 = $2|0; + var label = 0; + L1: do { + if ($1) { + label = 10; + } else { + if ($2) { + break L1; + return; + } + store4($0,-2); + return; + } + } while(0); + if ((label|0) == 10) { + store4($0,-1); + } + return; + } function keepAlive() { loads(); stores(); @@ -238,6 +260,7 @@ function asm(global, env, buffer) { i64(ifValue64(i64(0), i64(0))); ifValue32(0, 0) | 0; switch64(i64(0)) | 0; + unreachable_leftovers(0, 0, 0); } function __emscripten_dceable_type_decls() { // dce-able, but this defines the type of fabsf which has no other use diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm index 86c9cfad9..a8d125d23 100644 --- a/test/wasm-only.fromasm +++ b/test/wasm-only.fromasm @@ -343,6 +343,31 @@ (i32.const 1) ) ) + (func $unreachable_leftovers (param $0 i32) (param $1 i32) (param $2 i32) + (block $__rjto$0 + (if + (i32.eqz + (get_local $1) + ) + (block + (nop) + (br_if $__rjto$0 + (get_local $2) + ) + (i32.store + (get_local $0) + (i32.const -2) + ) + (return) + (br $__rjto$0) + ) + ) + (i32.store + (get_local $0) + (i32.const -1) + ) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -383,6 +408,11 @@ (i64.const 0) ) ) + (call $unreachable_leftovers + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) ) (func $legalstub$illegalParam (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64) (call $illegalParam diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise index 227ab430d..0edb3e6c1 100644 --- a/test/wasm-only.fromasm.imprecise +++ b/test/wasm-only.fromasm.imprecise @@ -271,6 +271,31 @@ (i32.const 1) ) ) + (func $unreachable_leftovers (param $0 i32) (param $1 i32) (param $2 i32) + (block $__rjto$0 + (if + (i32.eqz + (get_local $1) + ) + (block + (nop) + (br_if $__rjto$0 + (get_local $2) + ) + (i32.store + (get_local $0) + (i32.const -2) + ) + (return) + (br $__rjto$0) + ) + ) + (i32.store + (get_local $0) + (i32.const -1) + ) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -311,6 +336,11 @@ (i64.const 0) ) ) + (call $unreachable_leftovers + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) ) (func $legalstub$illegalParam (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64) (call $illegalParam diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts index 2f891e715..4b079e33e 100644 --- a/test/wasm-only.fromasm.imprecise.no-opts +++ b/test/wasm-only.fromasm.imprecise.no-opts @@ -721,6 +721,42 @@ (get_local $$waka) ) ) + (func $unreachable_leftovers (param $$0 i32) (param $$1 i32) (param $$2 i32) + (local $label i32) + (block $label$break$L1 + (if + (get_local $$1) + (set_local $label + (i32.const 10) + ) + (block + (if + (get_local $$2) + (block + (br $label$break$L1) + (return) + ) + ) + (i32.store + (get_local $$0) + (i32.const -2) + ) + (return) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 10) + ) + (i32.store + (get_local $$0) + (i32.const -1) + ) + ) + (return) + ) (func $keepAlive (call $loads) (call $stores) @@ -761,6 +797,11 @@ (i64.const 0) ) ) + (call $unreachable_leftovers + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) ) (func $__emscripten_dceable_type_decls (drop diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts index e8e2785d5..b1f72e6dc 100644 --- a/test/wasm-only.fromasm.no-opts +++ b/test/wasm-only.fromasm.no-opts @@ -769,6 +769,42 @@ (get_local $$waka) ) ) + (func $unreachable_leftovers (param $$0 i32) (param $$1 i32) (param $$2 i32) + (local $label i32) + (block $label$break$L1 + (if + (get_local $$1) + (set_local $label + (i32.const 10) + ) + (block + (if + (get_local $$2) + (block + (br $label$break$L1) + (return) + ) + ) + (i32.store + (get_local $$0) + (i32.const -2) + ) + (return) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 10) + ) + (i32.store + (get_local $$0) + (i32.const -1) + ) + ) + (return) + ) (func $keepAlive (call $loads) (call $stores) @@ -809,6 +845,11 @@ (i64.const 0) ) ) + (call $unreachable_leftovers + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) ) (func $__emscripten_dceable_type_decls (drop |