diff options
Diffstat (limited to 'test')
56 files changed, 1203 insertions, 1200 deletions
diff --git a/test/ctor-eval/gc-2.wast b/test/ctor-eval/gc-2.wast index 62c21c5bf..114254d3f 100644 --- a/test/ctor-eval/gc-2.wast +++ b/test/ctor-eval/gc-2.wast @@ -38,7 +38,7 @@ (func "keepalive" (result i32) (select (struct.get $struct 0 - (ref.cast $struct + (ref.cast (ref $struct) (global.get $global1) ) ) diff --git a/test/ctor-eval/gc-2.wast.out b/test/ctor-eval/gc-2.wast.out index 370faec16..12fd62924 100644 --- a/test/ctor-eval/gc-2.wast.out +++ b/test/ctor-eval/gc-2.wast.out @@ -14,7 +14,7 @@ (func $1 (type $none_=>_i32) (result i32) (select (struct.get $struct 0 - (ref.cast $struct + (ref.cast (ref $struct) (global.get $global1) ) ) diff --git a/test/ctor-eval/gc-array.wast b/test/ctor-eval/gc-array.wast index 316230e13..0ad3d0314 100644 --- a/test/ctor-eval/gc-array.wast +++ b/test/ctor-eval/gc-array.wast @@ -5,7 +5,7 @@ ;; This global will remain as it is. (global $global1 (ref $array) - (array.new_fixed $array + (array.new_fixed $array 4 (i32.const 10) (i32.const 20) (i32.const 30) @@ -14,7 +14,7 @@ ) (global $global2 (ref $array) - (array.new_fixed $array + (array.new_fixed $array 2 (i32.const 42) ;; This location will be written with a new value, 1337 (i32.const 0) diff --git a/test/ctor-eval/gc-array.wast.out b/test/ctor-eval/gc-array.wast.out index 27be809ba..20e464e07 100644 --- a/test/ctor-eval/gc-array.wast.out +++ b/test/ctor-eval/gc-array.wast.out @@ -1,13 +1,13 @@ (module (type $array (array (mut i32))) (type $none_=>_i32 (func (result i32))) - (global $global1 (ref $array) (array.new_fixed $array + (global $global1 (ref $array) (array.new_fixed $array 4 (i32.const 10) (i32.const 20) (i32.const 30) (i32.const 40) )) - (global $global2 (ref $array) (array.new_fixed $array + (global $global2 (ref $array) (array.new_fixed $array 2 (i32.const 42) (i32.const 1337) )) diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index edcc0b91e..00880f0db 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -2260,12 +2260,12 @@ BinaryenFeatureAll: 126975 ) ) (drop - (ref.test null $[mut:i8] + (ref.test (ref null $[mut:i8]) (global.get $i8Array-global) ) ) (drop - (ref.cast null $[mut:i8] + (ref.cast (ref null $[mut:i8]) (global.get $i8Array-global) ) ) @@ -2298,7 +2298,7 @@ BinaryenFeatureAll: 126975 ) ) (drop - (array.new_fixed $[mut:i8] + (array.new_fixed $[mut:i8] 3 (i32.const 1) (i32.const 2) (i32.const 3) diff --git a/test/lit/array-init-static.wast b/test/lit/array-init-static.wast index 266a874a6..41915d1ed 100644 --- a/test/lit/array-init-static.wast +++ b/test/lit/array-init-static.wast @@ -12,7 +12,7 @@ (type $array (array i32)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array + ;; CHECK-NEXT: (array.new_fixed $array 2 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) diff --git a/test/lit/array-new-fixed.wast b/test/lit/array-new-fixed.wast index ef20bf5f8..847b9ffcf 100644 --- a/test/lit/array-new-fixed.wast +++ b/test/lit/array-new-fixed.wast @@ -7,13 +7,13 @@ (type $array (array i32)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array + ;; CHECK-NEXT: (array.new_fixed $array 2 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array + ;; CHECK-NEXT: (array.new_fixed $array 2 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) diff --git a/test/lit/cast-to-basic.wast b/test/lit/cast-to-basic.wast index c4190dc76..e7a5567c8 100644 --- a/test/lit/cast-to-basic.wast +++ b/test/lit/cast-to-basic.wast @@ -6,26 +6,26 @@ (module ;; CHECK: (func $test (type $none_=>_i32) (result i32) - ;; CHECK-NEXT: (ref.test struct + ;; CHECK-NEXT: (ref.test (ref struct) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test (result i32) - (ref.test struct + (ref.test (ref struct) (ref.null none) ) ) ;; CHECK: (func $cast (type $structref_=>_none) (param $x structref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null struct + ;; CHECK-NEXT: (ref.cast structref ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $cast (param $x (ref null struct)) (drop - (ref.cast null struct + (ref.cast structref (local.get $x) ) ) diff --git a/test/lit/ctor-eval/extern.wast b/test/lit/ctor-eval/extern.wast index 874b2c00e..2607e13c9 100644 --- a/test/lit/ctor-eval/extern.wast +++ b/test/lit/ctor-eval/extern.wast @@ -12,7 +12,7 @@ ;; CHECK: (type $none_=>_anyref (func (result anyref))) - ;; CHECK: (global $ctor-eval$global (ref $array) (array.new_fixed $array + ;; CHECK: (global $ctor-eval$global (ref $array) (array.new_fixed $array 3 ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: (i32.const 3) @@ -50,7 +50,7 @@ (func $test2 (result externref) ;; This will be evalled into an externalization of a global.get. (extern.externalize - (array.new_fixed $array + (array.new_fixed $array 3 (i32.const 1) (i32.const 2) (i32.const 3) diff --git a/test/lit/ctor-eval/gc-cycle.wast b/test/lit/ctor-eval/gc-cycle.wast index 5096da376..e9c69a2fc 100644 --- a/test/lit/ctor-eval/gc-cycle.wast +++ b/test/lit/ctor-eval/gc-cycle.wast @@ -734,7 +734,7 @@ ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: )) - ;; CHECK: (global $ctor-eval$global_13 (ref $B) (array.new_fixed $B + ;; CHECK: (global $ctor-eval$global_13 (ref $B) (array.new_fixed $B 10 ;; CHECK-NEXT: (global.get $ctor-eval$global_14) ;; CHECK-NEXT: (global.get $ctor-eval$global_14) ;; CHECK-NEXT: (global.get $ctor-eval$global_14) @@ -772,7 +772,7 @@ ) (global.set $c (local.tee $c - (array.new_fixed $C + (array.new_fixed $C 2 (local.get $b) (local.get $a) ) @@ -784,7 +784,7 @@ ) ) - ;; CHECK: (global $ctor-eval$global_12 (ref $C) (array.new_fixed $C + ;; CHECK: (global $ctor-eval$global_12 (ref $C) (array.new_fixed $C 2 ;; CHECK-NEXT: (global.get $ctor-eval$global_13) ;; CHECK-NEXT: (global.get $ctor-eval$global_14) ;; CHECK-NEXT: )) @@ -842,7 +842,7 @@ ;; CHECK-NEXT: (i32.const 42) ;; CHECK-NEXT: )) - ;; CHECK: (global $ctor-eval$global_13 (ref $B) (array.new_fixed $B + ;; CHECK: (global $ctor-eval$global_13 (ref $B) (array.new_fixed $B 10 ;; CHECK-NEXT: (global.get $ctor-eval$global_14) ;; CHECK-NEXT: (global.get $ctor-eval$global_14) ;; CHECK-NEXT: (global.get $ctor-eval$global_14) @@ -884,7 +884,7 @@ ) (global.set $c (local.tee $c - (array.new_fixed $C + (array.new_fixed $C 2 (local.get $b) (local.get $a) ) @@ -896,7 +896,7 @@ ) ) - ;; CHECK: (global $ctor-eval$global_12 (ref $C) (array.new_fixed $C + ;; CHECK: (global $ctor-eval$global_12 (ref $C) (array.new_fixed $C 2 ;; CHECK-NEXT: (global.get $ctor-eval$global_13) ;; CHECK-NEXT: (global.get $ctor-eval$global_14) ;; CHECK-NEXT: )) @@ -974,7 +974,7 @@ ) ) (global.set $b - (array.new_fixed $B + (array.new_fixed $B 3 (struct.new_default $A) (global.get $a) (struct.new_default $A) @@ -998,15 +998,15 @@ ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: )) - ;; CHECK: (global $ctor-eval$global_14 (ref $B) (array.new_fixed $B + ;; CHECK: (global $ctor-eval$global_14 (ref $B) (array.new_fixed $B 3 ;; CHECK-NEXT: (global.get $ctor-eval$global_15) ;; CHECK-NEXT: (global.get $ctor-eval$global_16) ;; CHECK-NEXT: (global.get $ctor-eval$global_19) ;; CHECK-NEXT: )) - ;; CHECK: (global $ctor-eval$global_17 (ref $B) (array.new_fixed $B)) + ;; CHECK: (global $ctor-eval$global_17 (ref $B) (array.new_fixed $B 0)) - ;; CHECK: (global $ctor-eval$global_18 (ref $B) (array.new_fixed $B)) + ;; CHECK: (global $ctor-eval$global_18 (ref $B) (array.new_fixed $B 0)) ;; CHECK: (export "test" (func $test_3)) @@ -1060,15 +1060,15 @@ ;; CHECK: (type $none_=>_anyref (func (result anyref))) - ;; CHECK: (global $ctor-eval$global_16 (ref $B) (array.new_fixed $B + ;; CHECK: (global $ctor-eval$global_16 (ref $B) (array.new_fixed $B 3 ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: )) - ;; CHECK: (global $ctor-eval$global_19 (ref $B) (array.new_fixed $B)) + ;; CHECK: (global $ctor-eval$global_19 (ref $B) (array.new_fixed $B 0)) - ;; CHECK: (global $ctor-eval$global_15 (ref $B) (array.new_fixed $B)) + ;; CHECK: (global $ctor-eval$global_15 (ref $B) (array.new_fixed $B 0)) ;; CHECK: (global $ctor-eval$global_14 (ref $A) (struct.new $A ;; CHECK-NEXT: (global.get $ctor-eval$global_15) @@ -1084,7 +1084,7 @@ (local $b (ref $B)) (global.set $b (local.tee $b - (array.new_fixed $B + (array.new_fixed $B 3 (struct.new_default $A) (ref.null $A) (struct.new_default $A) diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast index 6d07ae6a8..320fe5de5 100644 --- a/test/lit/exec/strings.wast +++ b/test/lit/exec/strings.wast @@ -9,7 +9,7 @@ ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") (func "new_wtf16_array" (result stringref) (string.new_wtf16_array - (array.new_fixed $array16 + (array.new_fixed $array16 5 (i32.const 104) ;; h (i32.const 101) ;; e (i32.const 108) ;; l diff --git a/test/lit/heap-types.wast b/test/lit/heap-types.wast index 63e12c67e..92f7f49b3 100644 --- a/test/lit/heap-types.wast +++ b/test/lit/heap-types.wast @@ -13,14 +13,14 @@ (type $struct.B (struct i32)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $struct.A + ;; CHECK-NEXT: (ref.test (ref $struct.A) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test (drop - (ref.test $struct.B (ref.null $struct.A)) + (ref.test (ref $struct.B) (ref.null $struct.A)) ) ) ) @@ -30,7 +30,7 @@ (type $struct.B (struct i32)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -39,7 +39,7 @@ ;; Note that this will not round-trip precisely because Binaryen IR will ;; apply the more refined type to the cast automatically (in finalize). (drop - (ref.cast null $struct.B (ref.null $struct.A)) + (ref.cast (ref null $struct.B) (ref.null $struct.A)) ) ) ) @@ -85,7 +85,7 @@ (type $vector (array (mut f64))) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $vector + ;; CHECK-NEXT: (array.new_fixed $vector 4 ;; CHECK-NEXT: (f64.const 1) ;; CHECK-NEXT: (f64.const 2) ;; CHECK-NEXT: (f64.const 4) @@ -95,7 +95,7 @@ ;; CHECK-NEXT: ) (func $test (drop - (array.new_fixed $vector + (array.new_fixed $vector 4 (f64.const 1) (f64.const 2) (f64.const 4) diff --git a/test/lit/passes/abstract-type-refining.wast b/test/lit/passes/abstract-type-refining.wast index af2b210fd..fba61723a 100644 --- a/test/lit/passes/abstract-type-refining.wast +++ b/test/lit/passes/abstract-type-refining.wast @@ -70,54 +70,54 @@ ;; YESTNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B + ;; YESTNH-NEXT: (ref.cast (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B + ;; YESTNH-NEXT: (ref.cast (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $E + ;; YESTNH-NEXT: (ref.cast (ref $E) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $E + ;; YESTNH-NEXT: (ref.cast (ref $E) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $C + ;; NO_TNH-NEXT: (ref.cast (ref $C) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $D + ;; NO_TNH-NEXT: (ref.cast (ref $D) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $E + ;; NO_TNH-NEXT: (ref.cast (ref $E) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -126,27 +126,27 @@ ;; List out all possible casts for comprehensiveness. For other instructions ;; we are more focused, below. (drop - (ref.cast $A ;; This will be $B in TNH. + (ref.cast (ref $A) ;; This will be $B in TNH. (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) (drop - (ref.cast $D ;; This will be $E in TNH. + (ref.cast (ref $D) ;; This will be $E in TNH. (local.get $x) ) ) (drop - (ref.cast $E + (ref.cast (ref $E) (local.get $x) ) ) @@ -154,21 +154,21 @@ ;; YESTNH: (func $ref.test (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.test $B + ;; YESTNH-NEXT: (ref.test (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.test (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.test $A + ;; NO_TNH-NEXT: (ref.test (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) (func $ref.test (param $x anyref) (drop - (ref.test $A + (ref.test (ref $A) (local.get $x) ) ) @@ -213,14 +213,14 @@ ;; YESTNH: (func $basic (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast struct + ;; YESTNH-NEXT: (ref.cast (ref struct) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $basic (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast struct + ;; NO_TNH-NEXT: (ref.cast (ref struct) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -228,7 +228,7 @@ (func $basic (param $x anyref) ;; Casts to basic types should not be modified. (drop - (ref.cast struct + (ref.cast (ref struct) (local.get $x) ) ) @@ -306,51 +306,51 @@ ;; YESTNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $A + ;; YESTNH-NEXT: (ref.cast (ref $A) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B + ;; YESTNH-NEXT: (ref.cast (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B1 + ;; YESTNH-NEXT: (ref.cast (ref $B1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B1 + ;; NO_TNH-NEXT: (ref.cast (ref $B1) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) (func $ref.cast (param $x anyref) (drop - (ref.cast $A ;; This will not be optimized like before. + (ref.cast (ref $A) ;; This will not be optimized like before. (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $B1 + (ref.cast (ref $B1) (local.get $x) ) ) @@ -395,51 +395,51 @@ ;; YESTNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B1 + ;; YESTNH-NEXT: (ref.cast (ref $B1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast none + ;; YESTNH-NEXT: (ref.cast (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B1 + ;; YESTNH-NEXT: (ref.cast (ref $B1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast none + ;; NO_TNH-NEXT: (ref.cast (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B1 + ;; NO_TNH-NEXT: (ref.cast (ref $B1) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) (func $ref.cast (param $x anyref) (drop - (ref.cast $A ;; This will be optimized to $B1. + (ref.cast (ref $A) ;; This will be optimized to $B1. (local.get $x) ) ) (drop - (ref.cast $B ;; $B is never created, so this will trap, in both TNH + (ref.cast (ref $B) ;; $B is never created, so this will trap, in both TNH (local.get $x) ;; and non-TNH modes. ) ) (drop - (ref.cast $B1 + (ref.cast (ref $B1) (local.get $x) ) ) @@ -482,51 +482,51 @@ ;; YESTNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $C + ;; NO_TNH-NEXT: (ref.cast (ref $C) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) (func $ref.cast (param $x anyref) (drop - (ref.cast $A ;; This can be $C. + (ref.cast (ref $A) ;; This can be $C. (local.get $x) ) ) (drop - (ref.cast $B ;; This can also be $C. + (ref.cast (ref $B) ;; This can also be $C. (local.get $x) ) ) (drop - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) @@ -553,22 +553,22 @@ ;; YESTNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast none + ;; YESTNH-NEXT: (ref.cast (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast none + ;; YESTNH-NEXT: (ref.cast (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast none + ;; YESTNH-NEXT: (ref.cast (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast none + ;; YESTNH-NEXT: (ref.cast (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) @@ -580,22 +580,22 @@ ;; NO_TNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast none + ;; NO_TNH-NEXT: (ref.cast (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast none + ;; NO_TNH-NEXT: (ref.cast (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast none + ;; NO_TNH-NEXT: (ref.cast (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast none + ;; NO_TNH-NEXT: (ref.cast (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -603,22 +603,22 @@ (func $ref.cast (param $x anyref) ;; All these will trap. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C1 + (ref.cast (ref $C1) (local.get $x) ) ) (drop - (ref.cast $C2 + (ref.cast (ref $C2) (local.get $x) ) ) @@ -626,44 +626,44 @@ ;; YESTNH: (func $ref.cast.null (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null none + ;; YESTNH-NEXT: (ref.cast nullref ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null none + ;; YESTNH-NEXT: (ref.cast nullref ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null none + ;; YESTNH-NEXT: (ref.cast nullref ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null none + ;; YESTNH-NEXT: (ref.cast nullref ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast.null (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -671,22 +671,22 @@ (func $ref.cast.null (param $x anyref) ;; These can only pass through a null. (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) (drop - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) (drop - (ref.cast null $C1 + (ref.cast (ref null $C1) (local.get $x) ) ) (drop - (ref.cast null $C2 + (ref.cast (ref null $C2) (local.get $x) ) ) @@ -694,24 +694,24 @@ ;; YESTNH: (func $ref.test (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.test none + ;; YESTNH-NEXT: (ref.test (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.test null none + ;; YESTNH-NEXT: (ref.test nullref ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.test (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.test none + ;; NO_TNH-NEXT: (ref.test (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.test null none + ;; NO_TNH-NEXT: (ref.test nullref ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -719,13 +719,13 @@ (func $ref.test (param $x anyref) ;; This will return 0. (drop - (ref.test $A + (ref.test (ref $A) (local.get $x) ) ) ;; This can test for a null. (drop - (ref.test null $A + (ref.test (ref null $A) (local.get $x) ) ) @@ -846,44 +846,44 @@ ;; YESTNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C1 + ;; YESTNH-NEXT: (ref.cast (ref $C1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C1 + ;; YESTNH-NEXT: (ref.cast (ref $C1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C1 + ;; YESTNH-NEXT: (ref.cast (ref $C1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast none + ;; YESTNH-NEXT: (ref.cast (ref none) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $C1 + ;; NO_TNH-NEXT: (ref.cast (ref $C1) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast none + ;; NO_TNH-NEXT: (ref.cast (ref none) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -891,23 +891,23 @@ (func $ref.cast (param $x anyref) ;; These three can be cast to $C1 in TNH. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C1 + (ref.cast (ref $C1) (local.get $x) ) ) ;; This will trap. (drop - (ref.cast $C2 + (ref.cast (ref $C2) (local.get $x) ) ) @@ -915,44 +915,44 @@ ;; YESTNH: (func $ref.cast.null (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null $C1 + ;; YESTNH-NEXT: (ref.cast (ref null $C1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null $C1 + ;; YESTNH-NEXT: (ref.cast (ref null $C1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null $C1 + ;; YESTNH-NEXT: (ref.cast (ref null $C1) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast null none + ;; YESTNH-NEXT: (ref.cast nullref ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $ref.cast.null (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null $A + ;; NO_TNH-NEXT: (ref.cast (ref null $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null $B + ;; NO_TNH-NEXT: (ref.cast (ref null $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null $C1 + ;; NO_TNH-NEXT: (ref.cast (ref null $C1) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -960,23 +960,23 @@ (func $ref.cast.null (param $x anyref) ;; These three can be cast to $C1 in TNH. (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) (drop - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) (drop - (ref.cast null $C1 + (ref.cast (ref null $C1) (local.get $x) ) ) ;; This returns null. (drop - (ref.cast null $C2 + (ref.cast (ref null $C2) (local.get $x) ) ) @@ -1023,34 +1023,34 @@ ;; YESTNH: (func $casts (type $funcref_=>_none) (param $x funcref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $A + ;; YESTNH-NEXT: (ref.cast (ref $A) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B + ;; YESTNH-NEXT: (ref.cast (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $casts (type $funcref_=>_none) (param $x funcref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $C + ;; NO_TNH-NEXT: (ref.cast (ref $C) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -1059,17 +1059,17 @@ ;; $A and $C have functions of their types, so in theory we could optimize ;; $B here. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) @@ -1140,34 +1140,34 @@ ;; YESTNH: (func $casts (type $funcref_=>_none) (param $x funcref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $A + ;; YESTNH-NEXT: (ref.cast (ref $A) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B + ;; YESTNH-NEXT: (ref.cast (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $casts (type $funcref_=>_none) (param $x funcref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $C + ;; NO_TNH-NEXT: (ref.cast (ref $C) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -1176,17 +1176,17 @@ ;; $A and $C have functions of their types, and references to them, so in ;; theory we could optimize $B here. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) @@ -1254,51 +1254,51 @@ ;; YESTNH: (func $casts (type $anyref_=>_none) (param $x anyref) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $A + ;; YESTNH-NEXT: (ref.cast (ref $A) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $B + ;; YESTNH-NEXT: (ref.cast (ref $B) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: (drop - ;; YESTNH-NEXT: (ref.cast $C + ;; YESTNH-NEXT: (ref.cast (ref $C) ;; YESTNH-NEXT: (local.get $x) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; YESTNH-NEXT: ) ;; NO_TNH: (func $casts (type $anyref_=>_none) (param $x anyref) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $A + ;; NO_TNH-NEXT: (ref.cast (ref $A) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $B + ;; NO_TNH-NEXT: (ref.cast (ref $B) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $C + ;; NO_TNH-NEXT: (ref.cast (ref $C) ;; NO_TNH-NEXT: (local.get $x) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) (func $casts (param $x anyref) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) diff --git a/test/lit/passes/cfp.wast b/test/lit/passes/cfp.wast index e9eaf001f..80fdb5eb2 100644 --- a/test/lit/passes/cfp.wast +++ b/test/lit/passes/cfp.wast @@ -2070,7 +2070,7 @@ ;; CHECK: (type $ref?|$object|_=>_funcref (func (param (ref null $object)) (result funcref))) - ;; CHECK: (global $global (ref $itable) (array.new_fixed $itable + ;; CHECK: (global $global (ref $itable) (array.new_fixed $itable 2 ;; CHECK-NEXT: (struct.new $vtable ;; CHECK-NEXT: (ref.null nofunc) ;; CHECK-NEXT: ) @@ -2078,7 +2078,7 @@ ;; CHECK-NEXT: (ref.func $test) ;; CHECK-NEXT: ) ;; CHECK-NEXT: )) - (global $global (ref $itable) (array.new_fixed $itable + (global $global (ref $itable) (array.new_fixed $itable 2 (struct.new $vtable (ref.null func) ) diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index 5df9728d7..55574bfe4 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -223,8 +223,8 @@ ;; CHECK-NEXT: (local $0 i31ref) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: (ref.test i31 - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.test (ref i31) + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (block (result i31ref) ;; CHECK-NEXT: (i31.new ;; CHECK-NEXT: (i32.const 0) @@ -238,8 +238,8 @@ (local $local i31ref) (i32.add (unreachable) - (ref.test i31 - (ref.cast null i31 + (ref.test (ref i31) + (ref.cast i31ref ;; This local.get is in unreachable code, and coalesce-locals will remove ;; it in order to avoid using the local index at all. While doing so it ;; must emit something of the exact same type so validation still works @@ -256,7 +256,7 @@ ;; CHECK-NEXT: (block (result f64) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (block (result (ref null $A)) ;; CHECK-NEXT: (struct.new_default $A) ;; CHECK-NEXT: ) @@ -271,7 +271,7 @@ (block (result f64) (unreachable) ) - (ref.cast null $A + (ref.cast (ref null $A) (local.tee $A (struct.new_default $A) ) diff --git a/test/lit/passes/dce_all-features.wast b/test/lit/passes/dce_all-features.wast index 47838dbd6..cda928e61 100644 --- a/test/lit/passes/dce_all-features.wast +++ b/test/lit/passes/dce_all-features.wast @@ -1433,7 +1433,7 @@ ;; CHECK: (type $none_=>_anyref (func (result anyref))) ;; CHECK: (func $if (type $none_=>_anyref) (result anyref) - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (if (result i31ref) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (unreachable) @@ -1451,7 +1451,7 @@ ;; ;; In other words, we can propagate unreachability in DCE, but should cause ;; no other type changes. - (ref.cast null i31 + (ref.cast i31ref (if (result i31ref) (i32.const 0) (block (result i31ref) diff --git a/test/lit/passes/gsi_vacuum_precompute.wast b/test/lit/passes/gsi_vacuum_precompute.wast index 2658961ac..564abe152 100644 --- a/test/lit/passes/gsi_vacuum_precompute.wast +++ b/test/lit/passes/gsi_vacuum_precompute.wast @@ -70,7 +70,7 @@ (func $test-A (export "test-A") (param $ref (ref any)) (result funcref) (struct.get $vtable 0 ;; this is a reference to $func1 (struct.get $itable1 0 ;; this is the sub-object in the global $itable1 - (ref.cast $itable1 + (ref.cast (ref $itable1) (local.get $ref) ;; this can be inferred to be the global $itable1 ) ) @@ -83,7 +83,7 @@ (func $test-B (export "test-B") (param $ref (ref any)) (result funcref) (struct.get $vtable 0 ;; this is a reference to $func2 (struct.get $itable2 0 ;; this is the sub-object in the global $itable2 - (ref.cast $itable2 + (ref.cast (ref $itable2) (local.get $ref) ;; this can be inferred to be the global $itable2 ) ) diff --git a/test/lit/passes/gufa-cast-all.wast b/test/lit/passes/gufa-cast-all.wast index b57b996a0..1e33c7b74 100644 --- a/test/lit/passes/gufa-cast-all.wast +++ b/test/lit/passes/gufa-cast-all.wast @@ -35,7 +35,7 @@ ;; CHECK-NEXT: (struct.new_default $B) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -104,7 +104,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $none_=>_none + ;; CHECK-NEXT: (ref.cast (ref $none_=>_none) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/gufa-extern.wast b/test/lit/passes/gufa-extern.wast index 5f293409f..e7a38b7ac 100644 --- a/test/lit/passes/gufa-extern.wast +++ b/test/lit/passes/gufa-extern.wast @@ -8,7 +8,7 @@ ;; CHECK: (func $externals (type $externref_anyref_=>_none) (param $ext externref) (param $any anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast struct + ;; CHECK-NEXT: (ref.cast (ref struct) ;; CHECK-NEXT: (extern.internalize ;; CHECK-NEXT: (local.get $ext) ;; CHECK-NEXT: ) @@ -24,7 +24,7 @@ ;; We must not turn these into unreachable code, as the function is ;; exported. (drop - (ref.cast struct + (ref.cast (ref struct) (extern.internalize (local.get $ext) ) @@ -58,7 +58,7 @@ ;; This is not exported, so the params are dead code, and can be turned ;; unreachable. (drop - (ref.cast struct + (ref.cast (ref struct) (extern.internalize (local.get $ext) ) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index 7dacf132d..011298c6e 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -54,7 +54,7 @@ (ref.is_null (loop $loop (result (ref func)) (nop) - (ref.cast func + (ref.cast (ref func) (ref.as_non_null (ref.null func) ) @@ -875,7 +875,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (array.new_fixed $vector + ;; CHECK-NEXT: (array.new_fixed $vector 2 ;; CHECK-NEXT: (f64.const 1.1) ;; CHECK-NEXT: (f64.const 2.2) ;; CHECK-NEXT: ) @@ -903,7 +903,7 @@ ) (drop (ref.as_non_null - (array.new_fixed $vector + (array.new_fixed $vector 2 (f64.const 1.1) (f64.const 2.2) ) @@ -1042,7 +1042,7 @@ ;; trapping contents in ref.cast, but not br_on_cast, so test both. (drop (struct.get $parent 0 - (ref.cast $parent + (ref.cast (ref $parent) (struct.new $unrelated) ) ) @@ -1101,7 +1101,7 @@ ;; CHECK-NEXT: (br $block1 ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1153,7 +1153,7 @@ (drop (block $block (result (ref null $child)) (br $block - (ref.cast null $child + (ref.cast (ref null $child) (ref.null $parent) ) ) @@ -1664,7 +1664,7 @@ (drop (ref.as_non_null (array.get $something-child - (ref.cast $something-child + (ref.cast (ref $something-child) (array.new_default $something (i32.const 10) ) @@ -2486,7 +2486,7 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $substruct + ;; CHECK-NEXT: (ref.cast (ref $substruct) ;; CHECK-NEXT: (struct.new $substruct ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.const 2) @@ -2494,7 +2494,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $subsubstruct + ;; CHECK-NEXT: (ref.cast (ref $subsubstruct) ;; CHECK-NEXT: (struct.new $subsubstruct ;; CHECK-NEXT: (i32.const 3) ;; CHECK-NEXT: (i32.const 4) @@ -2507,7 +2507,7 @@ ;; The cast here will fail, and the ref.cast null allows nothing through, so we ;; can emit an unreachable here. (drop - (ref.cast $substruct + (ref.cast (ref $substruct) (struct.new $struct (i32.const 0) ) @@ -2516,7 +2516,7 @@ ;; This cast of a type to itself can succeed (in fact, it will), so we make ;; no changes here. (drop - (ref.cast $substruct + (ref.cast (ref $substruct) (struct.new $substruct (i32.const 1) (i32.const 2) @@ -2525,7 +2525,7 @@ ) ;; This cast of a subtype will also succeed. As above, we make no changes. (drop - (ref.cast $substruct + (ref.cast (ref $substruct) (struct.new $subsubstruct (i32.const 3) (i32.const 4) @@ -2539,7 +2539,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $import) @@ -2554,7 +2554,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (select (result i31ref) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (i31.new @@ -2568,7 +2568,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (select (result (ref null $struct)) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (struct.new $struct @@ -2583,7 +2583,7 @@ ;; Only a null can flow through the cast, which we can infer for the value ;; of the cast. (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (select (ref.null $struct) (ref.null $struct) @@ -2597,7 +2597,7 @@ ;; to null, but it is dropped right before we return a null, so that has no ;; benefit in this case.) (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (select (ref.null $struct) (i31.new (i32.const 0)) @@ -2607,7 +2607,7 @@ ) ;; A null or a $struct may arrive, and so we cannot do anything here. (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (select (ref.null $struct) (struct.new $struct @@ -2621,7 +2621,7 @@ ;; CHECK: (func $test-cones (type $i32_=>_none) (param $x i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (select (result (ref null $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 0) @@ -2632,7 +2632,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 1) @@ -2646,7 +2646,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $substruct + ;; CHECK-NEXT: (ref.cast (ref $substruct) ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 4) @@ -2666,7 +2666,7 @@ (func $test-cones (export "test-cones") (param $x i32) ;; The input to the ref.cast null is potentially null, so we cannot infer here. (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (select (struct.new $struct (i32.const 0) @@ -2679,7 +2679,7 @@ ;; The input to the ref.cast is either $struct or $substruct, both of which ;; work, so we cannot optimize anything here away. (drop - (ref.cast $struct + (ref.cast (ref $struct) (select (struct.new $struct (i32.const 1) @@ -2695,7 +2695,7 @@ ;; As above, but now we test with $substruct, so one possibility fails and ;; one succeeds. We cannot infer here either. (drop - (ref.cast $substruct + (ref.cast (ref $substruct) (select (struct.new $struct (i32.const 4) @@ -2712,7 +2712,7 @@ ;; can infer an unreachable. The combination of these two is a cone from ;; $struct of depth 1, which does not overlap with $subsubstruct. (drop - (ref.cast $subsubstruct + (ref.cast (ref $subsubstruct) (select (struct.new $struct (i32.const 7) @@ -2742,7 +2742,7 @@ ;; This cast will fail: we know the exact type of the reference, and it is ;; not a subtype. (drop - (ref.test $substruct + (ref.test (ref $substruct) (struct.new $struct (i32.const 0) ) @@ -2750,7 +2750,7 @@ ) ;; Casting a thing to itself must succeed. (drop - (ref.test $substruct + (ref.test (ref $substruct) (struct.new $substruct (i32.const 1) (i32.const 2) @@ -2759,7 +2759,7 @@ ) ;; Casting a thing to a supertype must succeed. (drop - (ref.test $substruct + (ref.test (ref $substruct) (struct.new $subsubstruct (i32.const 3) (i32.const 4) @@ -2771,7 +2771,7 @@ ;; CHECK: (func $ref.test-inexact (type $i32_=>_none) (param $x i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $struct + ;; CHECK-NEXT: (ref.test (ref $struct) ;; CHECK-NEXT: (select (result (ref null $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 0) @@ -2785,7 +2785,7 @@ ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $substruct + ;; CHECK-NEXT: (ref.test (ref $substruct) ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 4) @@ -2805,7 +2805,7 @@ (func $ref.test-inexact (export "ref.test-inexact") (param $x i32) ;; The input to the ref.test is potentially null, so we cannot infer here. (drop - (ref.test $struct + (ref.test (ref $struct) (select (struct.new $struct (i32.const 0) @@ -2820,7 +2820,7 @@ ;; combination of those two types is a cone on $struct of depth 1, and that ;; cone is 100% a subtype of $struct, so the test will succeed. (drop - (ref.test $struct + (ref.test (ref $struct) (select (struct.new $struct (i32.const 1) @@ -2836,7 +2836,7 @@ ;; As above, but now we test with $substruct, so one possibility fails and ;; one succeeds. We cannot infer here. (drop - (ref.test $substruct + (ref.test (ref $substruct) (select (struct.new $struct (i32.const 4) @@ -2853,7 +2853,7 @@ ;; can infer a 0. The combination of these two is a cone from $struct of ;; depth 1, which does not overlap with $subsubstruct. (drop - (ref.test $subsubstruct + (ref.test (ref $subsubstruct) (select (struct.new $struct (i32.const 7) @@ -3578,7 +3578,7 @@ ;; CHECK: (func $foo (type $none_=>_ref|$B|) (result (ref $B)) ;; CHECK-NEXT: (local $A (ref null $A)) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.tee $A ;; CHECK-NEXT: (struct.new $B @@ -3594,7 +3594,7 @@ ;; Read the following from the most nested comment first. - (ref.cast $B ;; if we mistakenly think this contains content of + (ref.cast (ref $B) ;; if we mistakenly think this contains content of ;; type $A, it would trap, but it should not, and we ;; have nothing to optimize here (ref.as_non_null ;; also $B, based on the child's *contents* (not type!) @@ -3674,14 +3674,14 @@ ;; CHECK-NEXT: (local $bytes (ref null $bytes)) ;; CHECK-NEXT: (local $chars (ref null $chars)) ;; CHECK-NEXT: (local.set $bytes - ;; CHECK-NEXT: (array.new_fixed $bytes + ;; CHECK-NEXT: (array.new_fixed $bytes 1 ;; CHECK-NEXT: (i31.new ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $chars - ;; CHECK-NEXT: (array.new_fixed $chars + ;; CHECK-NEXT: (array.new_fixed $chars 1 ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -3713,12 +3713,12 @@ ;; which means two things are possible in $chars, and we can't optimize ;; there. (local.set $bytes - (array.new_fixed $bytes + (array.new_fixed $bytes 1 (i31.new (i32.const 0)) ) ) (local.set $chars - (array.new_fixed $chars + (array.new_fixed $chars 1 (ref.null any) ) ) @@ -3762,14 +3762,14 @@ ;; CHECK-NEXT: (local $bytes (ref null $bytes)) ;; CHECK-NEXT: (local $chars (ref null $chars)) ;; CHECK-NEXT: (local.set $bytes - ;; CHECK-NEXT: (array.new_fixed $bytes + ;; CHECK-NEXT: (array.new_fixed $bytes 1 ;; CHECK-NEXT: (i31.new ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $chars - ;; CHECK-NEXT: (array.new_fixed $chars + ;; CHECK-NEXT: (array.new_fixed $chars 1 ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -3802,12 +3802,12 @@ (local $bytes (ref null $bytes)) (local $chars (ref null $chars)) (local.set $bytes - (array.new_fixed $bytes + (array.new_fixed $bytes 1 (i31.new (i32.const 0)) ) ) (local.set $chars - (array.new_fixed $chars + (array.new_fixed $chars 1 (ref.null any) ) ) @@ -4144,7 +4144,7 @@ ;; CHECK: (func $arrays (type $ref|$B|_=>_none) (param $B (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (array.len - ;; CHECK-NEXT: (array.new_fixed $B + ;; CHECK-NEXT: (array.new_fixed $B 2 ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) @@ -4154,7 +4154,7 @@ (func $arrays (param $B (ref $B)) (drop (array.len $B - (array.new_fixed $B + (array.new_fixed $B 2 (ref.null none) (ref.null none) ) @@ -5267,27 +5267,27 @@ ;; An imported global has a known type, at least, which in this case is ;; enough for us to infer a result of 1. (drop - (ref.test $A + (ref.test (ref $A) (global.get $A) ) ) ;; Likewise, a function result. (drop - (ref.test $A + (ref.test (ref $A) (call $A) ) ) ;; Likewise, a parameter to this function, which is exported, but we do ;; still know the type it will be called with, and can optimize to 1. (drop - (ref.test $A + (ref.test (ref $A) (local.get $A) ) ) ;; Likewise, an exported mutable global can be modified by the outside, but ;; the type remains known, and we can optimize to 1. (drop - (ref.test $A + (ref.test (ref $A) (global.get $A) ) ) @@ -5295,22 +5295,22 @@ ;; CHECK: (func $no (type $ref|$A|_=>_none) (param $A (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (global.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (call $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (global.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -5319,22 +5319,22 @@ ;; Identical to the above function, but now all tests are vs type $B. We ;; cannot optimize any of these, as all we know is the type is $A. (drop - (ref.test $B + (ref.test (ref $B) (global.get $A) ) ) (drop - (ref.test $B + (ref.test (ref $B) (call $A) ) ) (drop - (ref.test $B + (ref.test (ref $B) (local.get $A) ) ) (drop - (ref.test $B + (ref.test (ref $B) (global.get $A) ) ) @@ -5401,7 +5401,7 @@ ;; But casting to $A will succeed, so the block is reachable, and also the ;; cast will return 1. (drop - (ref.test $A + (ref.test (ref $A) (block $A (result (ref $A)) (drop (br_on_cast $A anyref (ref $A) @@ -5659,7 +5659,7 @@ ;; CHECK: (export "func" (func $func)) ;; CHECK: (func $func (type $none_=>_ref|$A|) (result (ref $A)) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (call $get-B-def-any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -5667,7 +5667,7 @@ ;; Call a function that actually returns a B, though it is defined as ;; returning an anyref. Then cast it to A. We can infer that it will be a B, ;; so we can cast to B here instead. - (ref.cast $A + (ref.cast (ref $A) (call $get-B-def-any) ) ) @@ -5697,7 +5697,7 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -5705,7 +5705,7 @@ (func $called (param $x (ref null $A)) ;; The param is cast. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -5713,14 +5713,15 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $caller (export "out") (param $any anyref) (call $called - (ref.cast $A ;; This cast will could be refined with TNH, since we call a + (ref.cast (ref $A) + ;; This cast will could be refined with TNH, since we call a ;; function that casts (so if we do not trap as TNH assumes, ;; we must be sending in a $B). But without that flag we do ;; nothing. diff --git a/test/lit/passes/gufa-tnh-closed.wast b/test/lit/passes/gufa-tnh-closed.wast index dc13ca3bb..bf6de769c 100644 --- a/test/lit/passes/gufa-tnh-closed.wast +++ b/test/lit/passes/gufa-tnh-closed.wast @@ -48,7 +48,7 @@ (func $caller (export "out") (param $x funcref) ;; This call must trap: the only function of the right type will trap. (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -93,7 +93,7 @@ (func $caller (export "out") (param $x funcref) ;; No function exists of type $A, so this will trap. (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -130,7 +130,7 @@ (func $caller (export "out") (param $x funcref) ;; This must call $possible. (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -174,7 +174,7 @@ (func $caller (export "out") (param $x funcref) ;; This must call $possible, as the trapping function won't be called. (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -214,14 +214,14 @@ ;; CHECK: (func $caller (type $funcref_=>_none) (param $x funcref) ;; CHECK-NEXT: (call_ref $A - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $caller (export "out") (param $x funcref) (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -267,7 +267,7 @@ ;; CHECK: (func $caller (type $funcref_=>_none) (param $x funcref) ;; CHECK-NEXT: (call_ref $A - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -279,13 +279,13 @@ ;; A has one function, but it has a subtype with another, so we cannot ;; optimize (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) ;; The second call can be optimized, as B has just one function. (call_ref $B - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -321,14 +321,14 @@ ;; CHECK: (func $possible-Y1 (type $A) (param $ref anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-Y1 (type $A) (param $ref anyref) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref) ) ) @@ -336,14 +336,14 @@ ;; CHECK: (func $possible-Y2 (type $A) (param $ref anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y2 + ;; CHECK-NEXT: (ref.cast (ref $Y2) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-Y2 (type $A) (param $ref anyref) (drop - (ref.cast $Y2 + (ref.cast (ref $Y2) (local.get $ref) ) ) @@ -360,7 +360,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call_ref $A ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -375,21 +375,21 @@ ;; calling possible-Y1. (call_ref $A (struct.new $Y1) - (ref.cast $A + (ref.cast (ref $A) (local.get $func1) ) ) ;; Inverse of the above: we must call possible-Y2. (call_ref $A (struct.new $Y2) - (ref.cast $A + (ref.cast (ref $A) (local.get $func2) ) ) ;; This can call either one, and cannot be optimized. (call_ref $A (local.get $struct) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -450,14 +450,14 @@ ;; CHECK: (func $possible-Y1 (type $A) (param $ref anyref) (param $ref2 anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-Y1 (type $A) (param $ref anyref) (param $ref2 anyref) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref) ) ) @@ -465,14 +465,14 @@ ;; CHECK: (func $possible-Y2 (type $A) (param $ref anyref) (param $ref2 anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y2 + ;; CHECK-NEXT: (ref.cast (ref $Y2) ;; CHECK-NEXT: (local.get $ref2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-Y2 (type $A) (param $ref anyref) (param $ref2 anyref) (drop - (ref.cast $Y2 + (ref.cast (ref $Y2) (local.get $ref2) ;; this changed from ref to ref2. ) ) @@ -492,7 +492,7 @@ ;; CHECK-NEXT: (call_ref $A ;; CHECK-NEXT: (struct.new_default $Y1) ;; CHECK-NEXT: (struct.new_default $Y2) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -520,7 +520,7 @@ (call_ref $A (struct.new $Y1) (struct.new $Y1) - (ref.cast $A + (ref.cast (ref $A) (local.get $func1) ) ) @@ -529,7 +529,7 @@ (call_ref $A (struct.new $Y2) (struct.new $Y2) - (ref.cast $A + (ref.cast (ref $A) (local.get $func2) ) ) @@ -538,7 +538,7 @@ (call_ref $A (struct.new $Y1) (struct.new $Y2) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -546,7 +546,7 @@ (call_ref $A (struct.new $Y2) (struct.new $Y1) - (ref.cast $A + (ref.cast (ref $A) (local.get $func4) ) ) @@ -556,14 +556,14 @@ ;; CHECK-NEXT: (call_ref $A ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call_ref $A ;; CHECK-NEXT: (struct.new_default $Y1) ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -580,7 +580,7 @@ ;; CHECK-NEXT: (call_ref $A ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: (struct.new_default $Y2) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -597,7 +597,7 @@ (call_ref $A (local.get $struct) (local.get $struct) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -605,7 +605,7 @@ (call_ref $A (struct.new $Y1) (local.get $struct) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -613,7 +613,7 @@ (call_ref $A (struct.new $Y2) (local.get $struct) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -621,7 +621,7 @@ (call_ref $A (local.get $struct) (struct.new $Y1) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -629,7 +629,7 @@ (call_ref $A (local.get $struct) (struct.new $Y2) - (ref.cast $A + (ref.cast (ref $A) (local.get $func3) ) ) @@ -684,54 +684,54 @@ ;; CHECK: (func $possible-1 (type $A) (param $ref anyref) (param $ref2 anyref) (param $ref3 anyref) (param $ref4 anyref) (param $ref5 anyref) (param $ref6 anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref5) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref6) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-1 (type $A) (param $ref anyref) (param $ref2 anyref) (param $ref3 anyref) (param $ref4 anyref) (param $ref5 anyref) (param $ref6 anyref) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref) ) ) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref2) ) ) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref4) ) ) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref5) ) ) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref6) ) ) @@ -739,54 +739,54 @@ ;; CHECK: (func $possible-2 (type $A) (param $ref anyref) (param $ref2 anyref) (param $ref3 anyref) (param $ref4 anyref) (param $ref5 anyref) (param $ref6 anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref5) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y2 + ;; CHECK-NEXT: (ref.cast (ref $Y2) ;; CHECK-NEXT: (local.get $ref6) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-2 (type $A) (param $ref anyref) (param $ref2 anyref) (param $ref3 anyref) (param $ref4 anyref) (param $ref5 anyref) (param $ref6 anyref) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref) ) ) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref3) ) ) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref4) ) ) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref5) ) ) (drop - (ref.cast $Y2 + (ref.cast (ref $Y2) (local.get $ref6) ) ) @@ -794,25 +794,25 @@ ;; CHECK: (func $caller1 (type $anyref_anyref_anyref_anyref_anyref_anyref_funcref_=>_none) (param $ref1 anyref) (param $ref2 anyref) (param $ref3 anyref) (param $ref4 anyref) (param $ref5 anyref) (param $ref6 anyref) (param $func funcref) ;; CHECK-NEXT: (call_ref $A - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref1) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null any + ;; CHECK-NEXT: (ref.cast anyref ;; CHECK-NEXT: (local.get $ref2) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null any + ;; CHECK-NEXT: (ref.cast anyref ;; CHECK-NEXT: (local.get $ref3) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref4) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref5) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref6) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -831,30 +831,30 @@ ;; on the call targets. (call_ref $A ;; The first param is cast to $X in both targets, so we can apply that. - (ref.cast null any + (ref.cast anyref (local.get $ref1) ) ;; The second and third are cast to $X just in one of them, so we do ;; nothing. - (ref.cast null any + (ref.cast anyref (local.get $ref2) ) - (ref.cast null any + (ref.cast anyref (local.get $ref3) ) ;; The fourth and fifth are cast to $X and $Y1, so we can apply the LUB, ;; which is $X. - (ref.cast null any + (ref.cast anyref (local.get $ref4) ) - (ref.cast null any + (ref.cast anyref (local.get $ref5) ) ;; The last is cast to $Y1 and $Y2, and the LUB is $X. - (ref.cast null any + (ref.cast anyref (local.get $ref6) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $func) ) ) @@ -910,24 +910,24 @@ ;; CHECK: (func $possible-1 (type $A) (param $ref (ref null $X)) (param $ref2 (ref null $X)) (param $ref3 (ref null $X)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-1 (type $A) (param $ref (ref null $X)) (param $ref2 (ref null $X)) (param $ref3 (ref null $X)) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref2) ) ) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref3) ) ) @@ -935,34 +935,34 @@ ;; CHECK: (func $possible-2 (type $A) (param $ref (ref null $X)) (param $ref2 (ref null $X)) (param $ref3 (ref null $X)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $possible-2 (type $A) (param $ref (ref null $X)) (param $ref2 (ref null $X)) (param $ref3 (ref null $X)) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref) ) ) (drop - (ref.cast $X + (ref.cast (ref $X) (local.get $ref2) ) ) (drop - (ref.cast $Y1 + (ref.cast (ref $Y1) (local.get $ref3) ) ) @@ -970,16 +970,16 @@ ;; CHECK: (func $caller1 (type $anyref_anyref_anyref_anyref_anyref_anyref_funcref_=>_none) (param $ref1 anyref) (param $ref2 anyref) (param $ref3 anyref) (param $ref4 anyref) (param $ref5 anyref) (param $ref6 anyref) (param $func funcref) ;; CHECK-NEXT: (call_ref $A - ;; CHECK-NEXT: (ref.cast null $X + ;; CHECK-NEXT: (ref.cast (ref null $X) ;; CHECK-NEXT: (local.get $ref1) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $X + ;; CHECK-NEXT: (ref.cast (ref $X) ;; CHECK-NEXT: (local.get $ref2) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (local.get $ref3) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -998,19 +998,19 @@ ;; on the call targets. (call_ref $A ;; The first is cast to $Y1 in only one target, so we can do nothing. - (ref.cast null $X + (ref.cast (ref null $X) (local.get $ref1) ) ;; The second is cast to $X in one $Y1 in the other, so we can refine the ;; nullability at least. - (ref.cast null $X + (ref.cast (ref null $X) (local.get $ref2) ) ;; The third parameter is cast to $Y1 in both, so we can optimize to that. - (ref.cast null $X + (ref.cast (ref null $X) (local.get $ref3) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $func) ) ) @@ -1060,14 +1060,14 @@ ;; CHECK: (func $called (type $A) (param $ref anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $Y1 + ;; CHECK-NEXT: (ref.cast (ref null $Y1) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (type $A) (param $ref anyref) (drop - (ref.cast null $Y1 + (ref.cast (ref null $Y1) (local.get $ref) ) ) @@ -1081,7 +1081,7 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $Y1 + ;; CHECK-NEXT: (ref.cast (ref $Y1) ;; CHECK-NEXT: (select (result (ref $X)) ;; CHECK-NEXT: (struct.new_default $Y1) ;; CHECK-NEXT: (struct.new_default $Y2) @@ -1114,7 +1114,7 @@ ;; Only Y1 would succeed, so we can infer that the cast can be to $Y1. (call $called - (ref.cast $X + (ref.cast (ref $X) (select (result (ref $X)) (struct.new $Y1) (struct.new $Y2) diff --git a/test/lit/passes/gufa-tnh.wast b/test/lit/passes/gufa-tnh.wast index e1dee4773..13e51efd5 100644 --- a/test/lit/passes/gufa-tnh.wast +++ b/test/lit/passes/gufa-tnh.wast @@ -23,17 +23,17 @@ ;; CHECK: (func $called (type $funcref_funcref_funcref_funcref_=>_none) (param $x funcref) (param $no-cast funcref) (param $y funcref) (param $z funcref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $z) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -43,17 +43,17 @@ ;; optimization in the caller. Nothing significant changes here in this ;; function. (drop - (ref.cast func + (ref.cast (ref func) (local.get $x) ) ) (drop - (ref.cast func + (ref.cast (ref func) (local.get $y) ) ) (drop - (ref.cast func + (ref.cast (ref func) (local.get $z) ) ) @@ -69,26 +69,26 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null func + ;; CHECK-NEXT: (ref.cast funcref ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $f) - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $f) - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast func + ;; CHECK-NEXT: (ref.cast (ref func) ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -120,28 +120,28 @@ ;; are cast both here and in the called function. Those casts will lose the ;; "null" and become non-nullable. (call $called - (ref.cast null func + (ref.cast funcref (local.get $f) ) - (ref.cast null func + (ref.cast funcref (local.get $f) ) (local.get $f) - (ref.cast null func + (ref.cast funcref (local.get $f) ) ) ;; Another call, but with different casts. (call $called - (ref.cast func ;; this is now non-nullable, and will not change + (ref.cast funcref ;; this is now non-nullable, and will not change (local.get $f) ) (local.get $f) ;; this is not cast, and will not change. - (ref.cast null func + (ref.cast funcref (local.get $f) ;; this is now cast, and will be optimized. ) - (ref.cast null func ;; this is the same as before, and will be optimized. + (ref.cast funcref ;; this is the same as before, and will be optimized. (local.get $f) ) ) @@ -199,7 +199,7 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -207,7 +207,7 @@ (func $called (param $x (ref null $A)) ;; Cast the input to a $B, which will help the caller. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -217,20 +217,20 @@ ;; CHECK-NEXT: (local $x (ref null $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $A 0 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -249,7 +249,7 @@ ;; analysis will use that fact in the local.get $x below. (call $called (local.tee $x - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -259,13 +259,13 @@ ;; $any appears.) (drop (struct.get $A 0 - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) ) (drop - (ref.test $B + (ref.test (ref $B) (local.get $any) ) ) @@ -277,7 +277,7 @@ ) ) (drop - (ref.test $B + (ref.test (ref $B) (local.get $x) ) ) @@ -326,7 +326,7 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -334,7 +334,7 @@ (func $called (param $x (ref null $A)) ;; Cast the input to a $B, which will help the caller. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -397,7 +397,7 @@ ;; CHECK-NEXT: (i32.const 1337) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.tee $local ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -416,7 +416,7 @@ (i32.const 1337) ) (drop - (ref.cast $B + (ref.cast (ref $B) ;; This local.tee should not stop us from optimizing. (local.tee $local (local.get $x) @@ -429,7 +429,7 @@ ;; CHECK-NEXT: (local $x (ref null $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -439,7 +439,7 @@ (local $x (ref null $A)) (call $called (local.tee $x - (ref.cast $A ;; this cast will be refined + (ref.cast (ref $A) ;; this cast will be refined (local.get $any) ) ) @@ -468,7 +468,7 @@ ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -481,7 +481,7 @@ (return) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -491,7 +491,7 @@ ;; CHECK-NEXT: (local $x (ref null $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -501,7 +501,7 @@ (local $x (ref null $A)) (call $called (local.tee $x - (ref.cast $A ;; this cast will *not* be refined + (ref.cast (ref $A) ;; this cast will *not* be refined (local.get $any) ) ) @@ -524,14 +524,14 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x (ref null $A)) (drop - (ref.cast $A ;; This cast only removes nullability. + (ref.cast (ref $A) ;; This cast only removes nullability. (local.get $x) ) ) @@ -541,7 +541,7 @@ ;; CHECK-NEXT: (local $x (ref null $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -551,7 +551,8 @@ (local $x (ref null $A)) (call $called (local.tee $x - (ref.cast $A ;; This cast will *not* be refined, as it is already non- + (ref.cast (ref $A) + ;; This cast will *not* be refined, as it is already non- ;; nullable here, and the other cast did not improve the ;; heap type. (local.get $any) @@ -580,12 +581,12 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -595,12 +596,12 @@ ;; the general case as other optimizations will leave the most-refined one. ;; (But in this test, it is less optimal actually.) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) @@ -610,7 +611,7 @@ ;; CHECK-NEXT: (local $x (ref null $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -620,7 +621,7 @@ (local $x (ref null $A)) (call $called (local.tee $x - (ref.cast $A ;; this cast will be refined to $B. + (ref.cast (ref $A) ;; this cast will be refined to $B. (local.get $any) ) ) @@ -644,17 +645,17 @@ ;; CHECK: (func $called (type $ref?|$A|_ref?|$A|_ref?|$A|_=>_none) (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $z) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -662,17 +663,17 @@ (func $called (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; All parameters are cast. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $y) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $z) ) ) @@ -681,7 +682,7 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (block (result (ref $A)) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -690,12 +691,12 @@ ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (block (result (ref $A)) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -709,7 +710,7 @@ ;; first. (call $called (block (result (ref $A)) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -718,12 +719,12 @@ (i32.const 0) (return) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) (block (result (ref $A)) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -747,7 +748,7 @@ ;; CHECK: (func $called (type $ref?|$A|_ref?|$A|_ref?|$A|_=>_none) (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -755,14 +756,14 @@ ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $z) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -771,7 +772,7 @@ (local.get $y) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $z) ) ) @@ -780,7 +781,7 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (block (result (ref $A)) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -789,12 +790,12 @@ ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (return) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (block (result (ref $A)) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -806,7 +807,7 @@ ;; we can still refine the last one. (call $called (block (result (ref $A)) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -815,12 +816,12 @@ (i32.const 0) (return) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) (block (result (ref $A)) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -849,17 +850,17 @@ ;; CHECK: (func $called (type $ref?|$A|_ref?|$A|_ref?|$A|_=>_none) (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $z) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -867,17 +868,17 @@ (func $called (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; All parameters are cast. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $y) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $z) ) ) @@ -885,28 +886,28 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (call $get-any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $caller (export "out") (param $any anyref) (call $called - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) - (ref.cast $A + (ref.cast (ref $A) ;; This call might transfer control flow (if it throws), so we ;; can't optimize before it, but the last two casts will become $B. (call $get-any) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -934,17 +935,17 @@ ;; CHECK: (func $called (type $ref?|$A|_ref?|$A|_ref?|$A|_=>_none) (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $z) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -952,17 +953,17 @@ (func $called (param $x (ref null $A)) (param $y (ref null $A)) (param $z (ref null $A)) ;; All parameters are cast. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $y) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $z) ) ) @@ -970,24 +971,24 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if (result (ref $A)) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (return) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $caller (export "out") (param $any anyref) (call $called - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ;; One if arm transfers control flow, so while we have a fallthrough @@ -997,11 +998,11 @@ (if (result (ref $A)) (i32.const 0) (return) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -1024,14 +1025,14 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x (ref null $A)) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -1093,7 +1094,7 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1101,7 +1102,7 @@ (func $caller (export "out") (param $any anyref) (call $called ;; This cast can become non-nullable. - (ref.cast null $A + (ref.cast (ref null $A) (local.get $any) ) ) @@ -1133,7 +1134,7 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1141,7 +1142,7 @@ (func $called (param $x (ref null $A)) ;; This function casts the A to a B. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -1188,7 +1189,7 @@ ;; CHECK-NEXT: (local $temp-any anyref) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $temp-C - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (local.tee $temp-any ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) @@ -1200,14 +1201,14 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $B 0 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $temp-any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $A 0 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1218,7 +1219,8 @@ (local $temp-any anyref) (call $called (local.tee $temp-C - (ref.cast $C ;; This cast is already more refined than even the called + (ref.cast (ref $C) + ;; This cast is already more refined than even the called ;; function casts to. It should stay as it is. (local.tee $temp-any (local.get $any) @@ -1228,7 +1230,7 @@ ) (drop (struct.get $A 0 ;; the reference contains a C, so this value is 30. - (ref.cast $A + (ref.cast (ref $A) (local.get $temp-C) ) ) @@ -1239,7 +1241,7 @@ ;; value (which can be 20 or 30). ;; TODO: We can infer from the ref.cast $C in this ;; function backwards into the tee and its value. - (ref.cast $A + (ref.cast (ref $A) (local.get $temp-any) ) ) @@ -1247,7 +1249,7 @@ (drop (struct.get $A 0 ;; We have not inferred anything about the param, so this ;; is not optimized yet, but it could be. TODO - (ref.cast $A + (ref.cast (ref $A) (local.get $any) ) ) @@ -1258,7 +1260,7 @@ ;; CHECK-NEXT: (local $temp (ref $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $temp - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1273,7 +1275,7 @@ (local $temp (ref $A)) (call $called (local.tee $temp - (ref.cast $B ;; This cast is equal to the called cast. It should remain. + (ref.cast (ref $B) ;; This cast is equal to the called cast. It should remain. (local.get $any) ) ) @@ -1289,7 +1291,7 @@ ;; CHECK-NEXT: (local $temp (ref $A)) ;; CHECK-NEXT: (call $called ;; CHECK-NEXT: (local.tee $temp - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1304,7 +1306,7 @@ (local $temp (ref $A)) (call $called (local.tee $temp - (ref.cast $A ;; This cast is less refined, and can be improved to B. + (ref.cast (ref $A) ;; This cast is less refined, and can be improved to B. (local.get $any) ) ) @@ -1343,14 +1345,14 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B1 + ;; CHECK-NEXT: (ref.cast (ref $B1) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x (ref null $A)) (drop - (ref.cast $B1 + (ref.cast (ref $B1) (local.get $x) ) ) @@ -1424,7 +1426,7 @@ ;; This casts a local in the entry block, but it is not a parameter, so we ;; should ignore it and not error. (drop - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) @@ -1457,14 +1459,14 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x (ref null $A)) (drop - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) @@ -1472,32 +1474,32 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast null $C + ;; CHECK-NEXT: (ref.cast (ref null $C) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1506,35 +1508,35 @@ ;; A non-nullable A passed into a cast of B means this value must be a non- ;; nullable B. (call $called - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) ;; This will be refined to (nullable) B. (call $called - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) ;; Casts of B remain the same. (call $called - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (call $called - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) ;; Casts of C remain the same. (call $called - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) (call $called - (ref.cast null $C + (ref.cast (ref null $C) (local.get $x) ) ) @@ -1560,14 +1562,14 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $x (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x (ref null $A)) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -1575,32 +1577,32 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1608,37 +1610,37 @@ (func $caller (export "out") (param $x anyref) ;; Casts of A are refined. (call $called - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) ;; This will be refined to B. (call $called - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) ;; Casts of B turn or stay as non-nullable B. (call $called - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (call $called - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) ;; This cast of C remains the same. (call $called - (ref.cast $C + (ref.cast (ref $C) (local.get $x) ) ) ;; A nullable C passed into a cast of non-null B means this value must be a ;; non-nullable C. (call $called - (ref.cast null $C + (ref.cast (ref null $C) (local.get $x) ) ) @@ -1656,14 +1658,14 @@ ;; CHECK: (func $called (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $called (param $x anyref) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -1671,7 +1673,7 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1679,7 +1681,7 @@ (func $caller (export "out") (param $x anyref) (call $called ;; This will be refined to a non-nullable cast. - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1761,7 +1763,7 @@ ;; CHECK-NEXT: (i32.const 15) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $A + ;; CHECK-NEXT: (ref.test (ref $A) ;; CHECK-NEXT: (local.get $ref.test) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1831,7 +1833,7 @@ (i32.const 15) ) (drop - (ref.test $A + (ref.test (ref $A) (local.get $ref.test) ) ) @@ -1839,37 +1841,37 @@ ;; CHECK: (func $caller (type $anyref_=>_none) (param $any anyref) ;; CHECK-NEXT: (call $called - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1878,37 +1880,37 @@ ;; All these casts will be refined to non-nullable, aside from the last ;; param which is but a ref.test. (call $called - (ref.cast null $A + (ref.cast (ref null $A) (local.get $any) ) - (ref.cast null $A + (ref.cast (ref null $A) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $any) ) - (ref.cast null $C + (ref.cast (ref null $C) (local.get $any) ) - (ref.cast null $A + (ref.cast (ref null $A) (local.get $any) ) ) @@ -1936,7 +1938,7 @@ ;; CHECK: (func $caller (type $funcref_=>_none) (param $x funcref) ;; CHECK-NEXT: (call_ref $A - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1947,7 +1949,7 @@ ;; TODO: We could analyze publicly visible tables, exports, etc. to see ;; whether any more functions could be possible even in an open world. (call_ref $A - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -1974,7 +1976,7 @@ ;; CHECK: (func $called (type $ref?|$A|_=>_none) (param $0 (ref null $A)) ;; CHECK-NEXT: (call $import-throw) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1985,7 +1987,7 @@ ;; case we'd never reach the cast). (call $import-throw) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $0) ) ) diff --git a/test/lit/passes/gufa-vs-cfp.wast b/test/lit/passes/gufa-vs-cfp.wast index 0db24bbad..00c26815e 100644 --- a/test/lit/passes/gufa-vs-cfp.wast +++ b/test/lit/passes/gufa-vs-cfp.wast @@ -531,7 +531,7 @@ ;; As the get must trap, we can optimize to an unreachable here. (drop (struct.get $substruct 0 - (ref.cast $substruct + (ref.cast (ref $substruct) (call $create) ) ) @@ -590,7 +590,7 @@ (func $get (drop (struct.get $substruct 0 - (ref.cast $substruct + (ref.cast (ref $substruct) (call $create) ) ) @@ -644,7 +644,7 @@ ;; to $struct. But no null is possible since the local gets written a ;; non-null value before we get here, so we can optimize this to an ;; unreachable. - (ref.cast null $substruct + (ref.cast (ref null $substruct) (local.get $ref) ) ) @@ -803,7 +803,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $substruct + ;; CHECK-NEXT: (ref.cast (ref $substruct) ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 10) @@ -824,7 +824,7 @@ (drop (struct.get $struct 0 ;; This cast is added, ensuring only a $substruct can reach the get. - (ref.cast $substruct + (ref.cast (ref $substruct) (select (struct.new $struct (i32.const 10) @@ -876,7 +876,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $substruct 0 - ;; CHECK-NEXT: (ref.cast $substruct + ;; CHECK-NEXT: (ref.cast (ref $substruct) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -906,7 +906,7 @@ (struct.get $substruct 0 ;; This cast will be refined to be non-nullable, as the LocalGraph ;; analysis will show that it must be so. - (ref.cast null $substruct + (ref.cast (ref null $substruct) (local.get $ref) ) ) @@ -951,7 +951,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $substruct + ;; CHECK-NEXT: (ref.cast (ref $substruct) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -985,7 +985,7 @@ ;; analysis will show that it must be so. After that, the dropped ;; struct.get can be removed as it has no side effects (the only ;; possible effect was a trap on null). - (ref.cast null $substruct + (ref.cast (ref null $substruct) (local.get $ref) ) ) @@ -2044,7 +2044,7 @@ ) ;; CHECK: (func $set (type $none_=>_none) ;; CHECK-NEXT: (struct.set $C 0 - ;; CHECK-NEXT: (ref.cast $C + ;; CHECK-NEXT: (ref.cast (ref $C) ;; CHECK-NEXT: (call $create-C) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 20) @@ -2057,7 +2057,7 @@ ;; below. (Note that finalize will turn the cast into a cast of $C ;; automatically; that is not part of GUFA.) (struct.set $A 0 - (ref.cast $A + (ref.cast (ref $A) (call $create-C) ) (i32.const 20) ;; different value than in $create @@ -2625,7 +2625,7 @@ ;; CHECK: (type $none_=>_funcref (func (result funcref))) - ;; CHECK: (global $global (ref $itable) (array.new_fixed $itable + ;; CHECK: (global $global (ref $itable) (array.new_fixed $itable 2 ;; CHECK-NEXT: (struct.new $vtable ;; CHECK-NEXT: (ref.null nofunc) ;; CHECK-NEXT: ) @@ -2633,7 +2633,7 @@ ;; CHECK-NEXT: (ref.func $test) ;; CHECK-NEXT: ) ;; CHECK-NEXT: )) - (global $global (ref $itable) (array.new_fixed $itable + (global $global (ref $itable) (array.new_fixed $itable 2 (struct.new $vtable (ref.null func) ) diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast index 090ab4de0..20317763b 100644 --- a/test/lit/passes/heap2local.wast +++ b/test/lit/passes/heap2local.wast @@ -1907,7 +1907,7 @@ ;; CHECK-NEXT: (local $a (ref $A)) ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (local $2 (ref $A)) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (block (result (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) @@ -1933,7 +1933,7 @@ ;; precision, into a local.get of $A. After heap2local we'll end up using a ;; local of the type of $B's field which is more precise than $A's, and the ;; cast must be updated to be non-nullable. - (ref.cast null $B + (ref.cast (ref null $B) (struct.get $A 0 (local.tee $a (struct.new $B diff --git a/test/lit/passes/inlining-optimizing.wast b/test/lit/passes/inlining-optimizing.wast index a07d4aea6..870978e75 100644 --- a/test/lit/passes/inlining-optimizing.wast +++ b/test/lit/passes/inlining-optimizing.wast @@ -33,7 +33,7 @@ (call $0) (drop (call_ref $none_=>_i32 - (ref.cast $none_=>_i32 + (ref.cast (ref $none_=>_i32) (ref.func $0) ) ) diff --git a/test/lit/passes/inlining_vacuum_optimize-instructions.wast b/test/lit/passes/inlining_vacuum_optimize-instructions.wast index fbf6aac69..c524288e7 100644 --- a/test/lit/passes/inlining_vacuum_optimize-instructions.wast +++ b/test/lit/passes/inlining_vacuum_optimize-instructions.wast @@ -30,7 +30,7 @@ ;; CHECK-NEXT: ) (func $target (param $0 (ref null $A)) (drop - (ref.cast null $B + (ref.cast (ref null $B) (struct.get $A 0 (call $get-null) ) diff --git a/test/lit/passes/merge-similar-functions_all-features.wast b/test/lit/passes/merge-similar-functions_all-features.wast index 15929894f..661a55f66 100644 --- a/test/lit/passes/merge-similar-functions_all-features.wast +++ b/test/lit/passes/merge-similar-functions_all-features.wast @@ -50,7 +50,7 @@ ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (call $take-ref-null-array - ;; CHECK-NEXT: (array.new_fixed $[i8]) + ;; CHECK-NEXT: (array.new_fixed $[i8] 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $no-call-subtyping-same-operand-0 @@ -58,7 +58,7 @@ (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (call $take-ref-null-array - (array.new_fixed $[i8]) + (array.new_fixed $[i8] 0) ) ) ;; CHECK: (func $no-call-subtyping-same-operand-1 (type $none_=>_none) @@ -81,7 +81,7 @@ ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (call $take-ref-eq - ;; CHECK-NEXT: (array.new_fixed $[i8]) + ;; CHECK-NEXT: (array.new_fixed $[i8] 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $no-call-subtyping-same-operand-1 @@ -89,7 +89,7 @@ (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (nop) (call $take-ref-eq - (array.new_fixed $[i8]) + (array.new_fixed $[i8] 0) ) ) ) diff --git a/test/lit/passes/monomorphize.wast b/test/lit/passes/monomorphize.wast index 006cd1703..fe206b518 100644 --- a/test/lit/passes/monomorphize.wast +++ b/test/lit/passes/monomorphize.wast @@ -405,7 +405,7 @@ ;; ALWAYS: (func $refinable (type $ref|$A|_=>_none) (param $ref (ref $A)) ;; ALWAYS-NEXT: (local $x (ref $A)) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast $B + ;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) @@ -417,17 +417,17 @@ ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast $B + ;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast $B + ;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast $B + ;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) @@ -435,12 +435,12 @@ ;; CAREFUL: (func $refinable (type $ref|$A|_=>_none) (param $0 (ref $A)) ;; CAREFUL-NEXT: (local $1 (ref $A)) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast $B + ;; CAREFUL-NEXT: (ref.cast (ref $B) ;; CAREFUL-NEXT: (local.get $0) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast $B + ;; CAREFUL-NEXT: (ref.cast (ref $B) ;; CAREFUL-NEXT: (local.tee $1 ;; CAREFUL-NEXT: (select (result (ref $A)) ;; CAREFUL-NEXT: (local.get $0) @@ -451,12 +451,12 @@ ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast $B + ;; CAREFUL-NEXT: (ref.cast (ref $B) ;; CAREFUL-NEXT: (local.get $1) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast $B + ;; CAREFUL-NEXT: (ref.cast (ref $B) ;; CAREFUL-NEXT: (local.get $0) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) @@ -470,7 +470,7 @@ ;; cast will remain since we monomorphize without bothering to optimize and ;; see if there is any benefit.) (call $import - (ref.cast $B + (ref.cast (ref $B) (local.get $ref) ) ) @@ -485,18 +485,18 @@ ) ) (call $import - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (call $import - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) ;; Another use of $ref, also to avoid opts merging $x and $ref. (call $import - (ref.cast $B + (ref.cast (ref $B) (local.get $ref) ) ) @@ -506,7 +506,7 @@ ;; ALWAYS: (func $refinable_3 (type $ref|$B|_=>_none) (param $ref (ref $B)) ;; ALWAYS-NEXT: (local $x (ref $A)) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast $B +;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) @@ -518,17 +518,17 @@ ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast $B +;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast $B +;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast $B +;; ALWAYS-NEXT: (ref.cast (ref $B) ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) diff --git a/test/lit/passes/optimize-casts-noeh.wast b/test/lit/passes/optimize-casts-noeh.wast index 6cd6fa704..88c7ae203 100644 --- a/test/lit/passes/optimize-casts-noeh.wast +++ b/test/lit/passes/optimize-casts-noeh.wast @@ -9,7 +9,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -21,7 +21,7 @@ ;; CHECK-NEXT: ) (func $yes-past-call (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -38,7 +38,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -50,7 +50,7 @@ ;; CHECK-NEXT: ) (func $yes-past-return_call (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) diff --git a/test/lit/passes/optimize-casts-tnh.wast b/test/lit/passes/optimize-casts-tnh.wast index ced59bd0c..498d6849e 100644 --- a/test/lit/passes/optimize-casts-tnh.wast +++ b/test/lit/passes/optimize-casts-tnh.wast @@ -12,7 +12,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -21,7 +21,7 @@ ;; CHECK-NEXT: (i32.const 10) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -36,7 +36,7 @@ (i32.const 10) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) diff --git a/test/lit/passes/optimize-casts.wast b/test/lit/passes/optimize-casts.wast index 097f03c62..422734eb4 100644 --- a/test/lit/passes/optimize-casts.wast +++ b/test/lit/passes/optimize-casts.wast @@ -112,7 +112,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -128,7 +128,7 @@ ;; As $ref.as but with ref.casts: we should use the cast value after it has ;; been computed, in both gets. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -144,7 +144,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -161,7 +161,7 @@ ;; CHECK-NEXT: ) (func $not-past-set (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -181,7 +181,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -195,7 +195,7 @@ ;; CHECK-NEXT: ) (func $yes-past-call (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -213,7 +213,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -227,7 +227,7 @@ ;; CHECK-NEXT: ) (func $not-past-call_ref (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -246,7 +246,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $void) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -259,7 +259,7 @@ ) (call $void) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -273,7 +273,7 @@ ;; CHECK-NEXT: (ref.func $void) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -287,7 +287,7 @@ (ref.func $void) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -298,7 +298,7 @@ ;; CHECK-NEXT: (local $2 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -314,7 +314,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $2 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -328,7 +328,7 @@ ;; CHECK-NEXT: ) (func $best (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -345,7 +345,7 @@ (i32.const 20) ) (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -362,7 +362,7 @@ ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -371,7 +371,7 @@ ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -383,7 +383,7 @@ ;; As above, but with the casts reversed. Now we should use $B in both ;; gets. (drop - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -391,7 +391,7 @@ (local.get $x) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -404,7 +404,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (block (result (ref struct)) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -417,7 +417,7 @@ ;; CHECK-NEXT: ) (func $fallthrough (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) ;; We look through the block, and optimize. (block (result (ref struct)) (local.get $x) @@ -431,7 +431,7 @@ ;; CHECK: (func $past-basic-block (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -445,7 +445,7 @@ ;; CHECK-NEXT: ) (func $past-basic-block (param $x (ref struct)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -473,14 +473,14 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $4 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $5 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $b) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -512,12 +512,12 @@ (local.get $y) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $a) ) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $b) ) ) @@ -543,9 +543,9 @@ ;; CHECK: (func $move-cast-1 (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -555,7 +555,7 @@ ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -565,7 +565,7 @@ ;; The later cast to $B will be moved between ref.cast $A ;; and local.get $x. This will cause this ref.cast $A to be ;; converted to a second ref.cast $B due to ReFinalize(). - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -575,7 +575,7 @@ (drop ;; The most refined cast of $x is to $B, which we can move up to ;; the top and reuse from there. - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -584,16 +584,16 @@ ;; CHECK: (func $move-cast-2 (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -606,13 +606,13 @@ ;; As in $move-cast-1, the later cast to $B will be moved ;; between ref.cast $A and local.get $x, causing ref.cast $A ;; to be converted into a second ref.cast $B by ReFinalize(); - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop ;; This will be moved up to the first local.get $x. - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -625,18 +625,18 @@ ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -647,13 +647,13 @@ ) (drop ;; Converted to $B by ReFinalize(). - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop ;; This will be moved up to the first local.get $x. - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -663,18 +663,18 @@ ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -685,13 +685,13 @@ ) (drop ;; This will be moved up to the first local.get $x. - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop ;; Converted to $B by ReFinalize(). - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -701,13 +701,13 @@ ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -719,13 +719,13 @@ (drop ;; The first location is already the most refined cast, so nothing will be moved up. ;; (But we will save the cast to a local and re-use it below.) - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) (drop ;; Converted to $B by ReFinalize(). - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -738,7 +738,7 @@ ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -747,7 +747,7 @@ ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -755,7 +755,7 @@ (func $move-cast-6 (param $x (ref struct)) (drop ;; This is already the most refined cast, so nothing will be moved. - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -764,7 +764,7 @@ ) (drop ;; Converted to $B by ReFinalize(). - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -775,7 +775,7 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -787,7 +787,7 @@ (drop ;; Since we know $x is of type $B, this cast to a less refined type $A ;; will not be moved higher. - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -823,7 +823,7 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $D + ;; CHECK-NEXT: (ref.cast (ref $D) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -842,7 +842,7 @@ (local.get $x) ) (drop - (ref.cast $D + (ref.cast (ref $D) (block (result anyref) (local.get $x) ) @@ -915,20 +915,20 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $2 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $3 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -936,12 +936,12 @@ ;; CHECK-NEXT: (local.get $3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $3) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -965,7 +965,7 @@ (local.get $y) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -975,13 +975,13 @@ ) (drop ;; This can be moved past local.set $x. - (ref.cast $B + (ref.cast (ref $B) (local.get $y) ) ) (drop ;; This cannot be moved past local.set $x. - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -1044,7 +1044,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1052,7 +1052,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1069,7 +1069,7 @@ (ref.as_non_null ;; This will be converted to a non-nullable cast because the local we ;; save to in the optimization ($1) is now non-nullable. - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1081,14 +1081,14 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1108,7 +1108,7 @@ (drop ;; This is converted to ref.cast $A, because we will save $x to ;; a non-nullable $A local as part of the optimization. - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1124,7 +1124,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1136,7 +1136,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1157,7 +1157,7 @@ (drop ;; This is converted to ref.cast $A, because we will save $x to ;; a non-nullable $A local as part of the optimization. - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1165,7 +1165,7 @@ ;; CHECK: (func $unoptimizable-nested-casts (type $structref_=>_none) (param $x structref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -1176,7 +1176,7 @@ ;; No optimizations should be made here for this nested cast. ;; This test is here to ensure this. (drop - (ref.cast $B + (ref.cast (ref $B) (ref.as_non_null (local.get $x) ) @@ -1189,7 +1189,7 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.tee $x ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -1204,7 +1204,7 @@ ;; We do not move this ref.cast of $x because $x is set by the local.tee, ;; and we do not move casts past a set of a local index. This is treated ;; like a local.set and we do not have a special case for this. - (ref.cast $A + (ref.cast (ref $A) (local.tee $x (local.get $x) ) @@ -1217,13 +1217,13 @@ ;; CHECK-NEXT: (local $3 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $3 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.tee $a ;; CHECK-NEXT: (local.get $3) ;; CHECK-NEXT: ) @@ -1237,7 +1237,7 @@ ) (drop ;; We can move this ref.cast because the local.tee sets another local index. - (ref.cast $A + (ref.cast (ref $A) (local.tee $a (local.get $x) ) @@ -1249,18 +1249,18 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1273,12 +1273,12 @@ (local.get $x) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) @@ -1307,7 +1307,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1340,7 +1340,7 @@ ;; This cannot be moved earlier because it is blocked by ;; the if statement. All state information is cleared when ;; entering and leaving the if statement. - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) ) diff --git a/test/lit/passes/optimize-instructions-call_ref.wast b/test/lit/passes/optimize-instructions-call_ref.wast index 3b2ec2b54..5033eca3c 100644 --- a/test/lit/passes/optimize-instructions-call_ref.wast +++ b/test/lit/passes/optimize-instructions-call_ref.wast @@ -178,7 +178,7 @@ ;; call_ref that returns nothing with a call that returns an i32. In fact, we ;; end up optimizing the cast into an unreachable. (call_ref $none_=>_i32 - (ref.cast $none_=>_i32 + (ref.cast (ref $none_=>_i32) (ref.func $return-nothing) ) ) diff --git a/test/lit/passes/optimize-instructions-gc-iit.wast b/test/lit/passes/optimize-instructions-gc-iit.wast index e4694f4c7..6a1d7d2a3 100644 --- a/test/lit/passes/optimize-instructions-gc-iit.wast +++ b/test/lit/passes/optimize-instructions-gc-iit.wast @@ -34,7 +34,7 @@ ;; CHECK-NEXT: (local.get $child) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $child + ;; CHECK-NEXT: (ref.cast (ref $child) ;; CHECK-NEXT: (local.get $parent) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -55,7 +55,7 @@ ;; TNH-NEXT: (local.get $child) ;; TNH-NEXT: ) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.cast $child + ;; TNH-NEXT: (ref.cast (ref $child) ;; TNH-NEXT: (local.get $parent) ;; TNH-NEXT: ) ;; TNH-NEXT: ) @@ -76,13 +76,13 @@ ;; a cast of parent to parent. We can optimize this as the new type will be ;; valid. (drop - (ref.cast $parent + (ref.cast (ref $parent) (local.get $parent) ) ) ;; a cast of child to a supertype: again, we replace with a valid type. (drop - (ref.cast $parent + (ref.cast (ref $parent) (local.get $child) ) ) @@ -90,13 +90,13 @@ ;; $child with one that is not equal or more specific, like $parent, so we ;; cannot optimize here. (drop - (ref.cast $child + (ref.cast (ref $child) (local.get $parent) ) ) ;; a cast of child to an unrelated type: it will trap anyhow (drop - (ref.cast $other + (ref.cast (ref $other) (local.get $child) ) ) @@ -139,7 +139,7 @@ ;; optimizing this cast away requires reordering. (drop - (ref.cast $parent + (ref.cast (ref $parent) (block (result (ref $parent)) (call $foo) (local.get $parent) @@ -149,7 +149,7 @@ ;; ignore unreachability (drop - (ref.cast null $parent + (ref.cast (ref null $parent) (unreachable) ) ) @@ -170,7 +170,7 @@ (drop (ref.eq (local.get $x) - (ref.cast null $parent + (ref.cast (ref null $parent) (local.get $x) ) ) @@ -227,14 +227,14 @@ ;; TNH-NEXT: ) (func $test (param $C (ref $C)) (result anyref) (struct.get $B 0 - (ref.cast $B ;; Try to cast a $C to its parent, $B. That always - ;; works, so the cast can be removed. - ;; Then once the cast is removed, the outer struct.get - ;; will have a reference with a different type, - ;; making it a (struct.get $C ..) instead of $B. - ;; But $B and $C have different types on field 0, and - ;; so the struct.get must be refinalized so the node - ;; has the expected type. + (ref.cast (ref $B) ;; Try to cast a $C to its parent, $B. That always + ;; works, so the cast can be removed. + ;; Then once the cast is removed, the outer struct.get + ;; will have a reference with a different type, + ;; making it a (struct.get $C ..) instead of $B. + ;; But $B and $C have different types on field 0, and + ;; so the struct.get must be refinalized so the node + ;; has the expected type. (local.get $C) ) ) diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 155ac82cf..4d7ed0c48 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -23,10 +23,10 @@ ;; TNH-NEXT: ) ;; NO_TNH: (func $ref.eq (type $eqref_eqref_=>_i32) (param $a eqref) (param $b eqref) (result i32) ;; NO_TNH-NEXT: (ref.eq - ;; NO_TNH-NEXT: (ref.cast $struct + ;; NO_TNH-NEXT: (ref.cast (ref $struct) ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (ref.cast struct + ;; NO_TNH-NEXT: (ref.cast (ref struct) ;; NO_TNH-NEXT: (local.get $b) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -37,16 +37,16 @@ (ref.eq ;; When traps can happen we can still improve this by removing and ;; combining redundant casts. - (ref.cast struct + (ref.cast (ref struct) (ref.as_non_null - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $a) ) ) ) ;; Note that we can remove the non-null casts here in both modes, as the ;; ref.cast struct also checks for null. - (ref.cast struct + (ref.cast (ref struct) (ref.as_non_null (ref.as_non_null (local.get $b) @@ -64,10 +64,10 @@ ;; NO_TNH: (func $ref.eq-no (type $eqref_eqref_anyref_=>_none) (param $a eqref) (param $b eqref) (param $any anyref) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (ref.eq - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $any) ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (ref.cast struct + ;; NO_TNH-NEXT: (ref.cast (ref struct) ;; NO_TNH-NEXT: (local.get $any) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -77,11 +77,11 @@ ;; We must leave the inputs to ref.eq of type eqref or a subtype. (drop (ref.eq - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $any) ;; *Not* an eqref! ) (ref.as_non_null - (ref.cast struct + (ref.cast (ref struct) (ref.as_non_null (local.get $any) ;; *Not* an eqref! ) @@ -93,7 +93,7 @@ ;; TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.cast $struct + ;; TNH-NEXT: (ref.cast (ref $struct) ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) ;; TNH-NEXT: ) @@ -101,7 +101,7 @@ ;; TNH-NEXT: ) ;; NO_TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast $struct + ;; NO_TNH-NEXT: (ref.cast (ref $struct) ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -111,9 +111,9 @@ ;; In this case non-nullability is enough to tell that the ref.is will ;; return 0. TNH does not help here. (ref.is_null - (ref.cast $struct + (ref.cast (ref $struct) (ref.as_non_null - (ref.cast struct + (ref.cast (ref struct) (local.get $a) ) ) @@ -134,13 +134,13 @@ ;; NO_TNH: (func $ref.is_b (type $eqref_funcref_=>_i32) (param $a eqref) (param $f funcref) (result i32) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (ref.is_null - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (ref.is_null - ;; NO_TNH-NEXT: (ref.cast null $void + ;; NO_TNH-NEXT: (ref.cast (ref null $void) ;; NO_TNH-NEXT: (local.get $f) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -151,14 +151,14 @@ ;; remove the cast in TNH. (drop (ref.is_null - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $a) ) ) ) ;; It works on func references, too. (ref.is_null - (ref.cast null $void + (ref.cast (ref null $void) (local.get $f) ) ) @@ -168,7 +168,7 @@ ;; TNH-NEXT: (drop ;; TNH-NEXT: (block (result i32) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.cast null i31 + ;; TNH-NEXT: (ref.cast i31ref ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) ;; TNH-NEXT: ) @@ -188,7 +188,7 @@ ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (block (result i32) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null i31 + ;; NO_TNH-NEXT: (ref.cast i31ref ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -206,14 +206,14 @@ ;; NO_TNH-NEXT: ) (func $ref.test (param $a eqref) (result i32) (drop - (ref.test null i31 - (ref.cast null i31 + (ref.test i31ref + (ref.cast i31ref (local.get $a) ) ) ) - (ref.test eq - (ref.cast eq + (ref.test (ref eq) + (ref.cast (ref eq) (local.get $a) ) ) @@ -559,19 +559,19 @@ ;; TNH: (func $set-get-cast (type $structref_=>_none) (param $ref structref) ;; TNH-NEXT: (drop ;; TNH-NEXT: (struct.get $struct 0 - ;; TNH-NEXT: (ref.cast $struct + ;; TNH-NEXT: (ref.cast (ref $struct) ;; TNH-NEXT: (local.get $ref) ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: (struct.set $struct 0 - ;; TNH-NEXT: (ref.cast $struct + ;; TNH-NEXT: (ref.cast (ref $struct) ;; TNH-NEXT: (local.get $ref) ;; TNH-NEXT: ) ;; TNH-NEXT: (i32.const 1) ;; TNH-NEXT: ) ;; TNH-NEXT: (struct.set $struct 0 - ;; TNH-NEXT: (ref.cast null $struct + ;; TNH-NEXT: (ref.cast (ref null $struct) ;; TNH-NEXT: (local.get $ref) ;; TNH-NEXT: ) ;; TNH-NEXT: (block (result i32) @@ -583,19 +583,19 @@ ;; NO_TNH: (func $set-get-cast (type $structref_=>_none) (param $ref structref) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (struct.get $struct 0 - ;; NO_TNH-NEXT: (ref.cast $struct + ;; NO_TNH-NEXT: (ref.cast (ref $struct) ;; NO_TNH-NEXT: (local.get $ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (struct.set $struct 0 - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (i32.const 1) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (struct.set $struct 0 - ;; NO_TNH-NEXT: (ref.cast null $struct + ;; NO_TNH-NEXT: (ref.cast (ref null $struct) ;; NO_TNH-NEXT: (local.get $ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (block (result i32) @@ -609,7 +609,7 @@ ;; non-nullable cast. (drop (struct.get $struct 0 - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $ref) ) ) @@ -618,7 +618,7 @@ ;; TODO handle non-TNH as well, but we need to be careful of effects in ;; other children. (struct.set $struct 0 - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $ref) ) (i32.const 1) @@ -627,7 +627,7 @@ ;; prevents us from optimizing - if the parent is not necessarily reached, ;; we cannot infer the child won't trap. (struct.set $struct 0 - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $ref) ) (block (result i32) @@ -665,7 +665,7 @@ ;; We can remove the unreachable arm of the if here in TNH mode. While doing ;; so we must refinalize properly or else we'll hit an error in pass-debug ;; mode. - (ref.cast $struct + (ref.cast (ref $struct) (if (result (ref none)) (i32.const 1) (unreachable) @@ -697,7 +697,7 @@ ;; NO_TNH-NEXT: ) (func $cast-if-null-flip (param $x (ref none)) (result (ref $struct)) ;; As above but with arms flipped. - (ref.cast $struct + (ref.cast (ref $struct) (if (result (ref none)) (i32.const 1) (local.get $x) @@ -766,7 +766,7 @@ ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null none + ;; NO_TNH-NEXT: (ref.cast nullref ;; NO_TNH-NEXT: (local.get $nullable-ref) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -775,19 +775,19 @@ ;; Non-nullable casts to none must trap (regardless of whether the input is ;; nullable or not, the output is an impossible type). (drop - (ref.cast none + (ref.cast (ref none) (local.get $ref) ) ) (drop - (ref.cast none + (ref.cast (ref none) (local.get $nullable-ref) ) ) ;; Nullable casts to null have more possibilities. First, if the input is ;; non-nullable then we trap. (drop - (ref.cast null none + (ref.cast nullref (local.get $ref) ) ) @@ -796,7 +796,7 @@ ;; return a null here. (In non-TNH mode we could do a check for null etc., ;; but we'd be increasing code size.) (drop - (ref.cast null none + (ref.cast nullref (local.get $nullable-ref) ) ) @@ -892,7 +892,7 @@ ;; then process the select. While doing so we must not error, as the select ;; itself will still have a reachable type (a full refinalize only ;; happens at the very end of the function). - (ref.cast $struct + (ref.cast (ref $struct) (select (result (ref $struct)) (ref.as_non_null (ref.null none) @@ -919,7 +919,7 @@ ;; NO_TNH-NEXT: ) (func $select.unreachable.child.flip (param $x (ref $struct)) (result (ref $struct)) ;; Flip case of the above. - (ref.cast $struct + (ref.cast (ref $struct) (select (result (ref $struct)) (local.get $x) (ref.as_non_null @@ -965,7 +965,7 @@ ;; the false arm (that would trap, and change the behavior; tnh can remove ;; traps, not add them). (drop - (ref.cast func + (ref.cast (ref func) (if (result (ref nofunc)) (i32.const 1) (block (result (ref nofunc)) diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index e7933e8a1..45a984807 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -157,10 +157,10 @@ (ref.is_null (local.get $struct)) ) (drop - (ref.test func (local.get $func)) + (ref.test (ref func) (local.get $func)) ) (drop - (ref.test i31 (local.get $i31)) + (ref.test (ref i31) (local.get $i31)) ) ) @@ -197,11 +197,11 @@ ;; This can be optimized to !is_null rather than ref.test func, since we ;; know the heap type is what we want, so the only possible issue is a null. (drop - (ref.test func (local.get $func)) + (ref.test (ref func) (local.get $func)) ) ;; This can be optimized similarly. (drop - (ref.test i31 (local.get $i31)) + (ref.test (ref i31) (local.get $i31)) ) ) @@ -226,10 +226,10 @@ (ref.as_non_null (local.get $struct)) ) (drop - (ref.cast func (local.get $func)) + (ref.cast (ref func) (local.get $func)) ) (drop - (ref.cast i31 (local.get $i31)) + (ref.cast (ref i31) (local.get $i31)) ) ) @@ -260,16 +260,16 @@ (ref.as_non_null (local.get $struct)) ) (drop - (ref.cast func (local.get $func)) + (ref.cast (ref func) (local.get $func)) ) (drop - (ref.cast i31 (local.get $i31)) + (ref.cast (ref i31) (local.get $i31)) ) ) ;; CHECK: (func $unneeded_unreachability (type $void) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test func + ;; CHECK-NEXT: (ref.test (ref func) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -285,10 +285,10 @@ (func $unneeded_unreachability ;; unreachable instructions can simply be ignored (drop - (ref.test func (unreachable)) + (ref.test (ref func) (unreachable)) ) (drop - (ref.cast func (unreachable)) + (ref.cast (ref func) (unreachable)) ) ) @@ -551,7 +551,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -563,7 +563,7 @@ (drop (ref.eq (local.get $x) - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $x) ) ) @@ -572,13 +572,13 @@ ;; CHECK: (func $flip-cast-of-as-non-null (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get_u $struct $i8 - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -586,7 +586,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast i31 + ;; CHECK-NEXT: (ref.cast (ref i31) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -596,7 +596,7 @@ ;; CHECK-NEXT: ) (func $flip-cast-of-as-non-null (param $x anyref) (drop - (ref.cast $struct + (ref.cast (ref $struct) ;; this can be folded into the outer cast, which checks for null too (ref.as_non_null (local.get $x) @@ -606,7 +606,7 @@ (drop ;; an example of how this helps: the struct.get will trap on null anyhow (struct.get_u $struct 0 - (ref.cast $struct + (ref.cast (ref $struct) ;; this can be moved through the ref.cast null outward. (ref.as_non_null (local.get $x) @@ -616,8 +616,8 @@ ) ;; This will trap, so we can emit an unreachable. (drop - (ref.cast $struct - (ref.cast i31 + (ref.cast (ref $struct) + (ref.cast (ref i31) (local.get $x) ) ) @@ -765,7 +765,7 @@ ;; CHECK: (func $ref-cast-squared (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -773,8 +773,8 @@ (func $ref-cast-squared (param $x eqref) ;; Identical ref.casts can be folded together. (drop - (ref.cast null $struct - (ref.cast null $struct + (ref.cast (ref null $struct) + (ref.cast (ref null $struct) (local.get $x) ) ) @@ -787,7 +787,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $x ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -800,9 +800,9 @@ (func $ref-cast-squared-fallthrough (param $x eqref) ;; A fallthrough in the middle does not prevent this optimization. (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (local.tee $x - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $x) ) ) @@ -811,7 +811,7 @@ ) ;; CHECK: (func $ref-cast-cubed (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -819,9 +819,9 @@ (func $ref-cast-cubed (param $x eqref) ;; Three and more also work. (drop - (ref.cast null $struct - (ref.cast null $struct - (ref.cast null $struct + (ref.cast (ref null $struct) + (ref.cast (ref null $struct) + (ref.cast (ref null $struct) (local.get $x) ) ) @@ -830,7 +830,7 @@ ) ;; CHECK: (func $ref-cast-squared-different (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -839,8 +839,8 @@ ;; Different casts cannot be folded. We can emit a cast to null here, which ;; is the only possible thing that can pass through. (drop - (ref.cast null $struct - (ref.cast null $empty + (ref.cast (ref null $struct) + (ref.cast (ref null $empty) (local.get $x) ) ) @@ -891,10 +891,10 @@ ;; CHECK: (func $ref-eq-possible (type $eqref_eqref_=>_none) (param $x eqref) (param $y eqref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null $array + ;; CHECK-NEXT: (ref.cast (ref null $array) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -905,10 +905,10 @@ ;; they are both null, so we cannot optimize here. (drop (ref.eq - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $x) ) - (ref.cast null $array + (ref.cast (ref null $array) (local.get $y) ) ) @@ -919,12 +919,12 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $array + ;; CHECK-NEXT: (ref.cast (ref null $array) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -934,12 +934,12 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -949,12 +949,12 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -967,12 +967,12 @@ ;; equal, and the result must be 0. (drop (ref.eq - (ref.cast $struct + (ref.cast (ref $struct) (ref.as_non_null (local.get $x) ) ) - (ref.cast null $array + (ref.cast (ref null $array) (local.get $y) ) ) @@ -980,10 +980,10 @@ ;; As above but the cast is on the other one. (drop (ref.eq - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $x) ) - (ref.cast $array + (ref.cast (ref $array) (ref.as_non_null (local.get $y) ) @@ -993,12 +993,12 @@ ;; As above but the cast is both. (drop (ref.eq - (ref.cast $struct + (ref.cast (ref $struct) (ref.as_non_null (local.get $x) ) ) - (ref.cast $array + (ref.cast (ref $array) (ref.as_non_null (local.get $y) ) @@ -1010,20 +1010,20 @@ ;; CHECK: (func $ref-eq-possible-b (type $eqref_eqref_=>_none) (param $x eqref) (param $y eqref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1034,10 +1034,10 @@ ;; subtype of A, so we cannot optimize. (drop (ref.eq - (ref.cast $A + (ref.cast (ref $A) (local.get $x) ) - (ref.cast $B + (ref.cast (ref $B) (local.get $y) ) ) @@ -1045,10 +1045,10 @@ ;; As above but flipped. (drop (ref.eq - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) - (ref.cast $A + (ref.cast (ref $A) (local.get $y) ) ) @@ -1098,7 +1098,7 @@ ;; CHECK-NEXT: ) (func $incompatible-cast-of-non-null (param $struct (ref $struct)) (drop - (ref.cast $array + (ref.cast (ref $array) (local.get $struct) ) ) @@ -1121,14 +1121,14 @@ ;; CHECK-NEXT: ) (func $incompatible-cast-of-null (param $x (ref null $struct)) (drop - (ref.cast $array + (ref.cast (ref $array) ;; The child is null, so the cast will trap. Replace it with an ;; unreachable. (ref.null none) ) ) (drop - (ref.cast $array + (ref.cast (ref $array) ;; Even though the child type is non-null, it is still valid to do this ;; transformation. In practice this code will trap before getting to our ;; new unreachable. @@ -1141,14 +1141,14 @@ ;; CHECK: (func $incompatible-cast-of-unknown (type $ref?|$struct|_=>_none) (param $struct (ref null $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $incompatible-cast-of-unknown (param $struct (ref null $struct)) (drop - (ref.cast null $array + (ref.cast (ref null $array) (local.get $struct) ) ) @@ -1182,7 +1182,7 @@ (func $incompatible-test (param $struct (ref null $struct)) (drop ;; This test will definitely fail, so we can turn it into 0. - (ref.test $array + (ref.test (ref $array) (local.get $struct) ) ) @@ -1190,13 +1190,13 @@ ;; But this one might succeed due to a null, so don't optimize it away. ;; We can however change it from ref.test to ref.is_null, as a null is the ;; only possible way this will succeed. - (ref.test null $array + (ref.test (ref null $array) (local.get $struct) ) ) (drop ;; This one cannot succeed due to a null, so optimize it. - (ref.test null $array + (ref.test (ref null $array) (ref.as_non_null (local.get $struct) ) @@ -1206,7 +1206,7 @@ ;; CHECK: (func $subtype-compatible (type $ref?|$A|_ref?|$B|_=>_none) (param $A (ref null $A)) (param $B (ref null $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1249,26 +1249,26 @@ (func $subtype-compatible (param $A (ref null $A)) (param $B (ref null $B)) (drop ;; B is a subtype of A, so this can work. - (ref.test $B + (ref.test (ref $B) (local.get $A) ) ) (drop ;; The other direction can work too. It will only fail if the input is a ;; null, so we can switch to checking that. - (ref.test $A + (ref.test (ref $A) (local.get $B) ) ) (drop ;; If the test is nullable, this will succeed. - (ref.test null $A + (ref.test (ref null $A) (local.get $B) ) ) (drop ;; We will also succeed if the input is non-nullable. - (ref.test $A + (ref.test (ref $A) (ref.as_non_null (local.get $B) ) @@ -1276,7 +1276,7 @@ ) (drop ;; Or if the test is nullable and the input is non-nullable. - (ref.test null $A + (ref.test (ref null $A) (ref.as_non_null (local.get $B) ) @@ -1290,7 +1290,7 @@ ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result eqref) - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1301,14 +1301,14 @@ ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) (func $compatible-test-separate-fallthrough (param $eqref eqref) (result i32) - (ref.test i31 + (ref.test (ref i31) (local.tee $eqref (block (result eqref) ;; Prove that the value is non-nullable (ref.as_non_null (block (result eqref) ;; Prove that the value is an i31 - (ref.cast null i31 + (ref.cast i31ref (local.get $eqref) ) ) @@ -1319,7 +1319,7 @@ ) ;; CHECK: (func $improvable-test-separate-fallthrough (type $eqref_=>_i32) (param $eqref eqref) (result i32) - ;; CHECK-NEXT: (ref.test i31 + ;; CHECK-NEXT: (ref.test (ref i31) ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.get $eqref) @@ -1329,7 +1329,7 @@ ;; CHECK-NEXT: ) (func $improvable-test-separate-fallthrough (param $eqref eqref) (result i32) ;; There is no need to admit null here, but we don't know whether we have an i31. - (ref.test null i31 + (ref.test i31ref (block (result eqref) ;; Prove that the value is non-nullable (ref.as_non_null @@ -1345,7 +1345,7 @@ ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result eqref) - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1356,14 +1356,14 @@ ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) (func $incompatible-test-separate-fallthrough (param $eqref eqref) (result i32) - (ref.test null struct + (ref.test structref (local.tee $eqref (block (result eqref) ;; Prove that the value is non-nullable (ref.as_non_null (block (result eqref) ;; Prove that the value is an i31 - (ref.cast null i31 + (ref.cast i31ref (local.get $eqref) ) ) @@ -1399,7 +1399,7 @@ (drop ;; The value cannot be both i31 and struct, so it must be null and we ;; can optimize to 0. - (ref.test any + (ref.test (ref any) (block (result anyref) (br_on_cast_fail $outer anyref i31ref (block (result anyref) @@ -1440,7 +1440,7 @@ (block $outer (result anyref) (drop ;; Same as above, but now we allow null, so we optimize to 1. - (ref.test null any + (ref.test anyref (block (result anyref) (br_on_cast_fail $outer anyref i31ref (block (result anyref) @@ -1482,7 +1482,7 @@ (drop ;; Same as above, but now we know the value must be non-null and bottom, ;; so it cannot exist at all. - (ref.test null any + (ref.test anyref (block (result anyref) (br_on_cast_fail $outer anyref (ref i31) (block (result anyref) @@ -1500,12 +1500,12 @@ ;; CHECK: (func $ref.test-unreachable (type $ref?|$A|_=>_none) (param $A (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $A + ;; CHECK-NEXT: (ref.test (ref $A) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test null $A + ;; CHECK-NEXT: (ref.test (ref null $A) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1514,12 +1514,12 @@ (drop ;; We should ignore unreachable ref.tests and not try to compare their ;; HeapTypes. - (ref.test $A + (ref.test (ref $A) (unreachable) ) ) (drop - (ref.test null $A + (ref.test (ref null $A) (unreachable) ) ) @@ -1554,7 +1554,7 @@ ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1566,7 +1566,7 @@ ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1579,13 +1579,13 @@ (local $a (ref null $A)) ;; Casting nulls results in a null. (drop - (ref.cast null $A + (ref.cast (ref null $A) (ref.null none) ) ) ;; A fallthrough works too. (drop - (ref.cast null $B + (ref.cast (ref null $B) (local.tee $a (ref.null none) ) @@ -1593,7 +1593,7 @@ ) ;; A non-null cast of a falling-though null will trap. (drop - (ref.cast $A + (ref.cast (ref $A) (local.tee $a (ref.null none) ) @@ -1602,18 +1602,18 @@ ;; The prior two examples work even if the fallthrough is only later proven ;; to be null. (drop - (ref.cast null $B + (ref.cast (ref null $B) (block (result (ref null $A)) - (ref.cast null none + (ref.cast nullref (local.get $a) ) ) ) ) (drop - (ref.cast $B + (ref.cast (ref $B) (block (result (ref null $A)) - (ref.cast null none + (ref.cast nullref (local.get $a) ) ) @@ -1629,7 +1629,7 @@ ;; CHECK-NEXT: (local.get $b) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1643,24 +1643,24 @@ ;; In the general case, a static cast of something simply succeeds if the ;; type is a subtype. (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $a) ) ) (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $b) ) ) ;; This is the only one that we cannot know for sure will succeed. (drop - (ref.cast null $B + (ref.cast (ref null $B) (local.get $a) ) ) ;; A fallthrough works too. (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.tee $a (local.get $a) ) @@ -1670,17 +1670,17 @@ ;; CHECK: (func $ref-cast-static-squared (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1688,23 +1688,23 @@ (func $ref-cast-static-squared (param $x eqref) ;; Identical ref.casts can be folded together. (drop - (ref.cast null $A - (ref.cast null $A + (ref.cast (ref null $A) + (ref.cast (ref null $A) (local.get $x) ) ) ) ;; When subtypes exist, we only need the stricter one. (drop - (ref.cast null $A - (ref.cast null $B + (ref.cast (ref null $A) + (ref.cast (ref null $B) (local.get $x) ) ) ) (drop - (ref.cast null $B - (ref.cast null $A + (ref.cast (ref null $B) + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1713,32 +1713,32 @@ ;; CHECK: (func $ref-cast-static-many (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1747,54 +1747,54 @@ ;; We should optimize a long sequence of static casts when we can. All six ;; orderings of these casts should collapse into the strictest one. (drop - (ref.cast null $A - (ref.cast null $B - (ref.cast null $B-child + (ref.cast (ref null $A) + (ref.cast (ref null $B) + (ref.cast (ref null $B-child) (local.get $x) ) ) ) ) (drop - (ref.cast null $A - (ref.cast null $B-child - (ref.cast null $B + (ref.cast (ref null $A) + (ref.cast (ref null $B-child) + (ref.cast (ref null $B) (local.get $x) ) ) ) ) (drop - (ref.cast null $B - (ref.cast null $A - (ref.cast null $B-child + (ref.cast (ref null $B) + (ref.cast (ref null $A) + (ref.cast (ref null $B-child) (local.get $x) ) ) ) ) (drop - (ref.cast null $B - (ref.cast null $B-child - (ref.cast null $A + (ref.cast (ref null $B) + (ref.cast (ref null $B-child) + (ref.cast (ref null $A) (local.get $x) ) ) ) ) (drop - (ref.cast null $B-child - (ref.cast null $A - (ref.cast null $B + (ref.cast (ref null $B-child) + (ref.cast (ref null $A) + (ref.cast (ref null $B) (local.get $x) ) ) ) ) (drop - (ref.cast null $B-child - (ref.cast null $B - (ref.cast null $A + (ref.cast (ref null $B-child) + (ref.cast (ref null $B) + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1804,7 +1804,7 @@ ;; CHECK: (func $ref-cast-static-very-many (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B-child + ;; CHECK-NEXT: (ref.cast (ref null $B-child) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1812,18 +1812,18 @@ (func $ref-cast-static-very-many (param $x eqref) ;; We should optimize an arbitrarily-long long sequence of static casts. (drop - (ref.cast null $A - (ref.cast null $B - (ref.cast null $B-child - (ref.cast null $A - (ref.cast null $A - (ref.cast null $B-child - (ref.cast null $B-child - (ref.cast null $B - (ref.cast null $B - (ref.cast null $B - (ref.cast null $B-child - (ref.cast null $A + (ref.cast (ref null $A) + (ref.cast (ref null $B) + (ref.cast (ref null $B-child) + (ref.cast (ref null $A) + (ref.cast (ref null $A) + (ref.cast (ref null $B-child) + (ref.cast (ref null $B-child) + (ref.cast (ref null $B) + (ref.cast (ref null $B) + (ref.cast (ref null $B) + (ref.cast (ref null $B-child) + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1846,7 +1846,7 @@ ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1854,7 +1854,7 @@ ;; CHECK-NEXT: ) (func $ref-cast-static-fallthrough-remaining (param $x eqref) (drop - (ref.cast null $A + (ref.cast (ref null $A) (block (result (ref null $B)) ;; Additional contents in between redundant casts must be preserved. ;; That is, when we see that the casts are redundant, by seeing that @@ -1867,7 +1867,7 @@ (call $ref-cast-static-fallthrough-remaining (local.get $x) ) - (ref.cast null $B + (ref.cast (ref null $B) (local.get $x) ) ) @@ -1877,12 +1877,12 @@ ;; CHECK: (func $ref-cast-static-fallthrough-remaining-child (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1894,12 +1894,12 @@ ;; As above, but with $A and $B flipped. Now the inner cast is not needed. ;; However, we do not remove it, as it may be necessary for validation, ;; and we hope other opts help out here. - (ref.cast null $B + (ref.cast (ref null $B) (block (result (eqref)) (call $ref-cast-static-fallthrough-remaining-child (local.get $x) ) - (ref.cast null $A + (ref.cast (ref null $A) (local.get $x) ) ) @@ -1915,7 +1915,7 @@ ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining-impossible ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1929,12 +1929,12 @@ ;; As above, but with an impossible cast of an array to a struct. The ;; block with the side effects and the inner cast must be kept around and ;; dropped, and then we replace the outer cast with an unreachable. - (ref.cast $array + (ref.cast (ref $array) (block (result (ref eq)) (call $ref-cast-static-fallthrough-remaining-impossible (local.get $x) ) - (ref.cast $struct + (ref.cast (ref $struct) (local.get $x) ) ) @@ -1952,7 +1952,7 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1968,12 +1968,12 @@ ;; mis-optimize this case: The outer cast is not needed, so we can optimize ;; it out, but we have to be careful not to remove any side effects. (drop - (ref.cast $A + (ref.cast (ref $A) (block (result (ref eq)) (call $ref-cast-static-fallthrough-remaining (local.get $x) ) - (ref.cast $B + (ref.cast (ref $B) (local.get $x) ) ) @@ -1983,14 +1983,14 @@ ;; CHECK: (func $ref-cast-static-squared-impossible (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2000,7 +2000,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2010,7 +2010,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2022,29 +2022,29 @@ ;; Impossible casts will trap unless the input is null. Only the first one ;; here, which lets a null get through, will not trap. (drop - (ref.cast null $struct - (ref.cast null $array + (ref.cast (ref null $struct) + (ref.cast (ref null $array) (local.get $x) ) ) ) (drop - (ref.cast $struct - (ref.cast null $array + (ref.cast (ref $struct) + (ref.cast (ref null $array) (local.get $x) ) ) ) (drop - (ref.cast null $struct - (ref.cast $array + (ref.cast (ref null $struct) + (ref.cast (ref $array) (local.get $x) ) ) ) (drop - (ref.cast $struct - (ref.cast $array + (ref.cast (ref $struct) + (ref.cast (ref $array) (ref.as_non_null (local.get $x)) ) ) @@ -2072,13 +2072,13 @@ ;; A nullable value cannot be optimized here even though it is the same ;; type. But we can at least use !ref.is_null rather than ref.test. (drop - (ref.test $A + (ref.test (ref $A) (local.get $nullable) ) ) ;; But if it is non-nullable, it must succeed. (drop - (ref.test $A + (ref.test (ref $A) (local.get $non-nullable) ) ) @@ -2104,12 +2104,12 @@ (func $ref-test-static-subtype (param $nullable (ref null $B)) (param $non-nullable (ref $B)) ;; As above, but the input is a subtype, so the same things happen. (drop - (ref.test $A + (ref.test (ref $A) (local.get $nullable) ) ) (drop - (ref.test $A + (ref.test (ref $A) (local.get $non-nullable) ) ) @@ -2117,12 +2117,12 @@ ;; CHECK: (func $ref-test-static-supertype (type $ref?|$A|_ref|$A|_=>_none) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $nullable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $non-nullable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2131,12 +2131,12 @@ ;; As above, but the input is a supertype. We can't know at compile time ;; what to do here. (drop - (ref.test $B + (ref.test (ref $B) (local.get $nullable) ) ) (drop - (ref.test $B + (ref.test (ref $B) (local.get $non-nullable) ) ) @@ -2163,12 +2163,12 @@ (func $ref-test-static-impossible (param $nullable (ref null $array)) (param $non-nullable (ref $array)) ;; Testing an impossible cast will definitely fail. (drop - (ref.test $struct + (ref.test (ref $struct) (local.get $nullable) ) ) (drop - (ref.test $struct + (ref.test (ref $struct) (local.get $non-nullable) ) ) @@ -2187,7 +2187,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $A + ;; CHECK-NEXT: (ref.test (ref $A) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2214,7 +2214,7 @@ ) (drop (i32.and - (ref.test $A + (ref.test (ref $A) (local.get $x) ) (i32.const 1) @@ -2293,26 +2293,26 @@ ;; Non-nullable casts. When the input is non-nullable we must succeed. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $b) ) ) ;; When the input can be null, we might fail if it is a null. But we can ;; switch to checking only that. (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $null-b) ) ) ;; Null casts. Both of these must succeed. (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $b) ) ) (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $null-b) ) ) @@ -2344,7 +2344,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $null-b) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2354,24 +2354,24 @@ ;; types, $B and $struct, so the only possible way the cast succeeds is if ;; the cast allows null and the input is a null. (drop - (ref.cast $struct + (ref.cast (ref $struct) (local.get $b) ) ) (drop - (ref.cast $struct + (ref.cast (ref $struct) (local.get $null-b) ) ) (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $b) ) ) ;; This last case is the only one that can succeed. We turn it into a cast ;; to a null. (drop - (ref.cast null $struct + (ref.cast (ref null $struct) (local.get $null-b) ) ) @@ -2385,7 +2385,7 @@ ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2400,14 +2400,14 @@ ;; CHECK-NEXT: ) (func $compatible-cast-separate-fallthrough (param $eqref eqref) (result (ref i31)) ;; This cast will succeed even though no individual fallthrough value is sufficiently refined. - (ref.cast i31 + (ref.cast (ref i31) (local.tee $eqref (block (result eqref) ;; Prove that the value is non-nullable (ref.as_non_null (block (result eqref) ;; Prove that the value is an i31 - (ref.cast null i31 + (ref.cast i31ref (local.get $eqref) ) ) @@ -2423,7 +2423,7 @@ ;; CHECK-NEXT: (local.tee $eqref ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2437,11 +2437,11 @@ (func $compatible-cast-fallthrough-null-check (param $eqref eqref) (result (ref i31)) ;; Similar to above, but now we no longer know whether the value going into ;; the cast is null or not. - (ref.cast i31 + (ref.cast (ref i31) (local.tee $eqref (block (result eqref) ;; Prove that the value is an i31 - (ref.cast null i31 + (ref.cast i31ref (local.get $eqref) ) ) @@ -2461,7 +2461,7 @@ ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result eqref) - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2483,7 +2483,7 @@ ;; There are multiple "best" values we could tee and propagate. Choose the ;; shallowest. (block $outer (result (ref eq)) - (ref.cast i31 + (ref.cast (ref i31) (local.tee $eqref (block (result eqref) ;; Prove that the value is an i31 a second time. This one will be @@ -2494,7 +2494,7 @@ (ref.as_non_null (block (result eqref) ;; Prove that the value is an i31 - (ref.cast null i31 + (ref.cast i31ref (local.get $eqref) ) ) @@ -2519,7 +2519,7 @@ ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast i31 + ;; CHECK-NEXT: (ref.cast (ref i31) ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2537,7 +2537,7 @@ (func $compatible-cast-separate-fallthrough-multiple-options-2 (param $eqref eqref) (result (ref eq)) (block $outer (result (ref eq)) - (ref.cast i31 + (ref.cast (ref i31) (local.tee $eqref (block (result eqref) ;; Prove that the value is an i31 a second time, but not that it is @@ -2549,7 +2549,7 @@ (block (result eqref) ;; Now this is non-nullable and an exact match, so we ;; propagate this one. - (ref.cast i31 + (ref.cast (ref i31) (local.get $eqref) ) ) @@ -2568,7 +2568,7 @@ ;; CHECK-NEXT: (block (result (ref i31)) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result i31ref) - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $eqref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2579,14 +2579,14 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $incompatible-cast-separate-fallthrough (param $eqref eqref) (result structref) - (ref.cast null struct + (ref.cast structref (local.tee $eqref (block (result eqref) ;; Prove that the value is non-nullable (ref.as_non_null (block (result eqref) ;; Prove that the value is an i31 - (ref.cast null i31 + (ref.cast i31ref (local.get $eqref) ) ) @@ -2618,7 +2618,7 @@ (block $outer (result anyref) ;; The value cannot be both an i31 and a struct, so it must be null, so ;; the cast will fail. - (ref.cast struct + (ref.cast (ref struct) (block (result anyref) (br_on_cast_fail $outer anyref i31ref (block (result anyref) @@ -2634,7 +2634,7 @@ ;; CHECK: (func $incompatible-cast-heap-types-nullable (type $anyref_=>_anyref) (param $anyref anyref) (result anyref) ;; CHECK-NEXT: (block $outer (result anyref) - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (br_on_cast_fail $outer structref nullref ;; CHECK-NEXT: (block (result structref) @@ -2650,7 +2650,7 @@ (func $incompatible-cast-heap-types-nullable (param $anyref anyref) (result anyref) (block $outer (result anyref) ;; As above, but now the cast might succeed because we allow null. - (ref.cast null struct + (ref.cast structref (block (result anyref) (br_on_cast_fail $outer anyref i31ref (block (result anyref) @@ -2685,7 +2685,7 @@ (func $incompatible-cast-heap-types-unreachable (param $anyref anyref) (result anyref) (block $outer (result anyref) ;; As above, but now we know the value is not null, so the cast is unreachable. - (ref.cast null struct + (ref.cast structref (block (result anyref) (br_on_cast_fail $outer anyref (ref i31) (block (result anyref) @@ -2707,7 +2707,7 @@ ;; ref.as must then ignore the unreachable input and not error on trying to ;; infer anything about it. (ref.as_non_null - (ref.cast $A + (ref.cast (ref $A) (ref.null none) ) ) @@ -2715,7 +2715,7 @@ ;; CHECK: (func $cast-internalized-extern (type $externref_=>_none) (param $externref externref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (extern.internalize ;; CHECK-NEXT: (local.get $externref) ;; CHECK-NEXT: ) @@ -2727,7 +2727,7 @@ ;; externref as falling through to the cast and incorrectly inferring that ;; the cast cannot succeed. (drop - (ref.cast $A + (ref.cast (ref $A) (extern.internalize (local.get $externref) ) @@ -2802,7 +2802,7 @@ ;; CHECK: (func $refinalize.select.arm (type $void) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $void2 + ;; CHECK-NEXT: (ref.cast (ref $void2) ;; CHECK-NEXT: (ref.func $refinalize.select.arm) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2812,7 +2812,7 @@ ;; type (the arms are more refined than the declared type), so we must ;; refinalize or we'll error. (drop - (ref.cast null $void2 + (ref.cast (ref null $void2) (select (result (ref null $void)) (ref.func $refinalize.select.arm) (ref.func $refinalize.select.arm) @@ -2824,7 +2824,7 @@ ;; CHECK: (func $refinalize.select.arm.flip (type $void) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $void2 + ;; CHECK-NEXT: (ref.cast (ref $void2) ;; CHECK-NEXT: (ref.func $refinalize.select.arm) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2832,7 +2832,7 @@ (func $refinalize.select.arm.flip ;; Flipped of the above. (drop - (ref.cast null $void2 + (ref.cast (ref null $void2) (select (result (ref null $void)) (ref.func $refinalize.select.arm) (ref.func $refinalize.select.arm) @@ -2844,7 +2844,7 @@ ;; CHECK: (func $refinalize.select.arm.unknown (type $i32_=>_none) (param $x i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $void2 + ;; CHECK-NEXT: (ref.cast (ref $void2) ;; CHECK-NEXT: (ref.func $refinalize.select.arm) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2852,7 +2852,7 @@ (func $refinalize.select.arm.unknown (param $x i32) ;; As above but use an unknown value at compile time for the condition. (drop - (ref.cast null $void2 + (ref.cast (ref null $void2) (select (result (ref null $void)) (ref.func $refinalize.select.arm) (ref.func $refinalize.select.arm) @@ -2881,7 +2881,7 @@ ;; succeed, and replaced the cast with its child, we'd fail to validate. ;; Instead, since the cast fails, we can replace it with an unreachable ;; (after the dropped child). - (ref.cast func + (ref.cast (ref func) (local.tee $0 (loop (result (ref nofunc)) (unreachable) @@ -2898,7 +2898,7 @@ ;; CHECK-NEXT: ) (func $non-null-bottom-cast (result (ref nofunc)) ;; As above, but now the cast is uninhabitable. - (ref.cast nofunc + (ref.cast (ref nofunc) (ref.func $non-null-bottom-cast) ) ) @@ -2917,7 +2917,7 @@ (func $non-null-bottom-ref-test (result i32) (local $0 (ref null func)) ;; As above, but now it's a ref.test instead of cast. - (ref.test func + (ref.test (ref func) (local.tee $0 (loop (result (ref nofunc)) (unreachable) @@ -2939,7 +2939,7 @@ (local $0 (ref null func)) ;; As above, but without an intermediate local.tee. Now ref.test will see ;; that it is unreachable, as the input is uninhabitable. - (ref.test func + (ref.test (ref func) (loop (result (ref nofunc)) (unreachable) ) @@ -2955,7 +2955,7 @@ (func $non-null-bottom-test (result i32) ;; As above, but now the cast type is uninhabitable, and also use ref.test. ;; This cast cannot succeed, so return 0. - (ref.test nofunc + (ref.test (ref nofunc) (ref.func $non-null-bottom-cast) ) ) @@ -2963,7 +2963,7 @@ ;; CHECK: (func $ref.test-fallthrough (type $void) ;; CHECK-NEXT: (local $A (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.tee $A ;; CHECK-NEXT: (struct.new $A ;; CHECK-NEXT: (i32.const 10) @@ -2992,7 +2992,7 @@ ;; thinks it can succeed and nothing happens here (GUFA can optimize this, ;; however). (drop - (ref.test $B + (ref.test (ref $B) (local.tee $A (struct.new $A (i32.const 10) @@ -3003,7 +3003,7 @@ ;; This test will succeed, even though we tee to the parent type in the ;; middle. (drop - (ref.test $B + (ref.test (ref $B) (local.tee $A (struct.new $B (i32.const 20) @@ -3039,8 +3039,8 @@ (i32.const 1) (i32.add (i32.const 2) - (ref.test func - (ref.cast func + (ref.test (ref func) + (ref.cast (ref func) (ref.null nofunc) ) ) diff --git a/test/lit/passes/optimize-instructions-iit-eh.wast b/test/lit/passes/optimize-instructions-iit-eh.wast index cf69e4b90..a4768a05f 100644 --- a/test/lit/passes/optimize-instructions-iit-eh.wast +++ b/test/lit/passes/optimize-instructions-iit-eh.wast @@ -31,7 +31,7 @@ ;; which is invalid. We fix this up at the end up OptimizeInstruction, ;; assigning the 'pop' to a local at the start of this 'catch' body ;; and later using 'local.get' to get it. - (ref.cast null $struct.A + (ref.cast (ref null $struct.A) (pop (ref null $struct.A)) ) ) diff --git a/test/lit/passes/precompute-gc-immutable.wast b/test/lit/passes/precompute-gc-immutable.wast index 32e2d5719..c5fb5f0dc 100644 --- a/test/lit/passes/precompute-gc-immutable.wast +++ b/test/lit/passes/precompute-gc-immutable.wast @@ -670,11 +670,11 @@ ;; CHECK: (type $object (struct (field (ref $vtable)))) (type $object (struct (ref $vtable))) - ;; CHECK: (global $vtable (ref $vtable) (array.new_fixed $vtable + ;; CHECK: (global $vtable (ref $vtable) (array.new_fixed $vtable 1 ;; CHECK-NEXT: (ref.func $nested-creations) ;; CHECK-NEXT: )) (global $vtable (ref $vtable) - (array.new_fixed $vtable + (array.new_fixed $vtable 1 (ref.func $nested-creations) ) ) @@ -751,7 +751,7 @@ (type $vtable-1 (struct funcref)) ) - ;; CHECK: (global $itable (ref $itable) (array.new_fixed $itable + ;; CHECK: (global $itable (ref $itable) (array.new_fixed $itable 2 ;; CHECK-NEXT: (struct.new $vtable-0 ;; CHECK-NEXT: (ref.func $nested-creations) ;; CHECK-NEXT: ) @@ -760,7 +760,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: )) (global $itable (ref $itable) - (array.new_fixed $itable + (array.new_fixed $itable 2 (struct.new $vtable-0 (ref.func $nested-creations) ) @@ -794,7 +794,7 @@ ;; We can precompute all these operations away into the final constants. (call $helper (struct.get $vtable-0 0 - (ref.cast null $vtable-0 + (ref.cast (ref null $vtable-0) (array.get $itable (struct.get $object 0 (local.get $ref) @@ -806,7 +806,7 @@ ) (call $helper (struct.get $vtable-1 0 - (ref.cast null $vtable-1 + (ref.cast (ref null $vtable-1) (array.get $itable (struct.get $object 0 (local.get $ref) diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast index 94b076687..322342404 100644 --- a/test/lit/passes/precompute-gc.wast +++ b/test/lit/passes/precompute-gc.wast @@ -751,7 +751,7 @@ ;; ref.cast null instruction has, that is, the value is a null of type $B). So this ;; is an odd cast that "works". (local.set $temp - (ref.cast null $B + (ref.cast (ref null $B) (ref.null $A) ) ) @@ -786,7 +786,7 @@ ;; As above, but with a tuple. (local.set $temp (tuple.make - (ref.cast null $B + (ref.cast (ref null $B) (ref.null $A) ) (i32.const 10) @@ -810,7 +810,7 @@ ;; CHECK: (func $odd-cast-and-get-non-null (type $ref|$func-return-i32|_=>_none) (param $temp (ref $func-return-i32)) ;; CHECK-NEXT: (local.set $temp - ;; CHECK-NEXT: (ref.cast nofunc + ;; CHECK-NEXT: (ref.cast (ref nofunc) ;; CHECK-NEXT: (ref.func $receive-f64) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -823,7 +823,7 @@ (func $odd-cast-and-get-non-null (param $temp (ref $func-return-i32)) ;; Try to cast a function to an incompatible type. (local.set $temp - (ref.cast $func-return-i32 + (ref.cast (ref $func-return-i32) (ref.func $receive-f64) ) ) diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index 6f7dd5819..1b41e1257 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -101,7 +101,7 @@ ;; CHECK-NEXT: (block $block (result (ref $struct)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br $block - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.tee $any ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: ) @@ -111,7 +111,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (br_on_non_null $block - ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast (ref null $struct) ;; CHECK-NEXT: (local.tee $any ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) @@ -355,7 +355,7 @@ ;; CHECK-NEXT: (local $struct (ref null $struct)) ;; CHECK-NEXT: (block $block (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $struct + ;; CHECK-NEXT: (ref.cast (ref $struct) ;; CHECK-NEXT: (local.tee $any ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: ) @@ -545,7 +545,7 @@ ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) - ;; CHECK-NEXT: (ref.cast none + ;; CHECK-NEXT: (ref.cast (ref none) ;; CHECK-NEXT: (block (result i31ref) ;; CHECK-NEXT: (local.get $i31ref) ;; CHECK-NEXT: ) @@ -558,7 +558,7 @@ ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref none)) - ;; CHECK-NEXT: (ref.cast none + ;; CHECK-NEXT: (ref.cast (ref none) ;; CHECK-NEXT: (block (result i31ref) ;; CHECK-NEXT: (local.get $i31ref) ;; CHECK-NEXT: ) @@ -575,7 +575,7 @@ (drop (br_on_cast $block anyref (ref i31) (block (result anyref) - (ref.cast struct + (ref.cast (ref struct) (block (result anyref) (local.get $i31ref) ) @@ -585,7 +585,7 @@ ) (br_on_cast_fail $block anyref (ref i31) (block (result anyref) - (ref.cast struct + (ref.cast (ref struct) (block (result anyref) (local.get $i31ref) ) @@ -639,7 +639,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: (ref.test $struct + ;; CHECK-NEXT: (ref.test (ref $struct) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) @@ -649,7 +649,7 @@ ;; CHECK-NEXT: (if (result nullref) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (ref.cast null none + ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -701,7 +701,7 @@ (drop (if (result i32) (local.get $x) - (ref.test $struct + (ref.test (ref $struct) (ref.null any) ) (i32.const 0) @@ -711,7 +711,7 @@ (if (result anyref) (local.get $x) (ref.null any) - (ref.cast null $struct + (ref.cast (ref null $struct) (ref.null any) ) ) diff --git a/test/lit/passes/rse-gc.wast b/test/lit/passes/rse-gc.wast index e5d92abc9..6b90149a1 100644 --- a/test/lit/passes/rse-gc.wast +++ b/test/lit/passes/rse-gc.wast @@ -52,7 +52,7 @@ ;; CHECK: (func $pick-refined (type $ref?|$A|_i32_=>_none) (param $A (ref null $A)) (param $x i32) ;; CHECK-NEXT: (local $B (ref null $B)) ;; CHECK-NEXT: (local.set $B - ;; CHECK-NEXT: (ref.cast null $B + ;; CHECK-NEXT: (ref.cast (ref null $B) ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -81,7 +81,7 @@ (func $pick-refined (param $A (ref null $A)) (param $x i32) (local $B (ref null $B)) (local.set $B - (ref.cast null $B + (ref.cast (ref null $B) (local.get $A) ) ) @@ -113,7 +113,7 @@ ;; CHECK: (func $pick-refined-nn (type $ref|$A|_=>_none) (param $A (ref $A)) ;; CHECK-NEXT: (local $B (ref $B)) ;; CHECK-NEXT: (local.set $B - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -129,7 +129,7 @@ ;; As above, but now the types are both non-nullable. We should still switch ;; to $B. (local.set $B - (ref.cast $B + (ref.cast (ref $B) (local.get $A) ) ) @@ -144,7 +144,7 @@ ;; CHECK: (func $avoid-unrefined (type $ref|$A|_=>_none) (param $A (ref $A)) ;; CHECK-NEXT: (local $B (ref null $B)) ;; CHECK-NEXT: (local.set $B - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -161,7 +161,7 @@ ;; nullable, that means neither is a subtype of the other, and we will make ;; no changes. (local.set $B - (ref.cast $B + (ref.cast (ref $B) (local.get $A) ) ) diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index 63ca1ad0f..26fc72e96 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -833,7 +833,7 @@ ;; we do need to handle it in the optimization as well as print it (note how ;; type $A is declared in the output here - it would be a bug if it were ;; not, which this is a regression test for). - (ref.cast null $A + (ref.cast (ref null $A) (unreachable) ) ) diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index dc674b1b0..6c1c23291 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -862,18 +862,18 @@ ;; CHECK: (func $0 (type $none_=>_none) ;; CHECK-NEXT: (call $1 - ;; CHECK-NEXT: (array.new_fixed $[i8]) + ;; CHECK-NEXT: (array.new_fixed $[i8] 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $0 (call $1 - (array.new_fixed $[i8]) + (array.new_fixed $[i8] 0) ) ) ;; CHECK: (func $1 (type $ref|$[i8]|_=>_none) (param $2 (ref $[i8])) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast none + ;; CHECK-NEXT: (ref.cast (ref none) ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -882,7 +882,7 @@ ;; The param will become non-nullable after we refine. We must refinalize ;; after doing so, so the cast becomes non-nullable as well. (drop - (ref.cast null struct + (ref.cast structref (local.get $2) ) ) diff --git a/test/lit/passes/simplify-globals-gc.wast b/test/lit/passes/simplify-globals-gc.wast index da49cdf61..76ce984e7 100644 --- a/test/lit/passes/simplify-globals-gc.wast +++ b/test/lit/passes/simplify-globals-gc.wast @@ -14,14 +14,14 @@ ;; CHECK: (func $func (type $A) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (ref.func $func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $func (drop - (ref.cast null $A + (ref.cast (ref null $A) ;; This global can be replaced with a ref.func of $func. That has a more ;; refined type, so we should refinalize (if we do not, then the ref.cast ;; will fail to validate as it must become a non-nullable cast). diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index 155649dbb..2658bae62 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -433,7 +433,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $B 0 ;; CHECK-NEXT: (local.tee $B - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -456,7 +456,7 @@ ;; nullability but not the heap type. (local $B (ref null $B)) (local.set $B - (ref.cast $B + (ref.cast (ref $B) (local.get $A) ) ) @@ -520,8 +520,8 @@ ;; CHECK: (func $redundant-tee-finalize (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast any - ;; CHECK-NEXT: (ref.cast any + ;; CHECK-NEXT: (ref.cast (ref any) + ;; CHECK-NEXT: (ref.cast (ref any) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -532,9 +532,9 @@ ;; After doing so, the outer cast should become non-nullable as we ;; refinalize. (drop - (ref.cast null any + (ref.cast anyref (local.tee $x - (ref.cast any + (ref.cast (ref any) (local.get $x) ) ) diff --git a/test/lit/passes/type-merging-tnh.wast b/test/lit/passes/type-merging-tnh.wast index 5321b9cce..e10e6434c 100644 --- a/test/lit/passes/type-merging-tnh.wast +++ b/test/lit/passes/type-merging-tnh.wast @@ -11,12 +11,12 @@ ;; CHECK: (type $ref|$A|_=>_ref|$A| (func (param (ref $A)) (result (ref $A)))) ;; CHECK: (func $test (type $ref|$A|_=>_ref|$A|) (param $a (ref $A)) (result (ref $A)) - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test (param $a (ref $A)) (result (ref $B)) - (ref.cast $B + (ref.cast (ref $B) (local.get $a) ) ) @@ -33,12 +33,12 @@ ;; CHECK: (type $ref|$A|_=>_i32 (func (param (ref $A)) (result i32))) ;; CHECK: (func $test (type $ref|$A|_=>_i32) (param $a (ref $A)) (result i32) - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test (param $a (ref $A)) (result i32) - (ref.test $B + (ref.test (ref $B) (local.get $a) ) ) diff --git a/test/lit/passes/type-merging.wast b/test/lit/passes/type-merging.wast index 66d1e1222..f7cae2a42 100644 --- a/test/lit/passes/type-merging.wast +++ b/test/lit/passes/type-merging.wast @@ -34,12 +34,12 @@ ;; CHECK-NEXT: (local $f (ref null $F)) ;; CHECK-NEXT: (local $g (ref null $G)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $A + ;; CHECK-NEXT: (ref.cast (ref null $A) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $F + ;; CHECK-NEXT: (ref.cast (ref null $F) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -62,13 +62,13 @@ ;; A cast of $A has no effect. (drop - (ref.cast null $A + (ref.cast (ref null $A) (local.get $a) ) ) ;; A cast of $F prevents it from being merged. (drop - (ref.cast null $F + (ref.cast (ref null $F) (local.get $a) ) ) @@ -342,7 +342,7 @@ ;; CHECK-NEXT: (local $x (ref null $X)) ;; CHECK-NEXT: (local $y (ref null $X)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $A + ;; CHECK-NEXT: (ref.cast (ref $A) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -356,7 +356,7 @@ (local $y (ref null $Y)) (drop - (ref.cast $A + (ref.cast (ref $A) (local.get $a) ) ) @@ -689,7 +689,7 @@ ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: (global.get $global$0) ;; CHECK-NEXT: (i64.const 0) - ;; CHECK-NEXT: (array.new_fixed $I) + ;; CHECK-NEXT: (array.new_fixed $I 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $0 (type $G) (param $0 (ref $C)) (result (ref $D)) @@ -698,7 +698,7 @@ (i32.const 0) (global.get $global$0) (i64.const 0) - (array.new_fixed $I) + (array.new_fixed $I 0) ) ) ) @@ -896,7 +896,7 @@ ;; CHECK: (func $test (type $none_=>_ref|$b|) (result (ref $b)) ;; CHECK-NEXT: (local $0 (ref null $a)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $y + ;; CHECK-NEXT: (ref.test (ref $y) ;; CHECK-NEXT: (struct.new_default $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -908,7 +908,7 @@ ;; Cast to prevent $x and $y from being merged. (drop - (ref.test $y + (ref.test (ref $y) (struct.new_default $x) ) ) @@ -964,12 +964,12 @@ ;; CHECK: (type $ref|$A|_=>_i32 (func (param (ref $A)) (result i32))) ;; CHECK: (func $test (type $ref|$A|_=>_i32) (param $a (ref $A)) (result i32) - ;; CHECK-NEXT: (ref.test $B + ;; CHECK-NEXT: (ref.test (ref $B) ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test (param $a (ref $A)) (result i32) - (ref.test $B + (ref.test (ref $B) (local.get $a) ) ) diff --git a/test/lit/passes/type-refining.wast b/test/lit/passes/type-refining.wast index dac509887..34e1206c2 100644 --- a/test/lit/passes/type-refining.wast +++ b/test/lit/passes/type-refining.wast @@ -1139,7 +1139,7 @@ ;; CHECK: (func $0 (type $none_=>_ref|$A|) (result (ref $A)) ;; CHECK-NEXT: (struct.new $A - ;; CHECK-NEXT: (ref.cast $B + ;; CHECK-NEXT: (ref.cast (ref $B) ;; CHECK-NEXT: (struct.get $A 0 ;; CHECK-NEXT: (struct.new $A ;; CHECK-NEXT: (struct.new_default $B) @@ -1157,7 +1157,7 @@ ;; well, as otherwise the struct.new will not validate - we can't write a ;; (ref struct) to a field of (ref $B). (struct.new $A - (ref.cast struct + (ref.cast (ref struct) (struct.get $A 0 (struct.new $A (struct.new_default $B) @@ -1245,7 +1245,7 @@ ;; CHECK: (func $struct.new (type $externref_=>_anyref) (param $extern externref) (result anyref) ;; CHECK-NEXT: (struct.new $A - ;; CHECK-NEXT: (ref.cast noextern + ;; CHECK-NEXT: (ref.cast (ref noextern) ;; CHECK-NEXT: (try $try (result externref) ;; CHECK-NEXT: (do ;; CHECK-NEXT: (struct.get $A 0 @@ -1297,7 +1297,7 @@ ;; CHECK: (func $struct.set (type $ref|$A|_externref_=>_none) (param $ref (ref $A)) (param $extern externref) ;; CHECK-NEXT: (struct.set $A 0 ;; CHECK-NEXT: (local.get $ref) - ;; CHECK-NEXT: (ref.cast noextern + ;; CHECK-NEXT: (ref.cast (ref noextern) ;; CHECK-NEXT: (try $try (result externref) ;; CHECK-NEXT: (do ;; CHECK-NEXT: (struct.get $A 0 diff --git a/test/lit/passes/type-ssa.wast b/test/lit/passes/type-ssa.wast index dedf43832..f5572ab4a 100644 --- a/test/lit/passes/type-ssa.wast +++ b/test/lit/passes/type-ssa.wast @@ -311,22 +311,22 @@ ;; CHECK: (func $array.new_fixed (type $ref|i31|_anyref_=>_none) (param $refined (ref i31)) (param $null-any anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array$5 + ;; CHECK-NEXT: (array.new_fixed $array$5 1 ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array$6 + ;; CHECK-NEXT: (array.new_fixed $array$6 1 ;; CHECK-NEXT: (local.get $refined) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array + ;; CHECK-NEXT: (array.new_fixed $array 1 ;; CHECK-NEXT: (local.get $null-any) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array + ;; CHECK-NEXT: (array.new_fixed $array 2 ;; CHECK-NEXT: (local.get $refined) ;; CHECK-NEXT: (local.get $null-any) ;; CHECK-NEXT: ) @@ -335,26 +335,26 @@ (func $array.new_fixed (param $refined (ref i31)) (param $null-any (ref null any)) ;; Null, interesting, so we get a new type. (drop - (array.new_fixed $array + (array.new_fixed $array 1 (ref.null none) ) ) ;; More refined type, interesting. (drop - (array.new_fixed $array + (array.new_fixed $array 1 (local.get $refined) ) ) ;; Same type as declared - boring, no new type. (drop - (array.new_fixed $array + (array.new_fixed $array 1 (local.get $null-any) ) ) ;; Mixture of boring and interesting => boring (since we infer a single type ;; for the entire array). (drop - (array.new_fixed $array + (array.new_fixed $array 2 (local.get $refined) (local.get $null-any) ) diff --git a/test/lit/passes/vacuum-gc.wast b/test/lit/passes/vacuum-gc.wast index fcdeb8cd2..f2e2972f5 100644 --- a/test/lit/passes/vacuum-gc.wast +++ b/test/lit/passes/vacuum-gc.wast @@ -18,7 +18,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -32,7 +32,7 @@ ) ) (drop - (ref.cast null i31 + (ref.cast i31ref (local.get $x) ) ) @@ -81,7 +81,7 @@ ) ;; CHECK: (func $ref.cast.null.block (type $ref|${}|_=>_structref) (param $ref (ref ${})) (result structref) - ;; CHECK-NEXT: (ref.cast ${} + ;; CHECK-NEXT: (ref.cast (ref ${}) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -90,7 +90,7 @@ ;; on a non-nullable input. That is, we are refining the input to the cast. ;; The cast must be updated properly following that, to be a non-nullable ;; cast. - (ref.cast null ${} + (ref.cast (ref null ${}) (block (result (ref null ${})) (local.get $ref) ) diff --git a/test/lit/passes/vacuum-tnh.wast b/test/lit/passes/vacuum-tnh.wast index c3de8c21c..bccfa02f4 100644 --- a/test/lit/passes/vacuum-tnh.wast +++ b/test/lit/passes/vacuum-tnh.wast @@ -33,7 +33,7 @@ ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast null i31 + ;; NO_TNH-NEXT: (ref.cast i31ref ;; NO_TNH-NEXT: (local.get $y) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -57,7 +57,7 @@ ;; Other casts as well. (drop - (ref.cast null i31 + (ref.cast i31ref (local.get $y) ) ) diff --git a/test/lit/ref_cast_test.wast b/test/lit/ref_cast_test.wast index c44278c13..3ff05c48c 100644 --- a/test/lit/ref_cast_test.wast +++ b/test/lit/ref_cast_test.wast @@ -8,82 +8,82 @@ (type $array (array i32)) ;; CHECK: (func $test (type $eqref_=>_none) (param $0 eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $array + ;; CHECK-NEXT: (ref.cast (ref null $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast i31 + ;; CHECK-NEXT: (ref.cast (ref i31) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast $array + ;; CHECK-NEXT: (ref.cast (ref $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null $array + ;; CHECK-NEXT: (ref.cast (ref null $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast i31 + ;; CHECK-NEXT: (ref.cast (ref i31) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null i31 + ;; CHECK-NEXT: (ref.cast i31ref ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $array + ;; CHECK-NEXT: (ref.test (ref $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test null $array + ;; CHECK-NEXT: (ref.test (ref null $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test i31 + ;; CHECK-NEXT: (ref.test (ref i31) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test null i31 + ;; CHECK-NEXT: (ref.test i31ref ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test $array + ;; CHECK-NEXT: (ref.test (ref $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test null $array + ;; CHECK-NEXT: (ref.test (ref null $array) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test i31 + ;; CHECK-NEXT: (ref.test (ref i31) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test null i31 + ;; CHECK-NEXT: (ref.test i31ref ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index b1ca259a3..0be1beb0e 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -274,7 +274,7 @@ (call $log (array.len (local.tee $0 - (array.new_fixed $bytes + (array.new_fixed $bytes 2 (i32.const 42) (i32.const 50) ) @@ -297,7 +297,7 @@ (func $17 (type $void_func) (; has Stack IR ;) (call $log (array.get_u $bytes - (array.new_fixed $bytes + (array.new_fixed $bytes 1 (i32.const -11512) ) (i32.const 0) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index b057e0c16..5c48c4d3f 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -148,7 +148,7 @@ ;; array or a struct, so our casting code should not assume it is. it is ok ;; to try to cast it, and the result should be 0. (call $log - (ref.test $struct + (ref.test (ref $struct) (ref.null any) ) ) @@ -179,7 +179,7 @@ ) (func "ref-as-func-of-func" (drop - (ref.cast func + (ref.cast (ref func) (ref.func $0) ) ) @@ -191,12 +191,12 @@ (call $log (i32.const 0)) ;; a valid cast (call_ref $void_func - (ref.cast $void_func (ref.func $a-void-func)) + (ref.cast (ref $void_func) (ref.func $a-void-func)) ) (call $log (i32.const 1)) ;; an invalid cast (drop (call_ref $int_func - (ref.cast $int_func (ref.func $a-void-func)) + (ref.cast (ref $int_func) (ref.func $a-void-func)) )) ;; will never be reached (call $log (i32.const 2)) @@ -274,7 +274,7 @@ (func "array.new_fixed" (local $x (ref null $bytes)) (local.set $x - (array.new_fixed $bytes + (array.new_fixed $bytes 2 (i32.const 42) ;; first value (i32.const 50) ;; second value ) @@ -295,7 +295,7 @@ (func "array.new_fixed-packed" (local $x (ref null $bytes)) (local.set $x - (array.new_fixed $bytes + (array.new_fixed $bytes 1 (i32.const -11512) ) ) @@ -307,15 +307,15 @@ (func "static-casts" ;; Casting null returns null. (call $log (ref.is_null - (ref.cast null $struct (ref.null $struct)) + (ref.cast (ref null $struct) (ref.null $struct)) )) ;; Testing null returns 0. (call $log - (ref.test $struct (ref.null $struct)) + (ref.test (ref $struct) (ref.null $struct)) ) ;; Testing something completely wrong (struct vs array) returns 0. (call $log - (ref.test $struct + (ref.test (ref $struct) (array.new $bytes (i32.const 20) (i32.const 10) @@ -324,19 +324,19 @@ ) ;; Testing a thing with the same type returns 1. (call $log - (ref.test $struct + (ref.test (ref $struct) (struct.new_default $struct) ) ) ;; A bad downcast returns 0: we create a struct, which is not a extendedstruct. (call $log - (ref.test $extendedstruct + (ref.test (ref $extendedstruct) (struct.new_default $struct) ) ) ;; Casting to a supertype works. (call $log - (ref.test $struct + (ref.test (ref $struct) (struct.new_default $extendedstruct) ) ) diff --git a/test/spec/array-new-elem.wast b/test/spec/array-new-elem.wast index 9e1ac9116..e5089b69c 100644 --- a/test/spec/array-new-elem.wast +++ b/test/spec/array-new-elem.wast @@ -16,7 +16,7 @@ ) (func $get (param $i i32) (param $v (ref $vec)) (result i32) - (call_ref $f (ref.cast null $f (array.get $vec (local.get $v) (local.get $i)))) + (call_ref $f (ref.cast (ref null $f) (array.get $vec (local.get $v) (local.get $i)))) ) (func (export "get") (param $i i32) (result i32) (call $get (local.get $i) (call $new)) @@ -24,7 +24,7 @@ (func $set_get (param $i i32) (param $v (ref $mvec)) (param $y i32) (result i32) (array.set $mvec (local.get $v) (local.get $i) (array.get $mvec (local.get $v) (local.get $y))) - (call_ref $f (ref.cast null $f (array.get $mvec (local.get $v) (local.get $i)))) + (call_ref $f (ref.cast (ref null $f) (array.get $mvec (local.get $v) (local.get $i)))) ) (func (export "set_get") (param $i i32) (param $y i32) (result i32) (call $set_get diff --git a/test/spec/ref_cast.wast b/test/spec/ref_cast.wast index 8f7e3eb7f..d68baf45e 100644 --- a/test/spec/ref_cast.wast +++ b/test/spec/ref_cast.wast @@ -29,65 +29,65 @@ (func (export "test-sub") (call $init) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t0 (struct.new_default $t0))) - (drop (ref.cast null $t0 (global.get $tab.0))) - (drop (ref.cast null $t0 (global.get $tab.1))) - (drop (ref.cast null $t0 (global.get $tab.2))) - (drop (ref.cast null $t0 (global.get $tab.3))) - (drop (ref.cast null $t0 (global.get $tab.4))) - (drop (ref.cast $t0 (global.get $tab.0))) - (drop (ref.cast $t0 (global.get $tab.1))) - (drop (ref.cast $t0 (global.get $tab.2))) - (drop (ref.cast $t0 (global.get $tab.3))) - (drop (ref.cast $t0 (global.get $tab.4))) - - (drop (ref.cast null $t1 (ref.null struct))) - (drop (ref.cast null $t1 (struct.new_default $t1))) - (drop (ref.cast null $t1 (global.get $tab.1))) - (drop (ref.cast null $t1 (global.get $tab.2))) - (drop (ref.cast $t1 (global.get $tab.1))) - (drop (ref.cast $t1 (global.get $tab.2))) - - (drop (ref.cast null $t2 (ref.null struct))) - (drop (ref.cast null $t2 (struct.new_default $t2))) - (drop (ref.cast null $t2 (global.get $tab.2))) - (drop (ref.cast $t2 (global.get $tab.2))) - - (drop (ref.cast null $t3 (ref.null struct))) - (drop (ref.cast null $t3 (struct.new_default $t3))) - (drop (ref.cast null $t3 (global.get $tab.3))) - (drop (ref.cast $t3 (global.get $tab.3))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t0) (struct.new_default $t0))) + (drop (ref.cast (ref null $t0) (global.get $tab.0))) + (drop (ref.cast (ref null $t0) (global.get $tab.1))) + (drop (ref.cast (ref null $t0) (global.get $tab.2))) + (drop (ref.cast (ref null $t0) (global.get $tab.3))) + (drop (ref.cast (ref null $t0) (global.get $tab.4))) + (drop (ref.cast (ref $t0) (global.get $tab.0))) + (drop (ref.cast (ref $t0) (global.get $tab.1))) + (drop (ref.cast (ref $t0) (global.get $tab.2))) + (drop (ref.cast (ref $t0) (global.get $tab.3))) + (drop (ref.cast (ref $t0) (global.get $tab.4))) + + (drop (ref.cast (ref null $t1) (ref.null struct))) + (drop (ref.cast (ref null $t1) (struct.new_default $t1))) + (drop (ref.cast (ref null $t1) (global.get $tab.1))) + (drop (ref.cast (ref null $t1) (global.get $tab.2))) + (drop (ref.cast (ref $t1) (global.get $tab.1))) + (drop (ref.cast (ref $t1) (global.get $tab.2))) + + (drop (ref.cast (ref null $t2) (ref.null struct))) + (drop (ref.cast (ref null $t2) (struct.new_default $t2))) + (drop (ref.cast (ref null $t2) (global.get $tab.2))) + (drop (ref.cast (ref $t2) (global.get $tab.2))) + + (drop (ref.cast (ref null $t3) (ref.null struct))) + (drop (ref.cast (ref null $t3) (struct.new_default $t3))) + (drop (ref.cast (ref null $t3) (global.get $tab.3))) + (drop (ref.cast (ref $t3) (global.get $tab.3))) ) (func (export "test-canon") (call $init) - (drop (ref.cast null $t0 (global.get $tab.10))) - (drop (ref.cast null $t0 (global.get $tab.11))) - (drop (ref.cast null $t0 (global.get $tab.12))) + (drop (ref.cast (ref null $t0) (global.get $tab.10))) + (drop (ref.cast (ref null $t0) (global.get $tab.11))) + (drop (ref.cast (ref null $t0) (global.get $tab.12))) - (drop (ref.cast null $t1 (global.get $tab.11))) - (drop (ref.cast null $t1 (global.get $tab.12))) + (drop (ref.cast (ref null $t1) (global.get $tab.11))) + (drop (ref.cast (ref null $t1) (global.get $tab.12))) - (drop (ref.cast null $t2 (global.get $tab.12))) + (drop (ref.cast (ref null $t2) (global.get $tab.12))) ) (func (export "test-ref-test-t0") (result i32) - (ref.test $t0 (struct.new $t0)) + (ref.test (ref $t0) (struct.new $t0)) ) (func (export "test-ref-test-struct") (result i32) - (ref.test struct (struct.new $t0)) + (ref.test (ref struct) (struct.new $t0)) ) (func (export "test-ref-test-any") (result i32) - (ref.test any (struct.new $t0)) + (ref.test (ref any) (struct.new $t0)) ) (func (export "test-ref-cast-struct") (drop - (ref.cast struct (struct.new $t0)) + (ref.cast (ref struct) (struct.new $t0)) ) ) @@ -141,7 +141,7 @@ (func (export "test-trap-null") (drop - (ref.cast $t0 + (ref.cast (ref $t0) (ref.null $t0) ) ) @@ -164,7 +164,7 @@ (module (type $t0 (struct)) (func (export "test-ref-test-extern") (result i32) - (ref.test extern (struct.new $t0)) + (ref.test (ref extern) (struct.new $t0)) ) ) "common supertype" diff --git a/test/spec/ref_test.wast b/test/spec/ref_test.wast index b5291e179..6b6369459 100644 --- a/test/spec/ref_test.wast +++ b/test/spec/ref_test.wast @@ -37,63 +37,63 @@ (func (export "ref_test_null_data") (param $i i32) (result i32) (i32.add (ref.is_null (table.get $ta (local.get $i))) - (ref.test null none (table.get $ta (local.get $i))) + (ref.test nullref (table.get $ta (local.get $i))) ) ) (func (export "ref_test_any") (param $i i32) (result i32) (i32.add - (ref.test any (table.get $ta (local.get $i))) - (ref.test null any (table.get $ta (local.get $i))) + (ref.test (ref any) (table.get $ta (local.get $i))) + (ref.test anyref (table.get $ta (local.get $i))) ) ) (func (export "ref_test_eq") (param $i i32) (result i32) (i32.add - (ref.test eq (table.get $ta (local.get $i))) - (ref.test null eq (table.get $ta (local.get $i))) + (ref.test (ref eq) (table.get $ta (local.get $i))) + (ref.test eqref (table.get $ta (local.get $i))) ) ) (func (export "ref_test_i31") (param $i i32) (result i32) (i32.add - (ref.test i31 (table.get $ta (local.get $i))) - (ref.test null i31 (table.get $ta (local.get $i))) + (ref.test (ref i31) (table.get $ta (local.get $i))) + (ref.test i31ref (table.get $ta (local.get $i))) ) ) (func (export "ref_test_struct") (param $i i32) (result i32) (i32.add - (ref.test struct (table.get $ta (local.get $i))) - (ref.test null struct (table.get $ta (local.get $i))) + (ref.test (ref struct) (table.get $ta (local.get $i))) + (ref.test structref (table.get $ta (local.get $i))) ) ) (func (export "ref_test_array") (param $i i32) (result i32) (i32.add - (ref.test array (table.get $ta (local.get $i))) - (ref.test null array (table.get $ta (local.get $i))) + (ref.test (ref array) (table.get $ta (local.get $i))) + (ref.test arrayref (table.get $ta (local.get $i))) ) ) (func (export "ref_test_null_func") (param $i i32) (result i32) (i32.add (ref.is_null (table.get $tf (local.get $i))) - (ref.test null nofunc (table.get $tf (local.get $i))) + (ref.test nullfuncref (table.get $tf (local.get $i))) ) ) (func (export "ref_test_func") (param $i i32) (result i32) (i32.add - (ref.test func (table.get $tf (local.get $i))) - (ref.test null func (table.get $tf (local.get $i))) + (ref.test (ref func) (table.get $tf (local.get $i))) + (ref.test funcref (table.get $tf (local.get $i))) ) ) (func (export "ref_test_null_extern") (param $i i32) (result i32) (i32.add (ref.is_null (table.get $te (local.get $i))) - (ref.test null noextern (table.get $te (local.get $i))) + (ref.test nullexternref (table.get $te (local.get $i))) ) ) (func (export "ref_test_extern") (param $i i32) (result i32) (i32.add - (ref.test extern (table.get $te (local.get $i))) - (ref.test null extern (table.get $te (local.get $i))) + (ref.test (ref extern) (table.get $te (local.get $i))) + (ref.test externref (table.get $te (local.get $i))) ) ) ) @@ -206,91 +206,91 @@ (call $init) (block $l ;; must hold - (br_if $l (i32.eqz (ref.test null $t0 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get $tab (i32.const 0))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get $tab (i32.const 1))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get $tab (i32.const 2))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get $tab (i32.const 3))))) - (br_if $l (i32.eqz (ref.test null $t0 (table.get $tab (i32.const 4))))) - - (br_if $l (i32.eqz (ref.test null $t1 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t1 (table.get $tab (i32.const 1))))) - (br_if $l (i32.eqz (ref.test null $t1 (table.get $tab (i32.const 2))))) - - (br_if $l (i32.eqz (ref.test null $t2 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t2 (table.get $tab (i32.const 2))))) - - (br_if $l (i32.eqz (ref.test null $t3 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t3 (table.get $tab (i32.const 3))))) - - (br_if $l (i32.eqz (ref.test null $t4 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t4)))) - (br_if $l (i32.eqz (ref.test null $t4 (table.get $tab (i32.const 4))))) - - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 0))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 3))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 4))))) - - (br_if $l (i32.eqz (ref.test $t1 (table.get $tab (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get $tab (i32.const 2))))) - - (br_if $l (i32.eqz (ref.test $t2 (table.get $tab (i32.const 2))))) - - (br_if $l (i32.eqz (ref.test $t3 (table.get $tab (i32.const 3))))) - - (br_if $l (i32.eqz (ref.test $t4 (table.get $tab (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get $tab (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get $tab (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get $tab (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get $tab (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get $tab (i32.const 4))))) + + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get $tab (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get $tab (i32.const 2))))) + + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (table.get $tab (i32.const 2))))) + + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (table.get $tab (i32.const 3))))) + + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (table.get $tab (i32.const 4))))) + + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 4))))) + + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get $tab (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get $tab (i32.const 2))))) + + (br_if $l (i32.eqz (ref.test (ref $t2) (table.get $tab (i32.const 2))))) + + (br_if $l (i32.eqz (ref.test (ref $t3) (table.get $tab (i32.const 3))))) + + (br_if $l (i32.eqz (ref.test (ref $t4) (table.get $tab (i32.const 4))))) ;; must not hold - (br_if $l (ref.test $t0 (ref.null struct))) - (br_if $l (ref.test $t1 (ref.null struct))) - (br_if $l (ref.test $t2 (ref.null struct))) - (br_if $l (ref.test $t3 (ref.null struct))) - (br_if $l (ref.test $t4 (ref.null struct))) - - (br_if $l (ref.test $t1 (table.get $tab (i32.const 0)))) - (br_if $l (ref.test $t1 (table.get $tab (i32.const 3)))) - (br_if $l (ref.test $t1 (table.get $tab (i32.const 4)))) - - (br_if $l (ref.test $t2 (table.get $tab (i32.const 0)))) - (br_if $l (ref.test $t2 (table.get $tab (i32.const 1)))) - (br_if $l (ref.test $t2 (table.get $tab (i32.const 3)))) - (br_if $l (ref.test $t2 (table.get $tab (i32.const 4)))) - - (br_if $l (ref.test $t3 (table.get $tab (i32.const 0)))) - (br_if $l (ref.test $t3 (table.get $tab (i32.const 1)))) - (br_if $l (ref.test $t3 (table.get $tab (i32.const 2)))) - (br_if $l (ref.test $t3 (table.get $tab (i32.const 4)))) - - (br_if $l (ref.test $t4 (table.get $tab (i32.const 0)))) - (br_if $l (ref.test $t4 (table.get $tab (i32.const 1)))) - (br_if $l (ref.test $t4 (table.get $tab (i32.const 2)))) - (br_if $l (ref.test $t4 (table.get $tab (i32.const 3)))) + (br_if $l (ref.test (ref $t0) (ref.null struct))) + (br_if $l (ref.test (ref $t1) (ref.null struct))) + (br_if $l (ref.test (ref $t2) (ref.null struct))) + (br_if $l (ref.test (ref $t3) (ref.null struct))) + (br_if $l (ref.test (ref $t4) (ref.null struct))) + + (br_if $l (ref.test (ref $t1) (table.get $tab (i32.const 0)))) + (br_if $l (ref.test (ref $t1) (table.get $tab (i32.const 3)))) + (br_if $l (ref.test (ref $t1) (table.get $tab (i32.const 4)))) + + (br_if $l (ref.test (ref $t2) (table.get $tab (i32.const 0)))) + (br_if $l (ref.test (ref $t2) (table.get $tab (i32.const 1)))) + (br_if $l (ref.test (ref $t2) (table.get $tab (i32.const 3)))) + (br_if $l (ref.test (ref $t2) (table.get $tab (i32.const 4)))) + + (br_if $l (ref.test (ref $t3) (table.get $tab (i32.const 0)))) + (br_if $l (ref.test (ref $t3) (table.get $tab (i32.const 1)))) + (br_if $l (ref.test (ref $t3) (table.get $tab (i32.const 2)))) + (br_if $l (ref.test (ref $t3) (table.get $tab (i32.const 4)))) + + (br_if $l (ref.test (ref $t4) (table.get $tab (i32.const 0)))) + (br_if $l (ref.test (ref $t4) (table.get $tab (i32.const 1)))) + (br_if $l (ref.test (ref $t4) (table.get $tab (i32.const 2)))) + (br_if $l (ref.test (ref $t4) (table.get $tab (i32.const 3)))) (return) ) @@ -300,25 +300,25 @@ (func (export "test-canon") (call $init) (block $l - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 0))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 3))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 3))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 4))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 10))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 11))))) - (br_if $l (i32.eqz (ref.test $t0 (table.get $tab (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 10))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 11))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get $tab (i32.const 12))))) - (br_if $l (i32.eqz (ref.test $t1' (table.get $tab (i32.const 1))))) - (br_if $l (i32.eqz (ref.test $t1' (table.get $tab (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t1') (table.get $tab (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t1') (table.get $tab (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get $tab (i32.const 11))))) - (br_if $l (i32.eqz (ref.test $t1 (table.get $tab (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get $tab (i32.const 11))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get $tab (i32.const 12))))) - (br_if $l (i32.eqz (ref.test $t2' (table.get $tab (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t2') (table.get $tab (i32.const 2))))) - (br_if $l (i32.eqz (ref.test $t2 (table.get $tab (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t2) (table.get $tab (i32.const 12))))) (return) ) |