diff options
Diffstat (limited to 'test')
31 files changed, 3438 insertions, 212 deletions
diff --git a/test/dot_s/unreachable_blocks.wast b/test/dot_s/unreachable_blocks.wast index f1593a00c..d9e921a4a 100644 --- a/test/dot_s/unreachable_blocks.wast +++ b/test/dot_s/unreachable_blocks.wast @@ -14,7 +14,7 @@ (return (i32.const 2) ) - (block $label$0 i32 + (block $label$0 (unreachable) ) ) @@ -22,7 +22,7 @@ (return (i64.const 3) ) - (block $label$0 i64 + (block $label$0 (unreachable) ) ) @@ -30,7 +30,7 @@ (return (f32.const 4.5) ) - (block $label$0 f32 + (block $label$0 (unreachable) ) ) @@ -38,7 +38,7 @@ (return (f64.const 5.5) ) - (block $label$0 f64 + (block $label$0 (unreachable) ) ) 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) + ) + ) + ) + ) ) diff --git a/test/unreachable-import_wasm-only.fromasm b/test/unreachable-import_wasm-only.fromasm index 642d266dc..fad6e4de8 100644 --- a/test/unreachable-import_wasm-only.fromasm +++ b/test/unreachable-import_wasm-only.fromasm @@ -8,19 +8,17 @@ (data (get_global $memoryBase) "unreachable-import_wasm-only.asm.js") (export "__ZN10WasmAssertC2Ev__async_cb" (func $__ZN10WasmAssertC2Ev__async_cb)) (func $__ZN10WasmAssertC2Ev__async_cb (param $0 i32) - (block $switch-default - (i32.store - (i32.const 12) - (i32.const 26) - ) - (return) + (i32.store + (i32.const 12) + (i32.const 26) ) + (return) (i32.store - (unreachable) + (i32.const 0) (i32.const 1) ) (call $___cxa_throw - (unreachable) + (i32.const 0) (i32.const 1280) (i32.const 0) ) diff --git a/test/unreachable-import_wasm-only.fromasm.clamp b/test/unreachable-import_wasm-only.fromasm.clamp index 642d266dc..fad6e4de8 100644 --- a/test/unreachable-import_wasm-only.fromasm.clamp +++ b/test/unreachable-import_wasm-only.fromasm.clamp @@ -8,19 +8,17 @@ (data (get_global $memoryBase) "unreachable-import_wasm-only.asm.js") (export "__ZN10WasmAssertC2Ev__async_cb" (func $__ZN10WasmAssertC2Ev__async_cb)) (func $__ZN10WasmAssertC2Ev__async_cb (param $0 i32) - (block $switch-default - (i32.store - (i32.const 12) - (i32.const 26) - ) - (return) + (i32.store + (i32.const 12) + (i32.const 26) ) + (return) (i32.store - (unreachable) + (i32.const 0) (i32.const 1) ) (call $___cxa_throw - (unreachable) + (i32.const 0) (i32.const 1280) (i32.const 0) ) diff --git a/test/unreachable-import_wasm-only.fromasm.imprecise b/test/unreachable-import_wasm-only.fromasm.imprecise index c6a954d24..a85dc9ed8 100644 --- a/test/unreachable-import_wasm-only.fromasm.imprecise +++ b/test/unreachable-import_wasm-only.fromasm.imprecise @@ -7,19 +7,17 @@ (import "env" "tableBase" (global $tableBase i32)) (export "__ZN10WasmAssertC2Ev__async_cb" (func $__ZN10WasmAssertC2Ev__async_cb)) (func $__ZN10WasmAssertC2Ev__async_cb (param $0 i32) - (block $switch-default - (i32.store - (i32.const 12) - (i32.const 26) - ) - (return) + (i32.store + (i32.const 12) + (i32.const 26) ) + (return) (i32.store - (unreachable) + (i32.const 0) (i32.const 1) ) (call $___cxa_throw - (unreachable) + (i32.const 0) (i32.const 1280) (i32.const 0) ) diff --git a/test/wasm-only.asm.js b/test/wasm-only.asm.js index 371197173..7287126d0 100644 --- a/test/wasm-only.asm.js +++ b/test/wasm-only.asm.js @@ -16,7 +16,10 @@ function asm(global, env, buffer) { var HEAPF32 = new global.Float32Array(buffer); var HEAPF64 = new global.Float64Array(buffer); + var STACKTOP = env.STACKTOP | 0; + var fround = global.Math.fround; + var Math_imul = global.Math.imul; var illegalImport = env.illegalImport; var illegalImportResult = env.illegalImportResult; @@ -284,6 +287,135 @@ function asm(global, env, buffer) { } return 44; } + function _memchr($src,$c,$n) { + $src = $src|0; + $c = $c|0; + $n = $n|0; + var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $and = 0, $and15 = 0, $and16 = 0, $and39 = 0, $cmp = 0, $cmp11 = 0, $cmp1132 = 0, $cmp28 = 0, $cmp8 = 0, $cond = 0, $conv1 = 0, $dec = 0; + var $dec34 = 0, $incdec$ptr = 0, $incdec$ptr21 = 0, $incdec$ptr33 = 0, $lnot = 0, $mul = 0, $n$addr$0$lcssa = 0, $n$addr$0$lcssa52 = 0, $n$addr$043 = 0, $n$addr$1$lcssa = 0, $n$addr$133 = 0, $n$addr$227 = 0, $n$addr$3 = 0, $neg = 0, $or$cond = 0, $or$cond42 = 0, $s$0$lcssa = 0, $s$0$lcssa53 = 0, $s$044 = 0, $s$128 = 0; + var $s$2 = 0, $sub = 0, $sub22 = 0, $tobool = 0, $tobool2 = 0, $tobool2$lcssa = 0, $tobool241 = 0, $tobool25 = 0, $tobool2526 = 0, $tobool36 = 0, $tobool40 = 0, $w$0$lcssa = 0, $w$034 = 0, $xor = 0, label = 0, sp = 0; + sp = STACKTOP; + $conv1 = $c & 255; + $0 = $src; + $and39 = $0 & 3; + $tobool40 = ($and39|0)!=(0); + $tobool241 = ($n|0)!=(0); + $or$cond42 = $tobool241 & $tobool40; + L1: do { + if ($or$cond42) { + $1 = $c&255; + $n$addr$043 = $n;$s$044 = $src; + while(1) { + $2 = load1($s$044); + $cmp = ($2<<24>>24)==($1<<24>>24); + if ($cmp) { + $n$addr$0$lcssa52 = $n$addr$043;$s$0$lcssa53 = $s$044; + label = 6; + break L1; + } + $incdec$ptr = ((($s$044)) + 1|0); + $dec = (($n$addr$043) + -1)|0; + $3 = $incdec$ptr; + $and = $3 & 3; + $tobool = ($and|0)!=(0); + $tobool2 = ($dec|0)!=(0); + $or$cond = $tobool2 & $tobool; + if ($or$cond) { + $n$addr$043 = $dec;$s$044 = $incdec$ptr; + } else { + $n$addr$0$lcssa = $dec;$s$0$lcssa = $incdec$ptr;$tobool2$lcssa = $tobool2; + label = 5; + break; + } + } + } else { + $n$addr$0$lcssa = $n;$s$0$lcssa = $src;$tobool2$lcssa = $tobool241; + label = 5; + } + } while(0); + if ((label|0) == 5) { + if ($tobool2$lcssa) { + $n$addr$0$lcssa52 = $n$addr$0$lcssa;$s$0$lcssa53 = $s$0$lcssa; + label = 6; + } else { + $n$addr$3 = 0;$s$2 = $s$0$lcssa; + } + } + L8: do { + if ((label|0) == 6) { + $4 = load1($s$0$lcssa53); + $5 = $c&255; + $cmp8 = ($4<<24>>24)==($5<<24>>24); + if ($cmp8) { + $n$addr$3 = $n$addr$0$lcssa52;$s$2 = $s$0$lcssa53; + } else { + $mul = Math_imul($conv1, 16843009)|0; + $cmp1132 = ($n$addr$0$lcssa52>>>0)>(3); + L11: do { + if ($cmp1132) { + $n$addr$133 = $n$addr$0$lcssa52;$w$034 = $s$0$lcssa53; + while(1) { + $6 = load4($w$034); + $xor = $6 ^ $mul; + $sub = (($xor) + -16843009)|0; + $neg = $xor & -2139062144; + $and15 = $neg ^ -2139062144; + $and16 = $and15 & $sub; + $lnot = ($and16|0)==(0); + if (!($lnot)) { + break; + } + $incdec$ptr21 = ((($w$034)) + 4|0); + $sub22 = (($n$addr$133) + -4)|0; + $cmp11 = ($sub22>>>0)>(3); + if ($cmp11) { + $n$addr$133 = $sub22;$w$034 = $incdec$ptr21; + } else { + $n$addr$1$lcssa = $sub22;$w$0$lcssa = $incdec$ptr21; + label = 11; + break L11; + } + } + $n$addr$227 = $n$addr$133;$s$128 = $w$034; + } else { + $n$addr$1$lcssa = $n$addr$0$lcssa52;$w$0$lcssa = $s$0$lcssa53; + label = 11; + } + } while(0); + if ((label|0) == 11) { + $tobool2526 = ($n$addr$1$lcssa|0)==(0); + if ($tobool2526) { + $n$addr$3 = 0;$s$2 = $w$0$lcssa; + break; + } else { + $n$addr$227 = $n$addr$1$lcssa;$s$128 = $w$0$lcssa; + } + } + while(1) { + $7 = load1($s$128); + $cmp28 = ($7<<24>>24)==($5<<24>>24); + if ($cmp28) { + $n$addr$3 = $n$addr$227;$s$2 = $s$128; + break L8; + } + $incdec$ptr33 = ((($s$128)) + 1|0); + $dec34 = (($n$addr$227) + -1)|0; + $tobool25 = ($dec34|0)==(0); + if ($tobool25) { + $n$addr$3 = 0;$s$2 = $incdec$ptr33; + break; + } else { + $n$addr$227 = $dec34;$s$128 = $incdec$ptr33; + } + } + } + } + } while(0); + $tobool36 = ($n$addr$3|0)!=(0); + $cond = $tobool36 ? $s$2 : 0; + return ($cond|0); + } + function keepAlive() { loads(); stores(); @@ -297,6 +429,8 @@ function asm(global, env, buffer) { ifValue32(0, 0) | 0; switch64(i64(0)) | 0; unreachable_leftovers(0, 0, 0); + _memchr(0, 0, 0) | 0; + switch64TOOMUCH(i64(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 6fa30ba12..3a98e84a3 100644 --- a/test/wasm-only.fromasm +++ b/test/wasm-only.fromasm @@ -365,6 +365,325 @@ ) ) ) + (func $switch64TOOMUCH (param $0 i64) (result i32) + (local $1 i32) + (local $2 i64) + (block $switch-default + (if + (i64.ne + (tee_local $2 + (get_local $0) + ) + (i64.const -9223372036854775808) + ) + (br_if $switch-default + (i64.ne + (get_local $2) + (i64.const 4611686018427387904) + ) + ) + ) + (return + (i32.const 40) + ) + ) + (block $switch-default4 + (if + (i32.ne + (tee_local $1 + (i32.const 100) + ) + (i32.const 214748364) + ) + (br_if $switch-default4 + (i32.ne + (get_local $1) + (i32.const 107374182) + ) + ) + ) + (return + (i32.const 41) + ) + ) + (block $switch5 + (if + (i64.ne + (get_local $0) + (i64.const -9223372036854775808) + ) + (br_if $switch5 + (i64.ne + (get_local $0) + (i64.const 4611686018427387904) + ) + ) + ) + (return + (i32.const 42) + ) + ) + (block $switch8 + (if + (i32.ne + (tee_local $1 + (i32.const 100) + ) + (i32.const 214748364) + ) + (br_if $switch8 + (i32.ne + (get_local $1) + (i32.const 107374182) + ) + ) + ) + (return + (i32.const 43) + ) + ) + (i32.const 44) + ) + (func $_memchr (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (set_local $5 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + (block $label$break$L8 + (block $__rjti$2 + (if + (i32.and + (tee_local $4 + (i32.ne + (get_local $2) + (i32.const 0) + ) + ) + (i32.ne + (i32.and + (get_local $0) + (i32.const 3) + ) + (i32.const 0) + ) + ) + (block + (set_local $4 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + (set_local $3 + (get_local $2) + ) + (set_local $2 + (get_local $0) + ) + (loop $while-in + (if + (i32.eq + (i32.load8_u + (get_local $2) + ) + (i32.and + (get_local $4) + (i32.const 255) + ) + ) + (block + (set_local $0 + (get_local $3) + ) + (br $__rjti$2) + ) + ) + (br_if $while-in + (i32.and + (tee_local $0 + (i32.ne + (tee_local $3 + (i32.add + (get_local $3) + (i32.const -1) + ) + ) + (i32.const 0) + ) + ) + (i32.ne + (i32.and + (tee_local $2 + (i32.add + (get_local $2) + (i32.const 1) + ) + ) + (i32.const 3) + ) + (i32.const 0) + ) + ) + ) + ) + ) + (block + (set_local $3 + (get_local $2) + ) + (set_local $2 + (get_local $0) + ) + (set_local $0 + (get_local $4) + ) + ) + ) + (if + (get_local $0) + (block + (set_local $0 + (get_local $3) + ) + (br $__rjti$2) + ) + (set_local $0 + (i32.const 0) + ) + ) + (br $label$break$L8) + ) + (if + (i32.ne + (i32.load8_u + (get_local $2) + ) + (tee_local $1 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + ) + (block + (set_local $3 + (i32.mul + (get_local $5) + (i32.const 16843009) + ) + ) + (block $__rjto$0 + (block $__rjti$0 + (br_if $__rjti$0 + (i32.le_u + (get_local $0) + (i32.const 3) + ) + ) + (loop $while-in3 + (if + (i32.eqz + (i32.and + (i32.xor + (i32.and + (tee_local $4 + (i32.xor + (i32.load + (get_local $2) + ) + (get_local $3) + ) + ) + (i32.const -2139062144) + ) + (i32.const -2139062144) + ) + (i32.add + (get_local $4) + (i32.const -16843009) + ) + ) + ) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) + ) + (br_if $while-in3 + (i32.gt_u + (tee_local $0 + (i32.add + (get_local $0) + (i32.const -4) + ) + ) + (i32.const 3) + ) + ) + (br $__rjti$0) + ) + ) + ) + (br $__rjto$0) + ) + (if + (i32.eqz + (get_local $0) + ) + (block + (set_local $0 + (i32.const 0) + ) + (br $label$break$L8) + ) + ) + ) + (loop $while-in5 + (br_if $label$break$L8 + (i32.eq + (i32.load8_u + (get_local $2) + ) + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + ) + (set_local $2 + (i32.add + (get_local $2) + (i32.const 1) + ) + ) + (br_if $while-in5 + (tee_local $0 + (i32.add + (get_local $0) + (i32.const -1) + ) + ) + ) + (set_local $0 + (i32.const 0) + ) + ) + ) + ) + ) + (select + (get_local $2) + (i32.const 0) + (get_local $0) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -410,6 +729,18 @@ (i32.const 0) (i32.const 0) ) + (drop + (call $_memchr + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (drop + (call $switch64TOOMUCH + (i64.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.clamp b/test/wasm-only.fromasm.clamp index 6fa30ba12..3a98e84a3 100644 --- a/test/wasm-only.fromasm.clamp +++ b/test/wasm-only.fromasm.clamp @@ -365,6 +365,325 @@ ) ) ) + (func $switch64TOOMUCH (param $0 i64) (result i32) + (local $1 i32) + (local $2 i64) + (block $switch-default + (if + (i64.ne + (tee_local $2 + (get_local $0) + ) + (i64.const -9223372036854775808) + ) + (br_if $switch-default + (i64.ne + (get_local $2) + (i64.const 4611686018427387904) + ) + ) + ) + (return + (i32.const 40) + ) + ) + (block $switch-default4 + (if + (i32.ne + (tee_local $1 + (i32.const 100) + ) + (i32.const 214748364) + ) + (br_if $switch-default4 + (i32.ne + (get_local $1) + (i32.const 107374182) + ) + ) + ) + (return + (i32.const 41) + ) + ) + (block $switch5 + (if + (i64.ne + (get_local $0) + (i64.const -9223372036854775808) + ) + (br_if $switch5 + (i64.ne + (get_local $0) + (i64.const 4611686018427387904) + ) + ) + ) + (return + (i32.const 42) + ) + ) + (block $switch8 + (if + (i32.ne + (tee_local $1 + (i32.const 100) + ) + (i32.const 214748364) + ) + (br_if $switch8 + (i32.ne + (get_local $1) + (i32.const 107374182) + ) + ) + ) + (return + (i32.const 43) + ) + ) + (i32.const 44) + ) + (func $_memchr (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (set_local $5 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + (block $label$break$L8 + (block $__rjti$2 + (if + (i32.and + (tee_local $4 + (i32.ne + (get_local $2) + (i32.const 0) + ) + ) + (i32.ne + (i32.and + (get_local $0) + (i32.const 3) + ) + (i32.const 0) + ) + ) + (block + (set_local $4 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + (set_local $3 + (get_local $2) + ) + (set_local $2 + (get_local $0) + ) + (loop $while-in + (if + (i32.eq + (i32.load8_u + (get_local $2) + ) + (i32.and + (get_local $4) + (i32.const 255) + ) + ) + (block + (set_local $0 + (get_local $3) + ) + (br $__rjti$2) + ) + ) + (br_if $while-in + (i32.and + (tee_local $0 + (i32.ne + (tee_local $3 + (i32.add + (get_local $3) + (i32.const -1) + ) + ) + (i32.const 0) + ) + ) + (i32.ne + (i32.and + (tee_local $2 + (i32.add + (get_local $2) + (i32.const 1) + ) + ) + (i32.const 3) + ) + (i32.const 0) + ) + ) + ) + ) + ) + (block + (set_local $3 + (get_local $2) + ) + (set_local $2 + (get_local $0) + ) + (set_local $0 + (get_local $4) + ) + ) + ) + (if + (get_local $0) + (block + (set_local $0 + (get_local $3) + ) + (br $__rjti$2) + ) + (set_local $0 + (i32.const 0) + ) + ) + (br $label$break$L8) + ) + (if + (i32.ne + (i32.load8_u + (get_local $2) + ) + (tee_local $1 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + ) + (block + (set_local $3 + (i32.mul + (get_local $5) + (i32.const 16843009) + ) + ) + (block $__rjto$0 + (block $__rjti$0 + (br_if $__rjti$0 + (i32.le_u + (get_local $0) + (i32.const 3) + ) + ) + (loop $while-in3 + (if + (i32.eqz + (i32.and + (i32.xor + (i32.and + (tee_local $4 + (i32.xor + (i32.load + (get_local $2) + ) + (get_local $3) + ) + ) + (i32.const -2139062144) + ) + (i32.const -2139062144) + ) + (i32.add + (get_local $4) + (i32.const -16843009) + ) + ) + ) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) + ) + (br_if $while-in3 + (i32.gt_u + (tee_local $0 + (i32.add + (get_local $0) + (i32.const -4) + ) + ) + (i32.const 3) + ) + ) + (br $__rjti$0) + ) + ) + ) + (br $__rjto$0) + ) + (if + (i32.eqz + (get_local $0) + ) + (block + (set_local $0 + (i32.const 0) + ) + (br $label$break$L8) + ) + ) + ) + (loop $while-in5 + (br_if $label$break$L8 + (i32.eq + (i32.load8_u + (get_local $2) + ) + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + ) + (set_local $2 + (i32.add + (get_local $2) + (i32.const 1) + ) + ) + (br_if $while-in5 + (tee_local $0 + (i32.add + (get_local $0) + (i32.const -1) + ) + ) + ) + (set_local $0 + (i32.const 0) + ) + ) + ) + ) + ) + (select + (get_local $2) + (i32.const 0) + (get_local $0) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -410,6 +729,18 @@ (i32.const 0) (i32.const 0) ) + (drop + (call $_memchr + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (drop + (call $switch64TOOMUCH + (i64.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.clamp.no-opts b/test/wasm-only.fromasm.clamp.no-opts index 3bcbf33d5..da52d1955 100644 --- a/test/wasm-only.fromasm.clamp.no-opts +++ b/test/wasm-only.fromasm.clamp.no-opts @@ -6,6 +6,7 @@ (type $legaltype$illegalImportResult (func (result i32))) (type $legaltype$_fabsf (func (param f64) (result f64))) (type $legaltype$do_i64 (func (result i32))) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) (import "env" "illegalImport" (func $illegalImport (param f64 i64 i32))) (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "_fabsf" (func $_fabsf (param f32) (result f32))) @@ -18,6 +19,7 @@ (import "env" "table" (table 3 3 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) + (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) (global $tempRet0 (mut i32) (i32.const 0)) (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64) (export "test64" (func $test64)) @@ -950,6 +952,584 @@ (i32.const 44) ) ) + (func $_memchr (param $$src i32) (param $$c i32) (param $$n i32) (result i32) + (local $$0 i32) + (local $$1 i32) + (local $$2 i32) + (local $$3 i32) + (local $$4 i32) + (local $$5 i32) + (local $$6 i32) + (local $$7 i32) + (local $$and i32) + (local $$and15 i32) + (local $$and16 i32) + (local $$and39 i32) + (local $$cmp i32) + (local $$cmp11 i32) + (local $$cmp1132 i32) + (local $$cmp28 i32) + (local $$cmp8 i32) + (local $$cond i32) + (local $$conv1 i32) + (local $$dec i32) + (local $$dec34 i32) + (local $$incdec$ptr i32) + (local $$incdec$ptr21 i32) + (local $$incdec$ptr33 i32) + (local $$lnot i32) + (local $$mul i32) + (local $$n$addr$0$lcssa i32) + (local $$n$addr$0$lcssa52 i32) + (local $$n$addr$043 i32) + (local $$n$addr$1$lcssa i32) + (local $$n$addr$133 i32) + (local $$n$addr$227 i32) + (local $$n$addr$3 i32) + (local $$neg i32) + (local $$or$cond i32) + (local $$or$cond42 i32) + (local $$s$0$lcssa i32) + (local $$s$0$lcssa53 i32) + (local $$s$044 i32) + (local $$s$128 i32) + (local $$s$2 i32) + (local $$sub i32) + (local $$sub22 i32) + (local $$tobool i32) + (local $$tobool2 i32) + (local $$tobool2$lcssa i32) + (local $$tobool241 i32) + (local $$tobool25 i32) + (local $$tobool2526 i32) + (local $$tobool36 i32) + (local $$tobool40 i32) + (local $$w$0$lcssa i32) + (local $$w$034 i32) + (local $$xor i32) + (local $label i32) + (local $sp i32) + (set_local $sp + (get_global $STACKTOP) + ) + (set_local $$conv1 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$0 + (get_local $$src) + ) + (set_local $$and39 + (i32.and + (get_local $$0) + (i32.const 3) + ) + ) + (set_local $$tobool40 + (i32.ne + (get_local $$and39) + (i32.const 0) + ) + ) + (set_local $$tobool241 + (i32.ne + (get_local $$n) + (i32.const 0) + ) + ) + (set_local $$or$cond42 + (i32.and + (get_local $$tobool241) + (get_local $$tobool40) + ) + ) + (block $label$break$L1 + (if + (get_local $$or$cond42) + (block + (set_local $$1 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$n$addr$043 + (get_local $$n) + ) + (set_local $$s$044 + (get_local $$src) + ) + (loop $while-in + (block $while-out + (set_local $$2 + (i32.load8_s + (get_local $$s$044) + ) + ) + (set_local $$cmp + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$2) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$1) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp) + (block + (set_local $$n$addr$0$lcssa52 + (get_local $$n$addr$043) + ) + (set_local $$s$0$lcssa53 + (get_local $$s$044) + ) + (set_local $label + (i32.const 6) + ) + (br $label$break$L1) + ) + ) + (set_local $$incdec$ptr + (i32.add + (get_local $$s$044) + (i32.const 1) + ) + ) + (set_local $$dec + (i32.add + (get_local $$n$addr$043) + (i32.const -1) + ) + ) + (set_local $$3 + (get_local $$incdec$ptr) + ) + (set_local $$and + (i32.and + (get_local $$3) + (i32.const 3) + ) + ) + (set_local $$tobool + (i32.ne + (get_local $$and) + (i32.const 0) + ) + ) + (set_local $$tobool2 + (i32.ne + (get_local $$dec) + (i32.const 0) + ) + ) + (set_local $$or$cond + (i32.and + (get_local $$tobool2) + (get_local $$tobool) + ) + ) + (if + (get_local $$or$cond) + (block + (set_local $$n$addr$043 + (get_local $$dec) + ) + (set_local $$s$044 + (get_local $$incdec$ptr) + ) + ) + (block + (set_local $$n$addr$0$lcssa + (get_local $$dec) + ) + (set_local $$s$0$lcssa + (get_local $$incdec$ptr) + ) + (set_local $$tobool2$lcssa + (get_local $$tobool2) + ) + (set_local $label + (i32.const 5) + ) + (br $while-out) + ) + ) + (br $while-in) + ) + ) + ) + (block + (set_local $$n$addr$0$lcssa + (get_local $$n) + ) + (set_local $$s$0$lcssa + (get_local $$src) + ) + (set_local $$tobool2$lcssa + (get_local $$tobool241) + ) + (set_local $label + (i32.const 5) + ) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 5) + ) + (if + (get_local $$tobool2$lcssa) + (block + (set_local $$n$addr$0$lcssa52 + (get_local $$n$addr$0$lcssa) + ) + (set_local $$s$0$lcssa53 + (get_local $$s$0$lcssa) + ) + (set_local $label + (i32.const 6) + ) + ) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$s$0$lcssa) + ) + ) + ) + ) + (block $label$break$L8 + (if + (i32.eq + (get_local $label) + (i32.const 6) + ) + (block + (set_local $$4 + (i32.load8_s + (get_local $$s$0$lcssa53) + ) + ) + (set_local $$5 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$cmp8 + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$4) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$5) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp8) + (block + (set_local $$n$addr$3 + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$s$2 + (get_local $$s$0$lcssa53) + ) + ) + (block + (set_local $$mul + (i32.mul + (get_local $$conv1) + (i32.const 16843009) + ) + ) + (set_local $$cmp1132 + (i32.gt_u + (get_local $$n$addr$0$lcssa52) + (i32.const 3) + ) + ) + (block $label$break$L11 + (if + (get_local $$cmp1132) + (block + (set_local $$n$addr$133 + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$w$034 + (get_local $$s$0$lcssa53) + ) + (loop $while-in3 + (block $while-out2 + (set_local $$6 + (i32.load + (get_local $$w$034) + ) + ) + (set_local $$xor + (i32.xor + (get_local $$6) + (get_local $$mul) + ) + ) + (set_local $$sub + (i32.add + (get_local $$xor) + (i32.const -16843009) + ) + ) + (set_local $$neg + (i32.and + (get_local $$xor) + (i32.const -2139062144) + ) + ) + (set_local $$and15 + (i32.xor + (get_local $$neg) + (i32.const -2139062144) + ) + ) + (set_local $$and16 + (i32.and + (get_local $$and15) + (get_local $$sub) + ) + ) + (set_local $$lnot + (i32.eq + (get_local $$and16) + (i32.const 0) + ) + ) + (if + (i32.eqz + (get_local $$lnot) + ) + (br $while-out2) + ) + (set_local $$incdec$ptr21 + (i32.add + (get_local $$w$034) + (i32.const 4) + ) + ) + (set_local $$sub22 + (i32.add + (get_local $$n$addr$133) + (i32.const -4) + ) + ) + (set_local $$cmp11 + (i32.gt_u + (get_local $$sub22) + (i32.const 3) + ) + ) + (if + (get_local $$cmp11) + (block + (set_local $$n$addr$133 + (get_local $$sub22) + ) + (set_local $$w$034 + (get_local $$incdec$ptr21) + ) + ) + (block + (set_local $$n$addr$1$lcssa + (get_local $$sub22) + ) + (set_local $$w$0$lcssa + (get_local $$incdec$ptr21) + ) + (set_local $label + (i32.const 11) + ) + (br $label$break$L11) + ) + ) + (br $while-in3) + ) + ) + (set_local $$n$addr$227 + (get_local $$n$addr$133) + ) + (set_local $$s$128 + (get_local $$w$034) + ) + ) + (block + (set_local $$n$addr$1$lcssa + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$w$0$lcssa + (get_local $$s$0$lcssa53) + ) + (set_local $label + (i32.const 11) + ) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 11) + ) + (block + (set_local $$tobool2526 + (i32.eq + (get_local $$n$addr$1$lcssa) + (i32.const 0) + ) + ) + (if + (get_local $$tobool2526) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$w$0$lcssa) + ) + (br $label$break$L8) + ) + (block + (set_local $$n$addr$227 + (get_local $$n$addr$1$lcssa) + ) + (set_local $$s$128 + (get_local $$w$0$lcssa) + ) + ) + ) + ) + ) + (loop $while-in5 + (block $while-out4 + (set_local $$7 + (i32.load8_s + (get_local $$s$128) + ) + ) + (set_local $$cmp28 + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$7) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$5) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp28) + (block + (set_local $$n$addr$3 + (get_local $$n$addr$227) + ) + (set_local $$s$2 + (get_local $$s$128) + ) + (br $label$break$L8) + ) + ) + (set_local $$incdec$ptr33 + (i32.add + (get_local $$s$128) + (i32.const 1) + ) + ) + (set_local $$dec34 + (i32.add + (get_local $$n$addr$227) + (i32.const -1) + ) + ) + (set_local $$tobool25 + (i32.eq + (get_local $$dec34) + (i32.const 0) + ) + ) + (if + (get_local $$tobool25) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$incdec$ptr33) + ) + (br $while-out4) + ) + (block + (set_local $$n$addr$227 + (get_local $$dec34) + ) + (set_local $$s$128 + (get_local $$incdec$ptr33) + ) + ) + ) + (br $while-in5) + ) + ) + ) + ) + ) + ) + ) + (set_local $$tobool36 + (i32.ne + (get_local $$n$addr$3) + (i32.const 0) + ) + ) + (set_local $$cond + (if i32 + (get_local $$tobool36) + (get_local $$s$2) + (i32.const 0) + ) + ) + (return + (get_local $$cond) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -995,6 +1575,18 @@ (i32.const 0) (i32.const 0) ) + (drop + (call $_memchr + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (drop + (call $switch64TOOMUCH + (i64.const 0) + ) + ) ) (func $__emscripten_dceable_type_decls (drop diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise index 11eedc71d..de241740e 100644 --- a/test/wasm-only.fromasm.imprecise +++ b/test/wasm-only.fromasm.imprecise @@ -280,6 +280,325 @@ ) ) ) + (func $switch64TOOMUCH (param $0 i64) (result i32) + (local $1 i32) + (local $2 i64) + (block $switch-default + (if + (i64.ne + (tee_local $2 + (get_local $0) + ) + (i64.const -9223372036854775808) + ) + (br_if $switch-default + (i64.ne + (get_local $2) + (i64.const 4611686018427387904) + ) + ) + ) + (return + (i32.const 40) + ) + ) + (block $switch-default4 + (if + (i32.ne + (tee_local $1 + (i32.const 100) + ) + (i32.const 214748364) + ) + (br_if $switch-default4 + (i32.ne + (get_local $1) + (i32.const 107374182) + ) + ) + ) + (return + (i32.const 41) + ) + ) + (block $switch5 + (if + (i64.ne + (get_local $0) + (i64.const -9223372036854775808) + ) + (br_if $switch5 + (i64.ne + (get_local $0) + (i64.const 4611686018427387904) + ) + ) + ) + (return + (i32.const 42) + ) + ) + (block $switch8 + (if + (i32.ne + (tee_local $1 + (i32.const 100) + ) + (i32.const 214748364) + ) + (br_if $switch8 + (i32.ne + (get_local $1) + (i32.const 107374182) + ) + ) + ) + (return + (i32.const 43) + ) + ) + (i32.const 44) + ) + (func $_memchr (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (set_local $5 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + (block $label$break$L8 + (block $__rjti$2 + (if + (i32.and + (tee_local $4 + (i32.ne + (get_local $2) + (i32.const 0) + ) + ) + (i32.ne + (i32.and + (get_local $0) + (i32.const 3) + ) + (i32.const 0) + ) + ) + (block + (set_local $4 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + (set_local $3 + (get_local $2) + ) + (set_local $2 + (get_local $0) + ) + (loop $while-in + (if + (i32.eq + (i32.load8_u + (get_local $2) + ) + (i32.and + (get_local $4) + (i32.const 255) + ) + ) + (block + (set_local $0 + (get_local $3) + ) + (br $__rjti$2) + ) + ) + (br_if $while-in + (i32.and + (tee_local $0 + (i32.ne + (tee_local $3 + (i32.add + (get_local $3) + (i32.const -1) + ) + ) + (i32.const 0) + ) + ) + (i32.ne + (i32.and + (tee_local $2 + (i32.add + (get_local $2) + (i32.const 1) + ) + ) + (i32.const 3) + ) + (i32.const 0) + ) + ) + ) + ) + ) + (block + (set_local $3 + (get_local $2) + ) + (set_local $2 + (get_local $0) + ) + (set_local $0 + (get_local $4) + ) + ) + ) + (if + (get_local $0) + (block + (set_local $0 + (get_local $3) + ) + (br $__rjti$2) + ) + (set_local $0 + (i32.const 0) + ) + ) + (br $label$break$L8) + ) + (if + (i32.ne + (i32.load8_u + (get_local $2) + ) + (tee_local $1 + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + ) + (block + (set_local $3 + (i32.mul + (get_local $5) + (i32.const 16843009) + ) + ) + (block $__rjto$0 + (block $__rjti$0 + (br_if $__rjti$0 + (i32.le_u + (get_local $0) + (i32.const 3) + ) + ) + (loop $while-in3 + (if + (i32.eqz + (i32.and + (i32.xor + (i32.and + (tee_local $4 + (i32.xor + (i32.load + (get_local $2) + ) + (get_local $3) + ) + ) + (i32.const -2139062144) + ) + (i32.const -2139062144) + ) + (i32.add + (get_local $4) + (i32.const -16843009) + ) + ) + ) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) + ) + (br_if $while-in3 + (i32.gt_u + (tee_local $0 + (i32.add + (get_local $0) + (i32.const -4) + ) + ) + (i32.const 3) + ) + ) + (br $__rjti$0) + ) + ) + ) + (br $__rjto$0) + ) + (if + (i32.eqz + (get_local $0) + ) + (block + (set_local $0 + (i32.const 0) + ) + (br $label$break$L8) + ) + ) + ) + (loop $while-in5 + (br_if $label$break$L8 + (i32.eq + (i32.load8_u + (get_local $2) + ) + (i32.and + (get_local $1) + (i32.const 255) + ) + ) + ) + (set_local $2 + (i32.add + (get_local $2) + (i32.const 1) + ) + ) + (br_if $while-in5 + (tee_local $0 + (i32.add + (get_local $0) + (i32.const -1) + ) + ) + ) + (set_local $0 + (i32.const 0) + ) + ) + ) + ) + ) + (select + (get_local $2) + (i32.const 0) + (get_local $0) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -325,6 +644,18 @@ (i32.const 0) (i32.const 0) ) + (drop + (call $_memchr + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (drop + (call $switch64TOOMUCH + (i64.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 2ab7a85ca..5bdb5bc00 100644 --- a/test/wasm-only.fromasm.imprecise.no-opts +++ b/test/wasm-only.fromasm.imprecise.no-opts @@ -6,6 +6,7 @@ (type $legaltype$illegalImportResult (func (result i32))) (type $legaltype$_fabsf (func (param f64) (result f64))) (type $legaltype$do_i64 (func (result i32))) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) (import "env" "illegalImport" (func $illegalImport (param f64 i64 i32))) (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "_fabsf" (func $_fabsf (param f32) (result f32))) @@ -18,6 +19,7 @@ (import "env" "table" (table 3 3 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) + (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) (global $tempRet0 (mut i32) (i32.const 0)) (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64) (export "test64" (func $test64)) @@ -889,6 +891,584 @@ (i32.const 44) ) ) + (func $_memchr (param $$src i32) (param $$c i32) (param $$n i32) (result i32) + (local $$0 i32) + (local $$1 i32) + (local $$2 i32) + (local $$3 i32) + (local $$4 i32) + (local $$5 i32) + (local $$6 i32) + (local $$7 i32) + (local $$and i32) + (local $$and15 i32) + (local $$and16 i32) + (local $$and39 i32) + (local $$cmp i32) + (local $$cmp11 i32) + (local $$cmp1132 i32) + (local $$cmp28 i32) + (local $$cmp8 i32) + (local $$cond i32) + (local $$conv1 i32) + (local $$dec i32) + (local $$dec34 i32) + (local $$incdec$ptr i32) + (local $$incdec$ptr21 i32) + (local $$incdec$ptr33 i32) + (local $$lnot i32) + (local $$mul i32) + (local $$n$addr$0$lcssa i32) + (local $$n$addr$0$lcssa52 i32) + (local $$n$addr$043 i32) + (local $$n$addr$1$lcssa i32) + (local $$n$addr$133 i32) + (local $$n$addr$227 i32) + (local $$n$addr$3 i32) + (local $$neg i32) + (local $$or$cond i32) + (local $$or$cond42 i32) + (local $$s$0$lcssa i32) + (local $$s$0$lcssa53 i32) + (local $$s$044 i32) + (local $$s$128 i32) + (local $$s$2 i32) + (local $$sub i32) + (local $$sub22 i32) + (local $$tobool i32) + (local $$tobool2 i32) + (local $$tobool2$lcssa i32) + (local $$tobool241 i32) + (local $$tobool25 i32) + (local $$tobool2526 i32) + (local $$tobool36 i32) + (local $$tobool40 i32) + (local $$w$0$lcssa i32) + (local $$w$034 i32) + (local $$xor i32) + (local $label i32) + (local $sp i32) + (set_local $sp + (get_global $STACKTOP) + ) + (set_local $$conv1 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$0 + (get_local $$src) + ) + (set_local $$and39 + (i32.and + (get_local $$0) + (i32.const 3) + ) + ) + (set_local $$tobool40 + (i32.ne + (get_local $$and39) + (i32.const 0) + ) + ) + (set_local $$tobool241 + (i32.ne + (get_local $$n) + (i32.const 0) + ) + ) + (set_local $$or$cond42 + (i32.and + (get_local $$tobool241) + (get_local $$tobool40) + ) + ) + (block $label$break$L1 + (if + (get_local $$or$cond42) + (block + (set_local $$1 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$n$addr$043 + (get_local $$n) + ) + (set_local $$s$044 + (get_local $$src) + ) + (loop $while-in + (block $while-out + (set_local $$2 + (i32.load8_s + (get_local $$s$044) + ) + ) + (set_local $$cmp + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$2) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$1) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp) + (block + (set_local $$n$addr$0$lcssa52 + (get_local $$n$addr$043) + ) + (set_local $$s$0$lcssa53 + (get_local $$s$044) + ) + (set_local $label + (i32.const 6) + ) + (br $label$break$L1) + ) + ) + (set_local $$incdec$ptr + (i32.add + (get_local $$s$044) + (i32.const 1) + ) + ) + (set_local $$dec + (i32.add + (get_local $$n$addr$043) + (i32.const -1) + ) + ) + (set_local $$3 + (get_local $$incdec$ptr) + ) + (set_local $$and + (i32.and + (get_local $$3) + (i32.const 3) + ) + ) + (set_local $$tobool + (i32.ne + (get_local $$and) + (i32.const 0) + ) + ) + (set_local $$tobool2 + (i32.ne + (get_local $$dec) + (i32.const 0) + ) + ) + (set_local $$or$cond + (i32.and + (get_local $$tobool2) + (get_local $$tobool) + ) + ) + (if + (get_local $$or$cond) + (block + (set_local $$n$addr$043 + (get_local $$dec) + ) + (set_local $$s$044 + (get_local $$incdec$ptr) + ) + ) + (block + (set_local $$n$addr$0$lcssa + (get_local $$dec) + ) + (set_local $$s$0$lcssa + (get_local $$incdec$ptr) + ) + (set_local $$tobool2$lcssa + (get_local $$tobool2) + ) + (set_local $label + (i32.const 5) + ) + (br $while-out) + ) + ) + (br $while-in) + ) + ) + ) + (block + (set_local $$n$addr$0$lcssa + (get_local $$n) + ) + (set_local $$s$0$lcssa + (get_local $$src) + ) + (set_local $$tobool2$lcssa + (get_local $$tobool241) + ) + (set_local $label + (i32.const 5) + ) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 5) + ) + (if + (get_local $$tobool2$lcssa) + (block + (set_local $$n$addr$0$lcssa52 + (get_local $$n$addr$0$lcssa) + ) + (set_local $$s$0$lcssa53 + (get_local $$s$0$lcssa) + ) + (set_local $label + (i32.const 6) + ) + ) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$s$0$lcssa) + ) + ) + ) + ) + (block $label$break$L8 + (if + (i32.eq + (get_local $label) + (i32.const 6) + ) + (block + (set_local $$4 + (i32.load8_s + (get_local $$s$0$lcssa53) + ) + ) + (set_local $$5 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$cmp8 + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$4) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$5) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp8) + (block + (set_local $$n$addr$3 + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$s$2 + (get_local $$s$0$lcssa53) + ) + ) + (block + (set_local $$mul + (i32.mul + (get_local $$conv1) + (i32.const 16843009) + ) + ) + (set_local $$cmp1132 + (i32.gt_u + (get_local $$n$addr$0$lcssa52) + (i32.const 3) + ) + ) + (block $label$break$L11 + (if + (get_local $$cmp1132) + (block + (set_local $$n$addr$133 + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$w$034 + (get_local $$s$0$lcssa53) + ) + (loop $while-in3 + (block $while-out2 + (set_local $$6 + (i32.load + (get_local $$w$034) + ) + ) + (set_local $$xor + (i32.xor + (get_local $$6) + (get_local $$mul) + ) + ) + (set_local $$sub + (i32.add + (get_local $$xor) + (i32.const -16843009) + ) + ) + (set_local $$neg + (i32.and + (get_local $$xor) + (i32.const -2139062144) + ) + ) + (set_local $$and15 + (i32.xor + (get_local $$neg) + (i32.const -2139062144) + ) + ) + (set_local $$and16 + (i32.and + (get_local $$and15) + (get_local $$sub) + ) + ) + (set_local $$lnot + (i32.eq + (get_local $$and16) + (i32.const 0) + ) + ) + (if + (i32.eqz + (get_local $$lnot) + ) + (br $while-out2) + ) + (set_local $$incdec$ptr21 + (i32.add + (get_local $$w$034) + (i32.const 4) + ) + ) + (set_local $$sub22 + (i32.add + (get_local $$n$addr$133) + (i32.const -4) + ) + ) + (set_local $$cmp11 + (i32.gt_u + (get_local $$sub22) + (i32.const 3) + ) + ) + (if + (get_local $$cmp11) + (block + (set_local $$n$addr$133 + (get_local $$sub22) + ) + (set_local $$w$034 + (get_local $$incdec$ptr21) + ) + ) + (block + (set_local $$n$addr$1$lcssa + (get_local $$sub22) + ) + (set_local $$w$0$lcssa + (get_local $$incdec$ptr21) + ) + (set_local $label + (i32.const 11) + ) + (br $label$break$L11) + ) + ) + (br $while-in3) + ) + ) + (set_local $$n$addr$227 + (get_local $$n$addr$133) + ) + (set_local $$s$128 + (get_local $$w$034) + ) + ) + (block + (set_local $$n$addr$1$lcssa + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$w$0$lcssa + (get_local $$s$0$lcssa53) + ) + (set_local $label + (i32.const 11) + ) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 11) + ) + (block + (set_local $$tobool2526 + (i32.eq + (get_local $$n$addr$1$lcssa) + (i32.const 0) + ) + ) + (if + (get_local $$tobool2526) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$w$0$lcssa) + ) + (br $label$break$L8) + ) + (block + (set_local $$n$addr$227 + (get_local $$n$addr$1$lcssa) + ) + (set_local $$s$128 + (get_local $$w$0$lcssa) + ) + ) + ) + ) + ) + (loop $while-in5 + (block $while-out4 + (set_local $$7 + (i32.load8_s + (get_local $$s$128) + ) + ) + (set_local $$cmp28 + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$7) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$5) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp28) + (block + (set_local $$n$addr$3 + (get_local $$n$addr$227) + ) + (set_local $$s$2 + (get_local $$s$128) + ) + (br $label$break$L8) + ) + ) + (set_local $$incdec$ptr33 + (i32.add + (get_local $$s$128) + (i32.const 1) + ) + ) + (set_local $$dec34 + (i32.add + (get_local $$n$addr$227) + (i32.const -1) + ) + ) + (set_local $$tobool25 + (i32.eq + (get_local $$dec34) + (i32.const 0) + ) + ) + (if + (get_local $$tobool25) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$incdec$ptr33) + ) + (br $while-out4) + ) + (block + (set_local $$n$addr$227 + (get_local $$dec34) + ) + (set_local $$s$128 + (get_local $$incdec$ptr33) + ) + ) + ) + (br $while-in5) + ) + ) + ) + ) + ) + ) + ) + (set_local $$tobool36 + (i32.ne + (get_local $$n$addr$3) + (i32.const 0) + ) + ) + (set_local $$cond + (if i32 + (get_local $$tobool36) + (get_local $$s$2) + (i32.const 0) + ) + ) + (return + (get_local $$cond) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -934,6 +1514,18 @@ (i32.const 0) (i32.const 0) ) + (drop + (call $_memchr + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (drop + (call $switch64TOOMUCH + (i64.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 3bcbf33d5..da52d1955 100644 --- a/test/wasm-only.fromasm.no-opts +++ b/test/wasm-only.fromasm.no-opts @@ -6,6 +6,7 @@ (type $legaltype$illegalImportResult (func (result i32))) (type $legaltype$_fabsf (func (param f64) (result f64))) (type $legaltype$do_i64 (func (result i32))) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) (import "env" "illegalImport" (func $illegalImport (param f64 i64 i32))) (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "_fabsf" (func $_fabsf (param f32) (result f32))) @@ -18,6 +19,7 @@ (import "env" "table" (table 3 3 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) + (global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) (global $tempRet0 (mut i32) (i32.const 0)) (elem (get_global $tableBase) $legalfunc$illegalImport $legalfunc$_fabsf $legalfunc$do_i64) (export "test64" (func $test64)) @@ -950,6 +952,584 @@ (i32.const 44) ) ) + (func $_memchr (param $$src i32) (param $$c i32) (param $$n i32) (result i32) + (local $$0 i32) + (local $$1 i32) + (local $$2 i32) + (local $$3 i32) + (local $$4 i32) + (local $$5 i32) + (local $$6 i32) + (local $$7 i32) + (local $$and i32) + (local $$and15 i32) + (local $$and16 i32) + (local $$and39 i32) + (local $$cmp i32) + (local $$cmp11 i32) + (local $$cmp1132 i32) + (local $$cmp28 i32) + (local $$cmp8 i32) + (local $$cond i32) + (local $$conv1 i32) + (local $$dec i32) + (local $$dec34 i32) + (local $$incdec$ptr i32) + (local $$incdec$ptr21 i32) + (local $$incdec$ptr33 i32) + (local $$lnot i32) + (local $$mul i32) + (local $$n$addr$0$lcssa i32) + (local $$n$addr$0$lcssa52 i32) + (local $$n$addr$043 i32) + (local $$n$addr$1$lcssa i32) + (local $$n$addr$133 i32) + (local $$n$addr$227 i32) + (local $$n$addr$3 i32) + (local $$neg i32) + (local $$or$cond i32) + (local $$or$cond42 i32) + (local $$s$0$lcssa i32) + (local $$s$0$lcssa53 i32) + (local $$s$044 i32) + (local $$s$128 i32) + (local $$s$2 i32) + (local $$sub i32) + (local $$sub22 i32) + (local $$tobool i32) + (local $$tobool2 i32) + (local $$tobool2$lcssa i32) + (local $$tobool241 i32) + (local $$tobool25 i32) + (local $$tobool2526 i32) + (local $$tobool36 i32) + (local $$tobool40 i32) + (local $$w$0$lcssa i32) + (local $$w$034 i32) + (local $$xor i32) + (local $label i32) + (local $sp i32) + (set_local $sp + (get_global $STACKTOP) + ) + (set_local $$conv1 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$0 + (get_local $$src) + ) + (set_local $$and39 + (i32.and + (get_local $$0) + (i32.const 3) + ) + ) + (set_local $$tobool40 + (i32.ne + (get_local $$and39) + (i32.const 0) + ) + ) + (set_local $$tobool241 + (i32.ne + (get_local $$n) + (i32.const 0) + ) + ) + (set_local $$or$cond42 + (i32.and + (get_local $$tobool241) + (get_local $$tobool40) + ) + ) + (block $label$break$L1 + (if + (get_local $$or$cond42) + (block + (set_local $$1 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$n$addr$043 + (get_local $$n) + ) + (set_local $$s$044 + (get_local $$src) + ) + (loop $while-in + (block $while-out + (set_local $$2 + (i32.load8_s + (get_local $$s$044) + ) + ) + (set_local $$cmp + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$2) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$1) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp) + (block + (set_local $$n$addr$0$lcssa52 + (get_local $$n$addr$043) + ) + (set_local $$s$0$lcssa53 + (get_local $$s$044) + ) + (set_local $label + (i32.const 6) + ) + (br $label$break$L1) + ) + ) + (set_local $$incdec$ptr + (i32.add + (get_local $$s$044) + (i32.const 1) + ) + ) + (set_local $$dec + (i32.add + (get_local $$n$addr$043) + (i32.const -1) + ) + ) + (set_local $$3 + (get_local $$incdec$ptr) + ) + (set_local $$and + (i32.and + (get_local $$3) + (i32.const 3) + ) + ) + (set_local $$tobool + (i32.ne + (get_local $$and) + (i32.const 0) + ) + ) + (set_local $$tobool2 + (i32.ne + (get_local $$dec) + (i32.const 0) + ) + ) + (set_local $$or$cond + (i32.and + (get_local $$tobool2) + (get_local $$tobool) + ) + ) + (if + (get_local $$or$cond) + (block + (set_local $$n$addr$043 + (get_local $$dec) + ) + (set_local $$s$044 + (get_local $$incdec$ptr) + ) + ) + (block + (set_local $$n$addr$0$lcssa + (get_local $$dec) + ) + (set_local $$s$0$lcssa + (get_local $$incdec$ptr) + ) + (set_local $$tobool2$lcssa + (get_local $$tobool2) + ) + (set_local $label + (i32.const 5) + ) + (br $while-out) + ) + ) + (br $while-in) + ) + ) + ) + (block + (set_local $$n$addr$0$lcssa + (get_local $$n) + ) + (set_local $$s$0$lcssa + (get_local $$src) + ) + (set_local $$tobool2$lcssa + (get_local $$tobool241) + ) + (set_local $label + (i32.const 5) + ) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 5) + ) + (if + (get_local $$tobool2$lcssa) + (block + (set_local $$n$addr$0$lcssa52 + (get_local $$n$addr$0$lcssa) + ) + (set_local $$s$0$lcssa53 + (get_local $$s$0$lcssa) + ) + (set_local $label + (i32.const 6) + ) + ) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$s$0$lcssa) + ) + ) + ) + ) + (block $label$break$L8 + (if + (i32.eq + (get_local $label) + (i32.const 6) + ) + (block + (set_local $$4 + (i32.load8_s + (get_local $$s$0$lcssa53) + ) + ) + (set_local $$5 + (i32.and + (get_local $$c) + (i32.const 255) + ) + ) + (set_local $$cmp8 + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$4) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$5) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp8) + (block + (set_local $$n$addr$3 + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$s$2 + (get_local $$s$0$lcssa53) + ) + ) + (block + (set_local $$mul + (i32.mul + (get_local $$conv1) + (i32.const 16843009) + ) + ) + (set_local $$cmp1132 + (i32.gt_u + (get_local $$n$addr$0$lcssa52) + (i32.const 3) + ) + ) + (block $label$break$L11 + (if + (get_local $$cmp1132) + (block + (set_local $$n$addr$133 + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$w$034 + (get_local $$s$0$lcssa53) + ) + (loop $while-in3 + (block $while-out2 + (set_local $$6 + (i32.load + (get_local $$w$034) + ) + ) + (set_local $$xor + (i32.xor + (get_local $$6) + (get_local $$mul) + ) + ) + (set_local $$sub + (i32.add + (get_local $$xor) + (i32.const -16843009) + ) + ) + (set_local $$neg + (i32.and + (get_local $$xor) + (i32.const -2139062144) + ) + ) + (set_local $$and15 + (i32.xor + (get_local $$neg) + (i32.const -2139062144) + ) + ) + (set_local $$and16 + (i32.and + (get_local $$and15) + (get_local $$sub) + ) + ) + (set_local $$lnot + (i32.eq + (get_local $$and16) + (i32.const 0) + ) + ) + (if + (i32.eqz + (get_local $$lnot) + ) + (br $while-out2) + ) + (set_local $$incdec$ptr21 + (i32.add + (get_local $$w$034) + (i32.const 4) + ) + ) + (set_local $$sub22 + (i32.add + (get_local $$n$addr$133) + (i32.const -4) + ) + ) + (set_local $$cmp11 + (i32.gt_u + (get_local $$sub22) + (i32.const 3) + ) + ) + (if + (get_local $$cmp11) + (block + (set_local $$n$addr$133 + (get_local $$sub22) + ) + (set_local $$w$034 + (get_local $$incdec$ptr21) + ) + ) + (block + (set_local $$n$addr$1$lcssa + (get_local $$sub22) + ) + (set_local $$w$0$lcssa + (get_local $$incdec$ptr21) + ) + (set_local $label + (i32.const 11) + ) + (br $label$break$L11) + ) + ) + (br $while-in3) + ) + ) + (set_local $$n$addr$227 + (get_local $$n$addr$133) + ) + (set_local $$s$128 + (get_local $$w$034) + ) + ) + (block + (set_local $$n$addr$1$lcssa + (get_local $$n$addr$0$lcssa52) + ) + (set_local $$w$0$lcssa + (get_local $$s$0$lcssa53) + ) + (set_local $label + (i32.const 11) + ) + ) + ) + ) + (if + (i32.eq + (get_local $label) + (i32.const 11) + ) + (block + (set_local $$tobool2526 + (i32.eq + (get_local $$n$addr$1$lcssa) + (i32.const 0) + ) + ) + (if + (get_local $$tobool2526) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$w$0$lcssa) + ) + (br $label$break$L8) + ) + (block + (set_local $$n$addr$227 + (get_local $$n$addr$1$lcssa) + ) + (set_local $$s$128 + (get_local $$w$0$lcssa) + ) + ) + ) + ) + ) + (loop $while-in5 + (block $while-out4 + (set_local $$7 + (i32.load8_s + (get_local $$s$128) + ) + ) + (set_local $$cmp28 + (i32.eq + (i32.shr_s + (i32.shl + (get_local $$7) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.shr_s + (i32.shl + (get_local $$5) + (i32.const 24) + ) + (i32.const 24) + ) + ) + ) + (if + (get_local $$cmp28) + (block + (set_local $$n$addr$3 + (get_local $$n$addr$227) + ) + (set_local $$s$2 + (get_local $$s$128) + ) + (br $label$break$L8) + ) + ) + (set_local $$incdec$ptr33 + (i32.add + (get_local $$s$128) + (i32.const 1) + ) + ) + (set_local $$dec34 + (i32.add + (get_local $$n$addr$227) + (i32.const -1) + ) + ) + (set_local $$tobool25 + (i32.eq + (get_local $$dec34) + (i32.const 0) + ) + ) + (if + (get_local $$tobool25) + (block + (set_local $$n$addr$3 + (i32.const 0) + ) + (set_local $$s$2 + (get_local $$incdec$ptr33) + ) + (br $while-out4) + ) + (block + (set_local $$n$addr$227 + (get_local $$dec34) + ) + (set_local $$s$128 + (get_local $$incdec$ptr33) + ) + ) + ) + (br $while-in5) + ) + ) + ) + ) + ) + ) + ) + (set_local $$tobool36 + (i32.ne + (get_local $$n$addr$3) + (i32.const 0) + ) + ) + (set_local $$cond + (if i32 + (get_local $$tobool36) + (get_local $$s$2) + (i32.const 0) + ) + ) + (return + (get_local $$cond) + ) + ) (func $keepAlive (call $loads) (call $stores) @@ -995,6 +1575,18 @@ (i32.const 0) (i32.const 0) ) + (drop + (call $_memchr + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + ) + (drop + (call $switch64TOOMUCH + (i64.const 0) + ) + ) ) (func $__emscripten_dceable_type_decls (drop |