diff options
Diffstat (limited to 'test/lit/passes/optimize-instructions-gc-iit.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc-iit.wast | 198 |
1 files changed, 68 insertions, 130 deletions
diff --git a/test/lit/passes/optimize-instructions-gc-iit.wast b/test/lit/passes/optimize-instructions-gc-iit.wast index 3a098c0b4..0e315dd5d 100644 --- a/test/lit/passes/optimize-instructions-gc-iit.wast +++ b/test/lit/passes/optimize-instructions-gc-iit.wast @@ -1,38 +1,31 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + ;; RUN: foreach %s %t wasm-opt --optimize-instructions --ignore-implicit-traps --enable-reference-types --enable-gc -S -o - \ ;; RUN: | filecheck %s -;; RUN: foreach %s %t wasm-opt --optimize-instructions --ignore-implicit-traps --enable-reference-types --enable-gc --nominal -S -o - \ -;; RUN: | filecheck %s --check-prefix NOMNL -;; Also test trapsNeverHappen (with nominal; no need for both type system modes). -;; RUN: foreach %s %t wasm-opt --optimize-instructions --traps-never-happen --enable-reference-types --enable-gc --nominal -S -o - \ -;; RUN: | filecheck %s --check-prefix NOMNL-TNH + +;; Also test trapsNeverHappen +;; RUN: foreach %s %t wasm-opt --optimize-instructions --traps-never-happen --enable-reference-types --enable-gc -S -o - \ +;; RUN: | filecheck %s --check-prefix TNH (module ;; CHECK: (type $parent (struct (field i32))) - ;; NOMNL: (type $parent (struct (field i32))) - ;; NOMNL-TNH: (type $parent (struct (field i32))) + ;; TNH: (type $parent (struct (field i32))) (type $parent (struct (field i32))) ;; CHECK: (type $child (struct_subtype (field i32) (field f64) $parent)) - ;; NOMNL: (type $child (struct_subtype (field i32) (field f64) $parent)) - ;; NOMNL-TNH: (type $child (struct_subtype (field i32) (field f64) $parent)) + ;; TNH: (type $child (struct_subtype (field i32) (field f64) $parent)) (type $child (struct_subtype (field i32) (field f64) $parent)) ;; CHECK: (type $other (struct (field i64) (field f32))) - ;; NOMNL: (type $other (struct (field i64) (field f32))) - ;; NOMNL-TNH: (type $other (struct (field i64) (field f32))) + ;; TNH: (type $other (struct (field i64) (field f32))) (type $other (struct (field i64) (field f32))) ;; CHECK: (func $foo (type $none_=>_none) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) - ;; NOMNL: (func $foo (type $none_=>_none) - ;; NOMNL-NEXT: (nop) - ;; NOMNL-NEXT: ) - ;; NOMNL-TNH: (func $foo (type $none_=>_none) - ;; NOMNL-TNH-NEXT: (nop) - ;; NOMNL-TNH-NEXT: ) + ;; TNH: (func $foo (type $none_=>_none) + ;; TNH-NEXT: (nop) + ;; TNH-NEXT: ) (func $foo) - ;; CHECK: (func $ref-cast-iit (type $ref|$parent|_ref|$child|_ref|$other|_=>_none) (param $parent (ref $parent)) (param $child (ref $child)) (param $other (ref $other)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $parent) @@ -54,48 +47,27 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $ref-cast-iit (type $ref|$parent|_ref|$child|_ref|$other|_=>_none) (param $parent (ref $parent)) (param $child (ref $child)) (param $other (ref $other)) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (local.get $parent) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (local.get $child) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast $child - ;; NOMNL-NEXT: (local.get $parent) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (block - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (local.get $child) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (unreachable) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-TNH: (func $ref-cast-iit (type $ref|$parent|_ref|$child|_ref|$other|_=>_none) (param $parent (ref $parent)) (param $child (ref $child)) (param $other (ref $other)) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (local.get $parent) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (local.get $child) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (ref.cast $child - ;; NOMNL-TNH-NEXT: (local.get $parent) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (block - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (local.get $child) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: (unreachable) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) + ;; TNH: (func $ref-cast-iit (type $ref|$parent|_ref|$child|_ref|$other|_=>_none) (param $parent (ref $parent)) (param $child (ref $child)) (param $other (ref $other)) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (local.get $parent) + ;; TNH-NEXT: ) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (local.get $child) + ;; TNH-NEXT: ) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (ref.cast $child + ;; TNH-NEXT: (local.get $parent) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (block + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (local.get $child) + ;; TNH-NEXT: ) + ;; TNH-NEXT: (unreachable) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) (func $ref-cast-iit (param $parent (ref $parent)) (param $child (ref $child)) @@ -146,38 +118,22 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $ref-cast-iit-bad (type $ref|$parent|_=>_none) (param $parent (ref $parent)) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (block (result (ref $parent)) - ;; NOMNL-NEXT: (call $foo) - ;; NOMNL-NEXT: (local.get $parent) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (block ;; (replaces something unreachable we can't emit) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (unreachable) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (unreachable) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-TNH: (func $ref-cast-iit-bad (type $ref|$parent|_=>_none) (param $parent (ref $parent)) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (block (result (ref $parent)) - ;; NOMNL-TNH-NEXT: (call $foo) - ;; NOMNL-TNH-NEXT: (local.get $parent) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (block ;; (replaces something unreachable we can't emit) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (unreachable) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: (unreachable) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) + ;; TNH: (func $ref-cast-iit-bad (type $ref|$parent|_=>_none) (param $parent (ref $parent)) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (block (result (ref $parent)) + ;; TNH-NEXT: (call $foo) + ;; TNH-NEXT: (local.get $parent) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (block ;; (replaces something unreachable we can't emit) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (unreachable) + ;; TNH-NEXT: ) + ;; TNH-NEXT: (unreachable) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) (func $ref-cast-iit-bad (param $parent (ref $parent)) @@ -204,16 +160,11 @@ ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $ref-eq-ref-cast (type $eqref_=>_none) (param $x eqref) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (i32.const 1) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-TNH: (func $ref-eq-ref-cast (type $eqref_=>_none) (param $x eqref) - ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (i32.const 1) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) + ;; TNH: (func $ref-eq-ref-cast (type $eqref_=>_none) (param $x eqref) + ;; TNH-NEXT: (drop + ;; TNH-NEXT: (i32.const 1) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) (func $ref-eq-ref-cast (param $x eqref) ;; we can look through a ref.cast null if we ignore traps (drop @@ -231,16 +182,11 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $set-of-as-non-null (type $anyref_=>_none) (param $x anyref) - ;; NOMNL-NEXT: (local.set $x - ;; NOMNL-NEXT: (local.get $x) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-TNH: (func $set-of-as-non-null (type $anyref_=>_none) (param $x anyref) - ;; NOMNL-TNH-NEXT: (local.set $x - ;; NOMNL-TNH-NEXT: (local.get $x) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) + ;; TNH: (func $set-of-as-non-null (type $anyref_=>_none) (param $x anyref) + ;; TNH-NEXT: (local.set $x + ;; TNH-NEXT: (local.get $x) + ;; TNH-NEXT: ) + ;; TNH-NEXT: ) (func $set-of-as-non-null (param $x anyref) ;; As we ignore such traps, we can remove the ref.as here. (local.set $x @@ -255,20 +201,17 @@ (rec ;; CHECK: (rec ;; CHECK-NEXT: (type $A (struct )) - ;; NOMNL: (type $A (struct )) - ;; NOMNL-TNH: (type $A (struct )) + ;; TNH: (rec + ;; TNH-NEXT: (type $A (struct )) (type $A (struct_subtype data)) ;; CHECK: (type $B (struct_subtype (field (ref null $A)) $A)) - ;; NOMNL: (type $B (struct_subtype (field (ref null $A)) $A)) - ;; NOMNL-TNH: (type $B (struct_subtype (field (ref null $A)) $A)) + ;; TNH: (type $B (struct_subtype (field (ref null $A)) $A)) (type $B (struct_subtype (field (ref null $A)) $A)) ;; CHECK: (type $C (struct_subtype (field (ref null $D)) $B)) - ;; NOMNL: (type $C (struct_subtype (field (ref null $D)) $B)) - ;; NOMNL-TNH: (type $C (struct_subtype (field (ref null $D)) $B)) + ;; TNH: (type $C (struct_subtype (field (ref null $D)) $B)) (type $C (struct_subtype (field (ref null $D)) $B)) ;; CHECK: (type $D (struct_subtype $A)) - ;; NOMNL: (type $D (struct_subtype $A)) - ;; NOMNL-TNH: (type $D (struct_subtype $A)) + ;; TNH: (type $D (struct_subtype $A)) (type $D (struct_subtype $A)) ) @@ -277,16 +220,11 @@ ;; CHECK-NEXT: (local.get $C) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $test (type $ref|$C|_=>_anyref) (param $C (ref $C)) (result anyref) - ;; NOMNL-NEXT: (struct.get $C 0 - ;; NOMNL-NEXT: (local.get $C) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-TNH: (func $test (type $ref|$C|_=>_anyref) (param $C (ref $C)) (result anyref) - ;; NOMNL-TNH-NEXT: (struct.get $C 0 - ;; NOMNL-TNH-NEXT: (local.get $C) - ;; NOMNL-TNH-NEXT: ) - ;; NOMNL-TNH-NEXT: ) + ;; TNH: (func $test (type $ref|$C|_=>_anyref) (param $C (ref $C)) (result anyref) + ;; TNH-NEXT: (struct.get $C 0 + ;; TNH-NEXT: (local.get $C) + ;; TNH-NEXT: ) + ;; 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 |