diff options
Diffstat (limited to 'test/passes')
20 files changed, 513 insertions, 184 deletions
diff --git a/test/passes/O.txt b/test/passes/O.txt index eac56294b..d560e326b 100644 --- a/test/passes/O.txt +++ b/test/passes/O.txt @@ -1,7 +1,9 @@ (module (type $0 (func (result i32))) + (type $1 (func (param i64))) (memory $0 0) (export "ret" (func $ret)) + (export "waka" (func $if-0-unreachable-to-none)) (func $ret (type $0) (result i32) (block $out i32 (drop @@ -16,4 +18,7 @@ (i32.const 999) ) ) + (func $if-0-unreachable-to-none (type $1) (param $0 i64) + (unreachable) + ) ) diff --git a/test/passes/O.wast b/test/passes/O.wast index 8477c5306..8029c7b5b 100644 --- a/test/passes/O.wast +++ b/test/passes/O.wast @@ -13,5 +13,16 @@ (unreachable) ) ) + (func $if-0-unreachable-to-none (export "waka") (param $var$0 i64) + (local $var$1 i64) + (local $var$2 i64) + (block $label$1 + (if + (i32.const 0) + (br $label$1) + (unreachable) + ) + ) + ) ) diff --git a/test/passes/coalesce-locals-learning.txt b/test/passes/coalesce-locals-learning.txt index 08cb9a004..3bd04680d 100644 --- a/test/passes/coalesce-locals-learning.txt +++ b/test/passes/coalesce-locals-learning.txt @@ -110,7 +110,7 @@ (br $block) (nop) (drop - (unreachable) + (i32.const 0) ) (nop) ) @@ -391,10 +391,10 @@ (block $block (br $block) (drop - (unreachable) + (i32.const 0) ) (drop - (unreachable) + (i32.const 0) ) ) ) @@ -403,10 +403,10 @@ (block $block (unreachable) (drop - (unreachable) + (i32.const 0) ) (drop - (unreachable) + (i32.const 0) ) ) ) @@ -415,10 +415,10 @@ (block $block (return) (drop - (unreachable) + (i32.const 0) ) (drop - (unreachable) + (i32.const 0) ) ) ) @@ -462,7 +462,7 @@ (i32.const 100) ) (drop - (unreachable) + (i32.const 0) ) ) (drop diff --git a/test/passes/coalesce-locals.txt b/test/passes/coalesce-locals.txt index e022d59f9..381c76653 100644 --- a/test/passes/coalesce-locals.txt +++ b/test/passes/coalesce-locals.txt @@ -114,7 +114,7 @@ (br $block) (nop) (drop - (unreachable) + (i32.const 0) ) (nop) ) @@ -393,10 +393,10 @@ (block $block (br $block) (drop - (unreachable) + (i32.const 0) ) (drop - (unreachable) + (i32.const 0) ) ) ) @@ -405,10 +405,10 @@ (block $block (unreachable) (drop - (unreachable) + (i32.const 0) ) (drop - (unreachable) + (i32.const 0) ) ) ) @@ -417,10 +417,10 @@ (block $block (return) (drop - (unreachable) + (i32.const 0) ) (drop - (unreachable) + (i32.const 0) ) ) ) @@ -464,7 +464,7 @@ (i32.const 100) ) (drop - (unreachable) + (i32.const 0) ) ) (drop @@ -904,7 +904,7 @@ (return) (nop) (drop - (unreachable) + (i32.const 0) ) (nop) ) @@ -912,7 +912,7 @@ (unreachable) (nop) (drop - (unreachable) + (i32.const 0) ) (nop) ) @@ -920,7 +920,7 @@ (br $z) (nop) (drop - (unreachable) + (i32.const 0) ) (nop) ) @@ -930,7 +930,7 @@ ) (nop) (drop - (unreachable) + (i32.const 0) ) (nop) ) @@ -940,8 +940,8 @@ (block $block (unreachable) (i32.store - (unreachable) - (unreachable) + (i32.const 0) + (i32.const 0) ) ) ) @@ -1028,7 +1028,7 @@ (loop $top (if (i32.const 1) - (set_local $0 + (tee_local $0 (unreachable) ) ) diff --git a/test/passes/dce.txt b/test/passes/dce.txt index 3ccdbdffd..62cee370f 100644 --- a/test/passes/dce.txt +++ b/test/passes/dce.txt @@ -47,21 +47,15 @@ ) (if (i32.const 0) - (drop - (unreachable) - ) + (unreachable) ) (if (i32.const 0) - (drop - (unreachable) - ) + (unreachable) ) (if (i32.const 0) - (drop - (unreachable) - ) + (unreachable) ) (block $out16 (block $in @@ -199,9 +193,7 @@ ) (if (i32.const 22) - (drop - (unreachable) - ) + (unreachable) ) (if (i32.const 33) @@ -222,25 +214,19 @@ ) (if (i32.const 66) - (drop - (unreachable) - ) + (unreachable) ) (if (i32.const 77) - (drop - (unreachable) - ) + (unreachable) ) (if (i32.const 88) - (drop - (block - (drop - (i32.const 0) - ) - (unreachable) + (block + (drop + (i32.const 0) ) + (unreachable) ) ) (if @@ -249,34 +235,28 @@ ) (if (i32.const 100) - (drop - (block - (drop - (i32.const 123) - ) - (drop - (i32.const 456) - ) - (unreachable) + (block + (drop + (i32.const 123) ) + (drop + (i32.const 456) + ) + (unreachable) ) ) (if (i32.const 101) - (drop - (block - (drop - (i32.const 123) - ) - (unreachable) + (block + (drop + (i32.const 123) ) + (unreachable) ) ) (if (i32.const 102) - (drop - (unreachable) - ) + (unreachable) ) (drop (i32.const 1337) @@ -313,7 +293,6 @@ (get_local $$$0) ) ) - (unreachable) ) (func $global (type $1) (unreachable) @@ -336,20 +315,14 @@ ) ) (func $unreachable-block-ends-switch (type $2) (result i32) - (block $label$0 i32 - (block $label$3 - (nop) - (unreachable) - ) + (block $label$3 + (nop) (unreachable) ) ) (func $unreachable-block-ends-br_if (type $1) (result i32) - (block $label$0 i32 - (block $label$2 - (nop) - (unreachable) - ) + (block $label$2 + (nop) (unreachable) ) ) @@ -364,13 +337,11 @@ (drop (i32.const 1) ) - (drop - (block - (drop - (i32.const 4104) - ) - (unreachable) + (block + (drop + (i32.const 4104) ) + (unreachable) ) ) (func $call-unreach (type $4) (param $var$0 i64) (param $var$1 i64) (result i64) @@ -404,4 +375,70 @@ ) ) ) + (func $br-gone-means-block-type-changes-then-refinalize-at-end-is-too-late (type $1) (param $var$0 i32) (result i32) + (block $block + (nop) + (unreachable) + ) + ) + (func $br-with-unreachable-value-should-not-give-a-block-a-value (type $1) (param $var$0 i32) (result i32) + (block $label$0 i32 + (block $block + (drop + (br_if $label$0 + (i32.const 8) + (get_local $var$0) + ) + ) + (unreachable) + ) + ) + ) + (func $replace-br-value-of-i32-with-unreachable (type $2) (result i32) + (block $label$1 + (nop) + (unreachable) + ) + ) + (func $shorten-block-requires-sync-refinalize (type $ii) (param $var$0 i32) (param $var$1 i32) + (unreachable) + ) + (func $block-with-type-but-is-unreachable (type $3) (param $var$0 i32) (result i32) + (block $block + (nop) + (unreachable) + ) + ) + (func $if-with-type-but-is-unreachable (type $3) (param $var$0 i32) (result i32) + (if + (get_local $var$0) + (unreachable) + (unreachable) + ) + ) + (func $unreachable-loop (type $1) + (unreachable) + ) + (func $br-block-from-unary (type $2) (result i32) + (block $label$6 i32 + (br $label$6 + (i32.const 8) + ) + ) + ) + (func $replace-unary-with-br-child (type $1) + (drop + (block $label$6 i32 + (br $label$6 + (i32.const 8) + ) + ) + ) + ) + (func $br_if-unreach-then-br_if-normal (type $1) + (block $out + (nop) + (unreachable) + ) + ) ) diff --git a/test/passes/dce.wast b/test/passes/dce.wast index 87a5757cd..7ee37e874 100644 --- a/test/passes/dce.wast +++ b/test/passes/dce.wast @@ -538,4 +538,117 @@ ) ) ) + (func $br-gone-means-block-type-changes-then-refinalize-at-end-is-too-late (type $1) (param $var$0 i32) (result i32) + (block $label$0 i32 + (br $label$0 + (block i32 + (nop) + (drop + (br_if $label$0 + (unreachable) + (get_local $var$0) + ) + ) + (i32.const 4) + ) + ) + ) + ) + (func $br-with-unreachable-value-should-not-give-a-block-a-value (type $1) (param $var$0 i32) (result i32) + (block $label$0 i32 + (br $label$0 + (block i32 ;; turns into unreachable when refinalized + (drop + (br_if $label$0 + (i32.const 8) + (get_local $var$0) + ) + ) + (unreachable) + ) + ) + (i32.const 16) + ) + ) + (func $replace-br-value-of-i32-with-unreachable (result i32) + (block $label$0 i32 + (br $label$0 + (block $label$1 i32 + (nop) + (unreachable) + ) + ) + ) + ) + (func $shorten-block-requires-sync-refinalize (param $var$0 i32) (param $var$1 i32) + (block $label$0 + (unreachable) + (if + (unreachable) + (br_if $label$0 + (get_local $var$1) + ) + ) + ) + ) + (func $block-with-type-but-is-unreachable (param $var$0 i32) (result i32) + (block $label$0 i32 + (br $label$0 + (block $block i32 + (nop) + (unreachable) + ) + ) + ) + ) + (func $if-with-type-but-is-unreachable (param $var$0 i32) (result i32) + (block $label$0 i32 + (br $label$0 + (if i32 + (get_local $var$0) + (unreachable) + (unreachable) + ) + ) + ) + ) + (func $unreachable-loop + (loop $label$2 + (unreachable) + (br $label$2) + ) + ) + (func $br-block-from-unary (result i32) + (block $label$6 i32 + (i32.ctz + (block $label$7 i32 + (br $label$6 + (i32.const 8) + ) + ) + ) + ) + ) + (func $replace-unary-with-br-child + (drop + (block $label$6 i32 + (i32.ctz + (br $label$6 + (i32.const 8) + ) + ) + ) + ) + ) + (func $br_if-unreach-then-br_if-normal + (block $out + (nop) + (br_if $out + (unreachable) + ) + (br_if $out + (i32.const 1) + ) + ) + ) ) diff --git a/test/passes/dce_vacuum.bin.txt b/test/passes/dce_vacuum.bin.txt index 8d365b327..dc8138b24 100644 --- a/test/passes/dce_vacuum.bin.txt +++ b/test/passes/dce_vacuum.bin.txt @@ -5,7 +5,7 @@ (export "f32.compute_radix" (func $0)) (export "f64.compute_radix" (func $1)) (func $0 (type $0) (param $var$0 f32) (param $var$1 f32) (result f32) - (block $label$0 f32 + (block $label$0 (loop $label$1 (br_if $label$1 (f32.eq @@ -28,24 +28,22 @@ ) ) ) - (drop - (block - (drop - (call $0 - (f32.add - (get_local $var$0) - (tee_local $var$1 - (f32.add - (get_local $var$1) - (f32.const 1) - ) + (block + (drop + (call $0 + (f32.add + (get_local $var$0) + (tee_local $var$1 + (f32.add + (get_local $var$1) + (f32.const 1) ) ) - (get_local $var$0) ) + (get_local $var$0) ) - (unreachable) ) + (unreachable) ) ) ) diff --git a/test/passes/dce_vacuum.txt b/test/passes/dce_vacuum.txt index 0f1ec5095..ac61cce04 100644 --- a/test/passes/dce_vacuum.txt +++ b/test/passes/dce_vacuum.txt @@ -9,9 +9,7 @@ ) ) (func $drop-unreachable (type $1) (param $var$0 f32) (param $var$1 f32) (result f32) - (drop - (unreachable) - ) + (unreachable) ) (func $set-unreachable (type $2) (param $var$0 i64) (result i64) (local $var$1 i64) diff --git a/test/passes/precompute.txt b/test/passes/precompute.txt index acd96dee5..3de84aabe 100644 --- a/test/passes/precompute.txt +++ b/test/passes/precompute.txt @@ -105,4 +105,28 @@ (return) ) ) + (func $refinalize-br-condition-unreachable (type $2) + (block $label$1 + (drop + (br_if $label$1 + (unreachable) + ) + ) + ) + ) + (func $br_if-condition-is-block-i32-but-unreachable-so-refinalize-tricky (type $2) + (drop + (block $label$1 + (drop + (br_if $label$1 + (i32.const 100) + (block $label$3 + (unreachable) + ) + ) + ) + (i32.const 0) + ) + ) + ) ) diff --git a/test/passes/precompute.wast b/test/passes/precompute.wast index d5e91fb9d..aafa8e947 100644 --- a/test/passes/precompute.wast +++ b/test/passes/precompute.wast @@ -186,4 +186,28 @@ (return) ) ) + (func $refinalize-br-condition-unreachable + (block $label$1 + (drop + (br_if $label$1 + (unreachable) + ) + ) + ) + ) + (func $br_if-condition-is-block-i32-but-unreachable-so-refinalize-tricky + (drop + (block $label$1 i32 + (drop + (br_if $label$1 + (i32.const 100) + (block $label$3 i32 + (unreachable) + ) + ) + ) + (i32.const 0) + ) + ) + ) ) diff --git a/test/passes/precompute_coalesce-locals_vacuum.txt b/test/passes/precompute_coalesce-locals_vacuum.txt index 76b2303f2..fcf3cdf5d 100644 --- a/test/passes/precompute_coalesce-locals_vacuum.txt +++ b/test/passes/precompute_coalesce-locals_vacuum.txt @@ -2,9 +2,10 @@ (type $0 (func (param i32) (result i32))) (memory $0 0) (func $nested-br_if-value (type $0) (param $0 i32) (result i32) - (loop $label$0 i32 - (block $block i32 + (loop $label$0 + (block $block (br $label$0) + (i32.const 0) ) ) ) diff --git a/test/passes/remove-unused-names_merge-blocks.txt b/test/passes/remove-unused-names_merge-blocks.txt index 50f34c7b2..3c4d7a0a0 100644 --- a/test/passes/remove-unused-names_merge-blocks.txt +++ b/test/passes/remove-unused-names_merge-blocks.txt @@ -448,33 +448,27 @@ (drop (i32.const 10) ) + (unreachable) + (drop + (i32.const 50) + ) (drop (select (i32.const 20) - (block i32 - (unreachable) - (i32.const 40) - ) - (block i32 - (drop - (i32.const 50) - ) - (i32.const 60) - ) + (i32.const 40) + (i32.const 60) ) ) (drop (i32.const 10) ) (drop + (i32.const 30) + ) + (drop (select (i32.const 20) - (block i32 - (drop - (i32.const 30) - ) - (unreachable) - ) + (unreachable) (block i32 (drop (i32.const 50) @@ -489,14 +483,12 @@ (drop (i32.const 30) ) + (unreachable) (drop (select (i32.const 20) (i32.const 40) - (block i32 - (unreachable) - (i32.const 60) - ) + (i32.const 60) ) ) (drop @@ -506,15 +498,13 @@ (i32.const 30) ) (drop + (i32.const 50) + ) + (drop (select (i32.const 20) (i32.const 40) - (block i32 - (drop - (i32.const 50) - ) - (unreachable) - ) + (unreachable) ) ) ) @@ -751,4 +741,11 @@ ) (unreachable) ) + (func $drop-unreachable (type $4) (result i32) + (local $0 i32) + (drop + (unreachable) + ) + (unreachable) + ) ) diff --git a/test/passes/remove-unused-names_merge-blocks.wast b/test/passes/remove-unused-names_merge-blocks.wast index d41ff5fa4..adb27e6f0 100644 --- a/test/passes/remove-unused-names_merge-blocks.wast +++ b/test/passes/remove-unused-names_merge-blocks.wast @@ -914,4 +914,16 @@ ) (unreachable) ) + + (func $drop-unreachable (result i32) + (local $0 i32) + (block $label$1 i32 + (drop + (block i32 + (unreachable) + ) + ) + (unreachable) + ) + ) ) diff --git a/test/passes/remove-unused-names_precompute.txt b/test/passes/remove-unused-names_precompute.txt new file mode 100644 index 000000000..dccd4708e --- /dev/null +++ b/test/passes/remove-unused-names_precompute.txt @@ -0,0 +1,25 @@ +(module + (type $0 (func (param i32))) + (memory $0 256 256) + (func $__ZN10WasmAssertC2Ev__async_cb (type $0) (param $$0 i32) + (block $switch-default + (nop) + (block + (i32.store + (i32.const 12) + (i32.const 26) + ) + (return) + ) + ) + (block + (set_local $$0 + (i32.const 4) + ) + (i32.store + (get_local $$0) + (i32.const 1) + ) + ) + ) +) diff --git a/test/passes/remove-unused-names_precompute.wast b/test/passes/remove-unused-names_precompute.wast new file mode 100644 index 000000000..5e1853389 --- /dev/null +++ b/test/passes/remove-unused-names_precompute.wast @@ -0,0 +1,28 @@ +(module + (memory $0 256 256) + (func $__ZN10WasmAssertC2Ev__async_cb (param $$0 i32) + (block $switch-default + (block $switch-case + (br_table $switch-case $switch-default + (i32.const 0) + ) + ) + (block + (i32.store + (i32.const 12) + (i32.const 26) + ) + (return) + ) + ) + (block + (set_local $$0 + (i32.const 4) + ) + (i32.store + (get_local $$0) + (i32.const 1) + ) + ) + ) +) diff --git a/test/passes/remove-unused-names_vacuum.txt b/test/passes/remove-unused-names_vacuum.txt index 05112bf48..a1f49128e 100644 --- a/test/passes/remove-unused-names_vacuum.txt +++ b/test/passes/remove-unused-names_vacuum.txt @@ -1,5 +1,6 @@ (module (type $0 (func (result i32))) + (type $1 (func)) (memory $0 0) (func $return-i32-but-body-is-unreachable3 (type $0) (result i32) (local $label i32) @@ -10,4 +11,11 @@ (unreachable) (i32.const 0) ) + (func $to-drop-unreachable (type $1) + (drop + (block i32 + (unreachable) + ) + ) + ) ) diff --git a/test/passes/remove-unused-names_vacuum.wast b/test/passes/remove-unused-names_vacuum.wast index 694d95cfd..cb5affac3 100644 --- a/test/passes/remove-unused-names_vacuum.wast +++ b/test/passes/remove-unused-names_vacuum.wast @@ -16,5 +16,12 @@ ) (i32.const 0) ) + (func $to-drop-unreachable + (drop + (block i32 + (unreachable) + ) + ) + ) ) diff --git a/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt b/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt index 5ed8e80c7..d41cd386e 100644 --- a/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt +++ b/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt @@ -46,14 +46,12 @@ (get_local $0) ) ) - (block $block$11$break - (loop $shape$9$continue - (call $trivial) - (br_if $shape$9$continue + (loop $shape$9$continue + (call $trivial) + (br_if $shape$9$continue + (i32.eqz (i32.eqz - (i32.eqz - (get_local $0) - ) + (get_local $0) ) ) ) diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index f64ef0868..be18cc713 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -17,19 +17,11 @@ (set_local $x (get_local $x) ) - (block $in-a-block - ) - (block $two-in-a-block - ) (set_local $x - (block $result-used i32 - (get_local $x) - ) + (get_local $x) ) (set_local $x - (block $two-and-result-used i32 - (get_local $y) - ) + (get_local $y) ) ) (func $loopy (type $1) (param $0 i32) @@ -98,20 +90,10 @@ ) ) (func $block-to-one (type $0) - (block $block0 - ) - (block $block1 - (unreachable) - ) - (block $block2 - (unreachable) - ) - (block $block3 - (unreachable) - ) - (block $block4 - (unreachable) - ) + (unreachable) + (unreachable) + (unreachable) + (unreachable) ) (func $recurse (type $0) (nop) @@ -123,20 +105,18 @@ (if (if i32 (get_local $d) - (block $block1 i32 - (f64.ne - (f64.promote/f32 - (f32.load - (tee_local $l - (i32.add - (get_local $b) - (i32.const 60) - ) + (f64.ne + (f64.promote/f32 + (f32.load + (tee_local $l + (i32.add + (get_local $b) + (i32.const 60) ) ) ) - (get_local $e) ) + (get_local $e) ) (i32.const 0) ) @@ -185,22 +165,7 @@ (func $relooperJumpThreading1 (type $0) (local $$vararg_ptr5 i32) (local $$11 i32) - (loop $while-in$1 - (drop - (block $jumpthreading$outer$8 i32 - (block $jumpthreading$inner$8 - (br $jumpthreading$outer$8 - (i32.const 0) - ) - ) - (i32.store - (get_local $$vararg_ptr5) - (get_local $$11) - ) - (i32.const 0) - ) - ) - ) + (nop) ) (func $relooperJumpThreading2 (type $0) (nop) @@ -259,4 +224,36 @@ ) ) ) + (func $if-1-block (type $1) (param $x i32) + (block $out + (if + (get_local $x) + (block $block9 + (set_local $x + (get_local $x) + ) + (br $out) + ) + ) + ) + ) + (func $block-resize-br-gone (type $0) + (block $out + (block $in + (call $block-resize-br-gone) + (br $in) + ) + (return) + ) + (block $out2 + (block $in2 + (br $in2) + ) + (return) + ) + ) + (func $block-unreachable-but-last-element-concrete (type $0) + (local $2 i32) + (nop) + ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index 8b97b9386..01c928e4d 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -463,4 +463,50 @@ ) ) ) + (func $if-1-block (param $x i32) + (block $out + (if + (get_local $x) + (block + (if + (i32.const 1) + (block + (set_local $x + (get_local $x) + ) + (br $out) + ) + ) + ) + ) + ) + ) + (func $block-resize-br-gone + (block $out + (block $in + (call $block-resize-br-gone) + (br $in) + (br $out) + ) + (return) + ) + (block $out2 + (block $in2 + (br $in2) + (br $out2) + ) + (return) + ) + ) + (func $block-unreachable-but-last-element-concrete + (local $2 i32) + (block $label$0 + (drop + (block + (br $label$0) + (get_local $2) + ) + ) + ) + ) ) |