diff options
author | Thomas Lively <tlively@google.com> | 2023-05-19 13:47:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-19 11:47:32 -0700 |
commit | b7b1d0df29df14634d2c680d1d2c351b624b4fbb (patch) | |
tree | 808bd70c6502ba2ba3ef275048c89deaedbe5077 /test/lit/passes | |
parent | e42a58696059fd1cadcf25e10223b979214984b3 (diff) | |
download | binaryen-b7b1d0df29df14634d2c680d1d2c351b624b4fbb.tar.gz binaryen-b7b1d0df29df14634d2c680d1d2c351b624b4fbb.tar.bz2 binaryen-b7b1d0df29df14634d2c680d1d2c351b624b4fbb.zip |
Update br_on_cast binary and text format (#5734)
The final versions of the br_on_cast and br_on_cast_fail instructions have two
reference type annotations: one for the input type and one for the cast target
type. In the binary format, this is represented as a flags byte followed by two
encoded heap types. Since these instructions have been in flux for a while, do
not attempt to maintain backward compatibility with older versions of the
instructions. Instead, upgrade all of the tests at once to use the new versions
of the instructions. Drop some binary tests of deprecated instruction encodings
that would be more effort to update than they're worth.
Diffstat (limited to 'test/lit/passes')
-rw-r--r-- | test/lit/passes/abstract-type-refining.wast | 12 | ||||
-rw-r--r-- | test/lit/passes/dce_all-features.wast | 2 | ||||
-rw-r--r-- | test/lit/passes/gufa-refs.wast | 12 | ||||
-rw-r--r-- | test/lit/passes/precompute-gc.wast | 4 | ||||
-rw-r--r-- | test/lit/passes/remove-unused-brs-gc.wast | 34 | ||||
-rw-r--r-- | test/lit/passes/type-merging-tnh.wast | 4 | ||||
-rw-r--r-- | test/lit/passes/type-merging.wast | 4 |
7 files changed, 36 insertions, 36 deletions
diff --git a/test/lit/passes/abstract-type-refining.wast b/test/lit/passes/abstract-type-refining.wast index 5fffa7972..8310d28d1 100644 --- a/test/lit/passes/abstract-type-refining.wast +++ b/test/lit/passes/abstract-type-refining.wast @@ -178,7 +178,7 @@ ;; YESTNH-NEXT: (drop ;; YESTNH-NEXT: (block $block (result (ref $B)) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (br_on_cast $block $B + ;; YESTNH-NEXT: (br_on_cast $block anyref (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) @@ -190,7 +190,7 @@ ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (block $block (result anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (br_on_cast $block $A + ;; NO_TNH-NEXT: (br_on_cast $block anyref (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -202,7 +202,7 @@ (drop (block $block (result anyref) (drop - (br_on_cast $block $A + (br_on_cast $block anyref (ref $A) (local.get $x) ) ) @@ -750,7 +750,7 @@ ;; YESTNH-NEXT: (drop ;; YESTNH-NEXT: (block $block (result (ref none)) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (br_on_cast $block none + ;; YESTNH-NEXT: (br_on_cast $block anyref (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) @@ -770,7 +770,7 @@ ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (block $block (result (ref none)) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (br_on_cast $block none + ;; NO_TNH-NEXT: (br_on_cast $block anyref (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -791,7 +791,7 @@ (drop (block $block (result anyref) (drop - (br_on_cast $block $B + (br_on_cast $block anyref (ref $B) (local.get $x) ) ) diff --git a/test/lit/passes/dce_all-features.wast b/test/lit/passes/dce_all-features.wast index adddfd3cc..47838dbd6 100644 --- a/test/lit/passes/dce_all-features.wast +++ b/test/lit/passes/dce_all-features.wast @@ -1421,7 +1421,7 @@ (func $br_on_cast_fail (result (ref any)) (block $label$1 (result (ref none)) ;; Similar to the above, but using br_on_cast_fail. - (br_on_cast_fail $label$1 null struct + (br_on_cast_fail $label$1 anyref structref (unreachable) ) (unreachable) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index 06998072b..6fb372d72 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -988,7 +988,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $parent (result (ref $parent)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $parent $parent + ;; CHECK-NEXT: (br_on_cast $parent (ref $unrelated) (ref $parent) ;; CHECK-NEXT: (struct.new_default $unrelated) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1051,7 +1051,7 @@ (struct.get $parent 0 (block $parent (result (ref $parent)) (drop - (br_on_cast $parent $parent + (br_on_cast $parent anyref (ref $parent) (struct.new $unrelated) ) ) @@ -5344,7 +5344,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $B (result (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $B $B + ;; CHECK-NEXT: (br_on_cast $B (ref $A) (ref $B) ;; CHECK-NEXT: (struct.new $A ;; CHECK-NEXT: (i32.const 100) ;; CHECK-NEXT: ) @@ -5361,7 +5361,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $A (result (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $A $A + ;; CHECK-NEXT: (br_on_cast $A (ref $A) (ref $A) ;; CHECK-NEXT: (struct.new $A ;; CHECK-NEXT: (i32.const 200) ;; CHECK-NEXT: ) @@ -5387,7 +5387,7 @@ (drop (block $B (result (ref $B)) (drop - (br_on_cast $B $B + (br_on_cast $B anyref (ref $B) (struct.new $A (i32.const 100) ) @@ -5402,7 +5402,7 @@ (ref.test $A (block $A (result (ref $A)) (drop - (br_on_cast $A $A + (br_on_cast $A anyref (ref $A) (struct.new $A (i32.const 200) ) diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast index 20d6230be..369bd685c 100644 --- a/test/lit/passes/precompute-gc.wast +++ b/test/lit/passes/precompute-gc.wast @@ -860,7 +860,7 @@ ;; CHECK: (func $br_on_cast-on-creation (type $none_=>_ref|$empty|) (result (ref $empty)) ;; CHECK-NEXT: (block $label (result (ref $empty)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $label $empty + ;; CHECK-NEXT: (br_on_cast $label (ref $empty) (ref $empty) ;; CHECK-NEXT: (struct.new_default $empty) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -870,7 +870,7 @@ (func $br_on_cast-on-creation (result (ref $empty)) (block $label (result (ref $empty)) (drop - (br_on_cast $label $empty + (br_on_cast $label anyref (ref $empty) (struct.new_default $empty) ) ) diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index 4fe7bd938..e063fa482 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -136,7 +136,7 @@ (drop ;; This static cast can be computed at compile time: it will definitely be ;; taken, so we can turn it into a normal br. - (br_on_cast $block $struct + (br_on_cast $block anyref (ref $struct) (struct.new $struct) ) ) @@ -157,7 +157,7 @@ ;; CHECK-NEXT: (local.get $nullable-struct2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $block null $struct + ;; CHECK-NEXT: (br_on_cast $block (ref null $struct2) (ref null $struct) ;; CHECK-NEXT: (local.get $nullable-struct2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -170,26 +170,26 @@ (drop ;; This cast can be computed at compile time: it will definitely fail, so we ;; can remove it. - (br_on_cast $block $struct + (br_on_cast $block anyref (ref $struct) (struct.new $struct2) ) ) (drop ;; We can still remove it even if the cast allows nulls. - (br_on_cast $block null $struct + (br_on_cast $block anyref (ref null $struct) (struct.new $struct2) ) ) (drop ;; Or if the cast does not allow nulls and the value is nullable. - (br_on_cast $block $struct + (br_on_cast $block anyref (ref $struct) (local.get $nullable-struct2) ) ) (drop ;; But if both are nullable, then we can't optimize because the cast would ;; succeed if the value is a null. - (br_on_cast $block null $struct + (br_on_cast $block anyref (ref null $struct) (local.get $nullable-struct2) ) ) @@ -216,7 +216,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_fail $block null $struct + ;; CHECK-NEXT: (br_on_cast_fail $block (ref null $struct2) (ref null $struct) ;; CHECK-NEXT: (local.get $nullable-struct2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -229,26 +229,26 @@ (drop ;; This cast can be computed at compile time: it will definitely fail, so we ;; can replace it with an unconditional br. - (br_on_cast_fail $block $struct + (br_on_cast_fail $block anyref (ref $struct) (struct.new $struct2) ) ) (drop ;; We can still replace it even if the cast allows nulls. - (br_on_cast_fail $block null $struct + (br_on_cast_fail $block anyref (ref null $struct) (struct.new $struct2) ) ) (drop ;; Or if the cast does not allow nulls and the value is nullable. - (br_on_cast_fail $block $struct + (br_on_cast_fail $block anyref (ref $struct) (local.get $nullable-struct2) ) ) (drop ;; But if both are nullable, then we can't optimize because the cast would ;; succeed if the value is a null. - (br_on_cast_fail $block null $struct + (br_on_cast_fail $block anyref (ref null $struct) (local.get $nullable-struct2) ) ) @@ -260,7 +260,7 @@ ;; CHECK-NEXT: (local $struct (ref null $struct)) ;; CHECK-NEXT: (block $block (result (ref $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $block $struct + ;; CHECK-NEXT: (br_on_cast $block (ref null $struct) (ref $struct) ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -271,7 +271,7 @@ (local $struct (ref null $struct)) (block $block (result (ref $struct)) (drop - (br_on_cast $block $struct + (br_on_cast $block anyref (ref $struct) ;; As above, but now the type is nullable, so we cannot infer anything. (local.get $struct) ) @@ -293,7 +293,7 @@ (func $br_on_cast_nullable (result (ref null $struct)) (block $block (result (ref null $struct)) (drop - (br_on_cast $block null $struct + (br_on_cast $block anyref (ref null $struct) ;; As above, but now the cast allows nulls, so we can optimize. (ref.null $struct) ) @@ -315,7 +315,7 @@ (drop ;; As $br_on_cast, but this checks for a failing cast, so we know it will ;; *not* be taken. - (br_on_cast_fail $block $struct + (br_on_cast_fail $block anyref (ref $struct) (struct.new $struct) ) ) @@ -348,7 +348,7 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (block $something (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $something $struct + ;; CHECK-NEXT: (br_on_cast $something (ref null $struct) (ref $struct) ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -403,7 +403,7 @@ (block (result anyref) (block $something (result anyref) (drop - (br_on_cast $something $struct + (br_on_cast $something anyref (ref $struct) (local.get $struct) ) ) diff --git a/test/lit/passes/type-merging-tnh.wast b/test/lit/passes/type-merging-tnh.wast index c84e31815..0ec9ac38e 100644 --- a/test/lit/passes/type-merging-tnh.wast +++ b/test/lit/passes/type-merging-tnh.wast @@ -57,7 +57,7 @@ ;; CHECK: (func $test (type $ref|$A|_=>_ref|$B|) (param $a (ref $A)) (result (ref $B)) ;; CHECK-NEXT: (block $__binaryen_fake_return (result (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $__binaryen_fake_return $B + ;; CHECK-NEXT: (br_on_cast $__binaryen_fake_return (ref $A) (ref $B) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -74,7 +74,7 @@ ;; CHECK-NEXT: ) (func $test (param $a (ref $A)) (result (ref $B)) (drop - (br_on_cast 0 $B + (br_on_cast 0 anyref (ref $B) (local.get $a) ) ) diff --git a/test/lit/passes/type-merging.wast b/test/lit/passes/type-merging.wast index 98ae92055..55ec42bd0 100644 --- a/test/lit/passes/type-merging.wast +++ b/test/lit/passes/type-merging.wast @@ -947,7 +947,7 @@ ;; CHECK: (func $test (type $ref|$A|_=>_ref|$B|) (param $a (ref $A)) (result (ref $B)) ;; CHECK-NEXT: (block $__binaryen_fake_return (result (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $__binaryen_fake_return $B + ;; CHECK-NEXT: (br_on_cast $__binaryen_fake_return (ref $A) (ref $B) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -964,7 +964,7 @@ ;; CHECK-NEXT: ) (func $test (param $a (ref $A)) (result (ref $B)) (drop - (br_on_cast 0 $B + (br_on_cast 0 anyref (ref $B) (local.get $a) ) ) |