diff options
author | Thomas Lively <tlively@google.com> | 2023-10-18 20:37:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-18 18:37:48 +0000 |
commit | f50e933f639c24f3a5814980fb20e6f7e1435184 (patch) | |
tree | c118bfbfbb54a5c0e1879af650131503ad59bd97 /test | |
parent | 89c02aad305474aea1d413e110aadd68278a13d6 (diff) | |
download | binaryen-f50e933f639c24f3a5814980fb20e6f7e1435184.tar.gz binaryen-f50e933f639c24f3a5814980fb20e6f7e1435184.tar.bz2 binaryen-f50e933f639c24f3a5814980fb20e6f7e1435184.zip |
Reuse existing function types for blocks (#6022)
Type annotations on multivalue blocks (and loops, ifs, and trys) are type
indices that refer to function types in the type section. For these type
annotations, the identities of the function types does not matter. As long as
the referenced type has the correct parameters and results, it will be valid to
use.
Previously, when collecting module types, we always used the "default" function
type for multivalue control flow, i.e. we used a final function type with no
supertypes in a singleton rec group. However, in cases where the program already
contains another function type with the expected signature, using the default
type is unnecessary and bloats the type section.
Update the type collecting code to reuse existing function types for multivalue
control flow where possible rather than unconditionally adding the default
function type. Similarly, update the binary writer to use the first heap type
with the required signature when emitting annotations on multivalue control flow
structures. To make this all testable, update the printer to print the type
annotations as well, rather than just the result types. Since the parser was not
able to parse those newly emitted type annotations, update the parser as well.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/blocktype.wast | 99 | ||||
-rw-r--r-- | test/lit/multivalue.wast | 14 | ||||
-rw-r--r-- | test/lit/passes/coalesce-locals-gc.wast | 10 | ||||
-rw-r--r-- | test/lit/passes/optimize-instructions-multivalue.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/poppify.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/remove-unused-brs.wast | 6 | ||||
-rw-r--r-- | test/lit/passes/roundtrip.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/tuple-optimization.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/type-merging.wast | 6 | ||||
-rw-r--r-- | test/lit/types-function-references.wast | 62 | ||||
-rw-r--r-- | test/lit/wat-kitchen-sink.wast | 14 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_enable-multivalue.txt | 8 |
12 files changed, 161 insertions, 66 deletions
diff --git a/test/lit/blocktype.wast b/test/lit/blocktype.wast new file mode 100644 index 000000000..61eba4868 --- /dev/null +++ b/test/lit/blocktype.wast @@ -0,0 +1,99 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + +;; RUN: wasm-opt %s -all -S -o - | filecheck %s +;; RUN: wasm-opt %s -all --roundtrip -g -S -o - | filecheck %s --check-prefix=RTRIP + +(module + (rec + ;; CHECK: (rec + ;; CHECK-NEXT: (type $f1 (func (result (ref $f1) (ref $f2)))) + ;; RTRIP: (rec + ;; RTRIP-NEXT: (type $f1 (func (result (ref $f1) (ref $f2)))) + (type $f1 (func (result (ref $f1) (ref $f2)))) + ;; CHECK: (type $f2 (func (result (ref $f2) (ref $f1)))) + ;; RTRIP: (type $f2 (func (result (ref $f2) (ref $f1)))) + (type $f2 (func (result (ref $f2) (ref $f1)))) + ) + + ;; These types will be optimized out. + (type $block1 (func (result (ref $f1) (ref $f2)))) + (type $block2 (func (result (ref $f2) (ref $f1)))) + + ;; CHECK: (func $f1 (type $f1) (result (ref $f1) (ref $f2)) + ;; CHECK-NEXT: (loop $l (type $f1) (result (ref $f1) (ref $f2)) + ;; CHECK-NEXT: (call $f1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $f1 (type $f1) (result (ref $f1) (ref $f2)) + ;; RTRIP-NEXT: (local $0 ((ref $f1) (ref $f2))) + ;; RTRIP-NEXT: (local $1 ((ref $f1) (ref $f2))) + ;; RTRIP-NEXT: (local.set $1 + ;; RTRIP-NEXT: (loop $label$1 (type $f1) (result (ref $f1) (ref $f2)) + ;; RTRIP-NEXT: (local.set $0 + ;; RTRIP-NEXT: (call $f1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.make + ;; RTRIP-NEXT: (tuple.extract 0 + ;; RTRIP-NEXT: (local.get $0) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.extract 1 + ;; RTRIP-NEXT: (local.get $0) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.make + ;; RTRIP-NEXT: (tuple.extract 0 + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.extract 1 + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + (func $f1 (type $f1) (result (ref $f1) (ref $f2)) + ;; This block will be emitted with type $f1 + (loop $l (type $block1) (result (ref $f1) (ref $f2)) + (call $f1) + ) + ) + + ;; CHECK: (func $f2 (type $f2) (result (ref $f2) (ref $f1)) + ;; CHECK-NEXT: (loop $l (type $f2) (result (ref $f2) (ref $f1)) + ;; CHECK-NEXT: (call $f2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; RTRIP: (func $f2 (type $f2) (result (ref $f2) (ref $f1)) + ;; RTRIP-NEXT: (local $0 ((ref $f2) (ref $f1))) + ;; RTRIP-NEXT: (local $1 ((ref $f2) (ref $f1))) + ;; RTRIP-NEXT: (local.set $1 + ;; RTRIP-NEXT: (loop $label$1 (type $f2) (result (ref $f2) (ref $f1)) + ;; RTRIP-NEXT: (local.set $0 + ;; RTRIP-NEXT: (call $f2) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.make + ;; RTRIP-NEXT: (tuple.extract 0 + ;; RTRIP-NEXT: (local.get $0) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.extract 1 + ;; RTRIP-NEXT: (local.get $0) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.make + ;; RTRIP-NEXT: (tuple.extract 0 + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: (tuple.extract 1 + ;; RTRIP-NEXT: (local.get $1) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + ;; RTRIP-NEXT: ) + (func $f2 (type $f2) (result (ref $f2) (ref $f1)) + ;; This block will be emitted with type $f2 + (loop $l (type $block2) (result (ref $f2) (ref $f1)) + (call $f2) + ) + ) +) diff --git a/test/lit/multivalue.wast b/test/lit/multivalue.wast index 0d52f5382..a4b5c6b7e 100644 --- a/test/lit/multivalue.wast +++ b/test/lit/multivalue.wast @@ -320,7 +320,7 @@ ;; CHECK-NEXT: (local $0 (i32 i64)) ;; CHECK-NEXT: (local $1 i32) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (block $label$1 (result i32 i64) + ;; CHECK-NEXT: (block $label$1 (type $0) (result i32 i64) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: (i64.const 42) @@ -394,7 +394,7 @@ ;; CHECK: (func $mv-block-break (type $0) (result i32 i64) ;; CHECK-NEXT: (local $0 (i32 i64)) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (block $label$1 (result i32 i64) + ;; CHECK-NEXT: (block $label$1 (type $0) (result i32 i64) ;; CHECK-NEXT: (br $label$1 ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 42) @@ -427,7 +427,7 @@ ;; CHECK-NEXT: (local $0 (i32 i64)) ;; CHECK-NEXT: (local $1 (i32 i64)) ;; CHECK-NEXT: (local.set $1 - ;; CHECK-NEXT: (block $label$1 (result i32 i64) + ;; CHECK-NEXT: (block $label$1 (type $0) (result i32 i64) ;; CHECK-NEXT: (local.set $0 ;; CHECK-NEXT: (br_if $label$1 ;; CHECK-NEXT: (tuple.make @@ -471,7 +471,7 @@ ;; CHECK: (func $mv-if (type $2) (result i32 i64 externref) ;; CHECK-NEXT: (local $0 (i32 i64 externref)) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (if (result i32 i64 externref) + ;; CHECK-NEXT: (if (type $2) (result i32 i64 externref) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 42) @@ -516,7 +516,7 @@ ;; CHECK: (func $mv-loop (type $0) (result i32 i64) ;; CHECK-NEXT: (local $0 (i32 i64)) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (loop $label$1 (result i32 i64) + ;; CHECK-NEXT: (loop $label$1 (type $0) (result i32 i64) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: (i64.const 42) @@ -545,9 +545,9 @@ ;; CHECK-NEXT: (local $0 (i32 i64)) ;; CHECK-NEXT: (local $1 (i32 i64)) ;; CHECK-NEXT: (local.set $1 - ;; CHECK-NEXT: (block $label$1 (result i32 i64) + ;; CHECK-NEXT: (block $label$1 (type $0) (result i32 i64) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (block $label$2 (result i32 i64) + ;; CHECK-NEXT: (block $label$2 (type $0) (result i32 i64) ;; CHECK-NEXT: (br_table $label$1 $label$2 ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 42) diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index 3706dc61f..5122fc23b 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -79,7 +79,7 @@ ) ) - ;; CHECK: (func $nn-dead (type $2) + ;; CHECK: (func $nn-dead (type $3) ;; CHECK-NEXT: (local $0 funcref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.func $nn-dead) @@ -118,7 +118,7 @@ ) ) - ;; CHECK: (func $nn-dead-nameless (type $2) + ;; CHECK: (func $nn-dead-nameless (type $3) ;; CHECK-NEXT: (local $0 (ref func)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.func $nn-dead) @@ -149,7 +149,7 @@ ) ) - ;; CHECK: (func $unreachable-get-null (type $2) + ;; CHECK: (func $unreachable-get-null (type $3) ;; CHECK-NEXT: (local $0 anyref) ;; CHECK-NEXT: (local $1 i31ref) ;; CHECK-NEXT: (unreachable) @@ -307,9 +307,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $nn-tuple-global - ;; CHECK-NEXT: (block (result (ref any) i32) + ;; CHECK-NEXT: (block (type $1) (result (ref any) i32) ;; CHECK-NEXT: (local.set $1 - ;; CHECK-NEXT: (if (result (ref any) i32) + ;; CHECK-NEXT: (if (type $1) (result (ref any) i32) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (ref.as_non_null diff --git a/test/lit/passes/optimize-instructions-multivalue.wast b/test/lit/passes/optimize-instructions-multivalue.wast index 0e7938417..1e456f20f 100644 --- a/test/lit/passes/optimize-instructions-multivalue.wast +++ b/test/lit/passes/optimize-instructions-multivalue.wast @@ -6,7 +6,7 @@ ;; CHECK-NEXT: (local $tuple (i32 i32)) ;; CHECK-NEXT: (local $tuple2 (i32 i32)) ;; CHECK-NEXT: (tuple.extract 0 - ;; CHECK-NEXT: (if (result i32 i32) + ;; CHECK-NEXT: (if (type $2) (result i32 i32) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (local.get $tuple) ;; CHECK-NEXT: (local.get $tuple2) diff --git a/test/lit/passes/poppify.wast b/test/lit/passes/poppify.wast index 9432cbd28..4aa44a3d5 100644 --- a/test/lit/passes/poppify.wast +++ b/test/lit/passes/poppify.wast @@ -466,7 +466,7 @@ ) ;; CHECK: (func $break-tuple (type $1) (result i32 i64) - ;; CHECK-NEXT: (block $l (result i32 i64) + ;; CHECK-NEXT: (block $l (type $1) (result i32 i64) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i64.const 1) ;; CHECK-NEXT: (br $l diff --git a/test/lit/passes/remove-unused-brs.wast b/test/lit/passes/remove-unused-brs.wast index 93cf4cbd2..8392dfe86 100644 --- a/test/lit/passes/remove-unused-brs.wast +++ b/test/lit/passes/remove-unused-brs.wast @@ -5,7 +5,7 @@ (module ;; Regression test in which we need to calculate a proper LUB. - ;; CHECK: (func $selectify-fresh-lub (type $2) (param $x i32) (result anyref) + ;; CHECK: (func $selectify-fresh-lub (type $3) (param $x i32) (result anyref) ;; CHECK-NEXT: (select (result i31ref) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (ref.i31 @@ -211,7 +211,7 @@ ) ) - ;; CHECK: (func $get-i32 (type $3) (result i32) + ;; CHECK: (func $get-i32 (type $4) (result i32) ;; CHECK-NEXT: (i32.const 400) ;; CHECK-NEXT: ) (func $get-i32 (result i32) @@ -327,7 +327,7 @@ ;; CHECK: (func $restructure-select-no-multivalue (type $1) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $block (result i32 i32) + ;; CHECK-NEXT: (block $block (type $2) (result i32 i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br_if $block ;; CHECK-NEXT: (tuple.make diff --git a/test/lit/passes/roundtrip.wast b/test/lit/passes/roundtrip.wast index f41761c2e..2f3fd4009 100644 --- a/test/lit/passes/roundtrip.wast +++ b/test/lit/passes/roundtrip.wast @@ -8,7 +8,7 @@ ;; CHECK-NEXT: (local $0 (funcref (ref $none))) ;; CHECK-NEXT: (local $1 funcref) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (block $label$1 (result funcref (ref $none)) + ;; CHECK-NEXT: (block $label$1 (type $1) (result funcref (ref $none)) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (ref.null nofunc) ;; CHECK-NEXT: (ref.func $foo) diff --git a/test/lit/passes/tuple-optimization.wast b/test/lit/passes/tuple-optimization.wast index 766f51e81..6884f95c5 100644 --- a/test/lit/passes/tuple-optimization.wast +++ b/test/lit/passes/tuple-optimization.wast @@ -546,7 +546,7 @@ ;; CHECK: (func $set-of-block (type $0) ;; CHECK-NEXT: (local $tuple (i32 i32)) ;; CHECK-NEXT: (local.set $tuple - ;; CHECK-NEXT: (block (result i32 i32) + ;; CHECK-NEXT: (block (type $1) (result i32 i32) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.const 2) diff --git a/test/lit/passes/type-merging.wast b/test/lit/passes/type-merging.wast index 7c44fe8e2..34f156a2b 100644 --- a/test/lit/passes/type-merging.wast +++ b/test/lit/passes/type-merging.wast @@ -929,8 +929,6 @@ ;; CHECK: (rec ;; CHECK-NEXT: (type $B (sub (func))) - ;; CHECK: (type $1 (func (result (ref any) (ref $B)))) - ;; CHECK: (type $A (sub (func (result (ref any) (ref $B))))) (type $A (sub (func (result (ref any) (ref $C))))) (type $B (sub (func))) @@ -939,10 +937,8 @@ (type $D (sub final $A (func (result (ref any) (ref $C))))) ) - ;; CHECK: (type $4 (func (result (ref any) (ref $B)))) - ;; CHECK: (func $test (type $D) (result (ref any) (ref $B)) - ;; CHECK-NEXT: (block $l (result (ref any) (ref $B)) + ;; CHECK-NEXT: (block $l (type $A) (result (ref any) (ref $B)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/types-function-references.wast b/test/lit/types-function-references.wast index c5f250f34..9479c93b3 100644 --- a/test/lit/types-function-references.wast +++ b/test/lit/types-function-references.wast @@ -22,22 +22,26 @@ (type $_=>_eqref (func (result eqref))) ;; CHECK-BINARY: (type $i32-i32 (func (param i32) (result i32))) - ;; CHECK-BINARY: (type $3 (func (param (ref $i32-i32)) (result i32))) + ;; CHECK-BINARY: (type $3 (func (result i32 (ref null $mixed_results) f64))) - ;; CHECK-BINARY: (type $4 (func (param (ref null $i32-i32)) (result i32))) + ;; CHECK-BINARY: (type $4 (func (param (ref $i32-i32)) (result i32))) - ;; CHECK-BINARY: (type $5 (func (result i32))) + ;; CHECK-BINARY: (type $5 (func (param (ref null $i32-i32)) (result i32))) + + ;; CHECK-BINARY: (type $6 (func (result i32))) ;; CHECK-BINARY: (type $=>eqref (func (result eqref))) ;; CHECK-BINARY: (type $f64_=>_ref_null<_->_eqref> (func (param f64) (result (ref null $=>eqref)))) ;; CHECK-TEXT: (type $i32-i32 (func (param i32) (result i32))) - ;; CHECK-TEXT: (type $3 (func (param (ref $i32-i32)) (result i32))) + ;; CHECK-TEXT: (type $3 (func (result i32 (ref null $mixed_results) f64))) + + ;; CHECK-TEXT: (type $4 (func (param (ref $i32-i32)) (result i32))) - ;; CHECK-TEXT: (type $4 (func (param (ref null $i32-i32)) (result i32))) + ;; CHECK-TEXT: (type $5 (func (param (ref null $i32-i32)) (result i32))) - ;; CHECK-TEXT: (type $5 (func (result i32))) + ;; CHECK-TEXT: (type $6 (func (result i32))) ;; CHECK-TEXT: (type $=>eqref (func (result eqref))) @@ -51,8 +55,6 @@ (type $i32-i32 (func (param i32) (result i32))) - ;; CHECK-BINARY: (type $9 (func (result i32 (ref null $mixed_results) f64))) - ;; CHECK-BINARY: (type $10 (func (param (ref null $mixed_results)))) ;; CHECK-BINARY: (elem declare func $call-ref $call-ref-more) @@ -62,8 +64,6 @@ ;; CHECK-BINARY-NEXT: (ref.func $call-ref) ;; CHECK-BINARY-NEXT: ) ;; CHECK-BINARY-NEXT: ) - ;; CHECK-TEXT: (type $9 (func (result i32 (ref null $mixed_results) f64))) - ;; CHECK-TEXT: (type $10 (func (param (ref null $mixed_results)))) ;; CHECK-TEXT: (elem declare func $call-ref $call-ref-more) @@ -104,13 +104,13 @@ (func $call-ref-more (param i32) (result i32) (call_ref $i32-i32 (i32.const 42) (ref.func $call-ref-more)) ) - ;; CHECK-BINARY: (func $call_from-param (type $3) (param $f (ref $i32-i32)) (result i32) + ;; CHECK-BINARY: (func $call_from-param (type $4) (param $f (ref $i32-i32)) (result i32) ;; CHECK-BINARY-NEXT: (call_ref $i32-i32 ;; CHECK-BINARY-NEXT: (i32.const 42) ;; CHECK-BINARY-NEXT: (local.get $f) ;; CHECK-BINARY-NEXT: ) ;; CHECK-BINARY-NEXT: ) - ;; CHECK-TEXT: (func $call_from-param (type $3) (param $f (ref $i32-i32)) (result i32) + ;; CHECK-TEXT: (func $call_from-param (type $4) (param $f (ref $i32-i32)) (result i32) ;; CHECK-TEXT-NEXT: (call_ref $i32-i32 ;; CHECK-TEXT-NEXT: (i32.const 42) ;; CHECK-TEXT-NEXT: (local.get $f) @@ -119,13 +119,13 @@ (func $call_from-param (param $f (ref $i32-i32)) (result i32) (call_ref $i32-i32 (i32.const 42) (local.get $f)) ) - ;; CHECK-BINARY: (func $call_from-param-null (type $4) (param $f (ref null $i32-i32)) (result i32) + ;; CHECK-BINARY: (func $call_from-param-null (type $5) (param $f (ref null $i32-i32)) (result i32) ;; CHECK-BINARY-NEXT: (call_ref $i32-i32 ;; CHECK-BINARY-NEXT: (i32.const 42) ;; CHECK-BINARY-NEXT: (local.get $f) ;; CHECK-BINARY-NEXT: ) ;; CHECK-BINARY-NEXT: ) - ;; CHECK-TEXT: (func $call_from-param-null (type $4) (param $f (ref null $i32-i32)) (result i32) + ;; CHECK-TEXT: (func $call_from-param-null (type $5) (param $f (ref null $i32-i32)) (result i32) ;; CHECK-TEXT-NEXT: (call_ref $i32-i32 ;; CHECK-TEXT-NEXT: (i32.const 42) ;; CHECK-TEXT-NEXT: (local.get $f) @@ -134,7 +134,7 @@ (func $call_from-param-null (param $f (ref null $i32-i32)) (result i32) (call_ref $i32-i32 (i32.const 42) (local.get $f)) ) - ;; CHECK-BINARY: (func $call_from-local-null (type $5) (result i32) + ;; CHECK-BINARY: (func $call_from-local-null (type $6) (result i32) ;; CHECK-BINARY-NEXT: (local $f (ref null $i32-i32)) ;; CHECK-BINARY-NEXT: (local.set $f ;; CHECK-BINARY-NEXT: (ref.func $call-ref-more) @@ -144,7 +144,7 @@ ;; CHECK-BINARY-NEXT: (local.get $f) ;; CHECK-BINARY-NEXT: ) ;; CHECK-BINARY-NEXT: ) - ;; CHECK-TEXT: (func $call_from-local-null (type $5) (result i32) + ;; CHECK-TEXT: (func $call_from-local-null (type $6) (result i32) ;; CHECK-TEXT-NEXT: (local $f (ref null $i32-i32)) ;; CHECK-TEXT-NEXT: (local.set $f ;; CHECK-TEXT-NEXT: (ref.func $call-ref-more) @@ -188,7 +188,7 @@ ;; CHECK-BINARY-NEXT: (local $1 (ref null $mixed_results)) ;; CHECK-BINARY-NEXT: (local $2 i32) ;; CHECK-BINARY-NEXT: (local.set $0 - ;; CHECK-BINARY-NEXT: (block $label$1 (result i32 (ref null $mixed_results) f64) + ;; CHECK-BINARY-NEXT: (block $label$1 (type $3) (result i32 (ref null $mixed_results) f64) ;; CHECK-BINARY-NEXT: (unreachable) ;; CHECK-BINARY-NEXT: ) ;; CHECK-BINARY-NEXT: ) @@ -223,7 +223,7 @@ ;; CHECK-TEXT-NEXT: (local $1 (ref null $mixed_results)) ;; CHECK-TEXT-NEXT: (local $2 i32) ;; CHECK-TEXT-NEXT: (local.set $0 - ;; CHECK-TEXT-NEXT: (block $label$1 (result i32 (ref null $mixed_results) f64) + ;; CHECK-TEXT-NEXT: (block $label$1 (type $3) (result i32 (ref null $mixed_results) f64) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) @@ -380,19 +380,19 @@ ;; CHECK-NODEBUG: (type $2 (func (param i32) (result i32))) -;; CHECK-NODEBUG: (type $3 (func (param (ref $2)) (result i32))) +;; CHECK-NODEBUG: (type $3 (func (result i32 (ref null $0) f64))) -;; CHECK-NODEBUG: (type $4 (func (param (ref null $2)) (result i32))) +;; CHECK-NODEBUG: (type $4 (func (param (ref $2)) (result i32))) -;; CHECK-NODEBUG: (type $5 (func (result i32))) +;; CHECK-NODEBUG: (type $5 (func (param (ref null $2)) (result i32))) -;; CHECK-NODEBUG: (type $6 (func (result eqref))) +;; CHECK-NODEBUG: (type $6 (func (result i32))) -;; CHECK-NODEBUG: (type $7 (func (param f64) (result (ref null $6)))) +;; CHECK-NODEBUG: (type $7 (func (result eqref))) -;; CHECK-NODEBUG: (type $8 (func (result anyref))) +;; CHECK-NODEBUG: (type $8 (func (param f64) (result (ref null $7)))) -;; CHECK-NODEBUG: (type $9 (func (result i32 (ref null $0) f64))) +;; CHECK-NODEBUG: (type $9 (func (result anyref))) ;; CHECK-NODEBUG: (type $10 (func (param (ref null $0)))) @@ -417,21 +417,21 @@ ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG-NEXT: ) -;; CHECK-NODEBUG: (func $3 (type $3) (param $0 (ref $2)) (result i32) +;; CHECK-NODEBUG: (func $3 (type $4) (param $0 (ref $2)) (result i32) ;; CHECK-NODEBUG-NEXT: (call_ref $2 ;; CHECK-NODEBUG-NEXT: (i32.const 42) ;; CHECK-NODEBUG-NEXT: (local.get $0) ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG-NEXT: ) -;; CHECK-NODEBUG: (func $4 (type $4) (param $0 (ref null $2)) (result i32) +;; CHECK-NODEBUG: (func $4 (type $5) (param $0 (ref null $2)) (result i32) ;; CHECK-NODEBUG-NEXT: (call_ref $2 ;; CHECK-NODEBUG-NEXT: (i32.const 42) ;; CHECK-NODEBUG-NEXT: (local.get $0) ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG-NEXT: ) -;; CHECK-NODEBUG: (func $5 (type $5) (result i32) +;; CHECK-NODEBUG: (func $5 (type $6) (result i32) ;; CHECK-NODEBUG-NEXT: (local $0 (ref null $2)) ;; CHECK-NODEBUG-NEXT: (local.set $0 ;; CHECK-NODEBUG-NEXT: (ref.func $2) @@ -442,14 +442,14 @@ ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG-NEXT: ) -;; CHECK-NODEBUG: (func $6 (type $7) (param $0 f64) (result (ref null $6)) +;; CHECK-NODEBUG: (func $6 (type $8) (param $0 f64) (result (ref null $7)) ;; CHECK-NODEBUG-NEXT: (ref.null nofunc) ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG: (func $7 (type $1) ;; CHECK-NODEBUG-NEXT: (local $0 i32) ;; CHECK-NODEBUG-NEXT: (local $1 f64) -;; CHECK-NODEBUG-NEXT: (local $2 (ref null $8)) +;; CHECK-NODEBUG-NEXT: (local $2 (ref null $9)) ;; CHECK-NODEBUG-NEXT: (nop) ;; CHECK-NODEBUG-NEXT: ) @@ -458,7 +458,7 @@ ;; CHECK-NODEBUG-NEXT: (local $1 (ref null $0)) ;; CHECK-NODEBUG-NEXT: (local $2 i32) ;; CHECK-NODEBUG-NEXT: (local.set $0 -;; CHECK-NODEBUG-NEXT: (block $label$1 (result i32 (ref null $0) f64) +;; CHECK-NODEBUG-NEXT: (block $label$1 (type $3) (result i32 (ref null $0) f64) ;; CHECK-NODEBUG-NEXT: (unreachable) ;; CHECK-NODEBUG-NEXT: ) ;; CHECK-NODEBUG-NEXT: ) diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index 8ef4f8d07..6b86d3e15 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -738,7 +738,7 @@ ;; CHECK: (func $block-folded (type $void) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $l (result i32 i32) + ;; CHECK-NEXT: (block $l (type $ret2) (result i32 i32) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (unreachable) @@ -766,7 +766,7 @@ ;; CHECK-NEXT: (local.set $scratch_2 ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (local.set $scratch_1 - ;; CHECK-NEXT: (block $1 (result i32 i32) + ;; CHECK-NEXT: (block $1 (type $ret2) (result i32 i32) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (block $2 (result i32) ;; CHECK-NEXT: (local.set $scratch @@ -819,8 +819,8 @@ ;; CHECK-NEXT: (local $scratch (i32 i32)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (local.set $scratch - ;; CHECK-NEXT: (block (result i32 i32) - ;; CHECK-NEXT: (block (result i32 i32) + ;; CHECK-NEXT: (block (type $ret2) (result i32 i32) + ;; CHECK-NEXT: (block (type $ret2) (result i32 i32) ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.const 1) @@ -1566,7 +1566,7 @@ ) ;; CHECK: (func $br-multivalue (type $7) (result i32 i64) - ;; CHECK-NEXT: (block $label (result i32 i64) + ;; CHECK-NEXT: (block $label (type $7) (result i32 i64) ;; CHECK-NEXT: (br $label ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (i32.const 0) @@ -1582,8 +1582,8 @@ ) ;; CHECK: (func $br-multivalue-drop (type $7) (result i32 i64) - ;; CHECK-NEXT: (block $label (result i32 i64) - ;; CHECK-NEXT: (block (result i32 i64) + ;; CHECK-NEXT: (block $label (type $7) (result i32 i64) + ;; CHECK-NEXT: (block (type $7) (result i32 i64) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (f32.const 0) ;; CHECK-NEXT: ) diff --git a/test/passes/remove-unused-brs_enable-multivalue.txt b/test/passes/remove-unused-brs_enable-multivalue.txt index 0a66153e9..b85f1df8c 100644 --- a/test/passes/remove-unused-brs_enable-multivalue.txt +++ b/test/passes/remove-unused-brs_enable-multivalue.txt @@ -193,17 +193,17 @@ ) ) (func $b14-tuple (result i32 i64) - (if (result i32 i64) + (if (type $5) (result i32 i64) (i32.const 1) - (block $topmost (result i32 i64) - (block $block1 (result i32 i64) + (block $topmost (type $5) (result i32 i64) + (block $block1 (type $5) (result i32 i64) (tuple.make (i32.const 12) (i64.const 12) ) ) ) - (block $block3 (result i32 i64) + (block $block3 (type $5) (result i32 i64) (tuple.make (i32.const 27) (i64.const 27) |