summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/gufa-refs.wast24
-rw-r--r--test/lit/passes/optimize-instructions-gc-tnh.wast29
-rw-r--r--test/lit/passes/optimize-instructions-gc.wast50
3 files changed, 20 insertions, 83 deletions
diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast
index f209cef88..2b221dfd8 100644
--- a/test/lit/passes/gufa-refs.wast
+++ b/test/lit/passes/gufa-refs.wast
@@ -981,7 +981,8 @@
;; CHECK: (type $none_=>_none (func))
- ;; CHECK: (elem declare func $func)
+ ;; CHECK: (type $unrelated (struct ))
+ (type $unrelated (struct))
;; CHECK: (func $func (type $none_=>_none)
;; CHECK-NEXT: (local $child (ref null $child))
@@ -1034,13 +1035,8 @@
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block $parent (result (ref $parent))
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (block (result (ref $none_=>_none))
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (br_on_cast $parent $parent
- ;; CHECK-NEXT: (ref.func $func)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (ref.func $func)
+ ;; CHECK-NEXT: (br_on_cast $parent $parent
+ ;; CHECK-NEXT: (struct.new_default $unrelated)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
@@ -1087,14 +1083,14 @@
(local.get $parent)
)
)
- ;; A ref.func is cast to a struct type, and then we read from that. The cast
- ;; will trap at runtime, of course; for here, we should not error and also
- ;; we can optimize these to unreachables. atm we filter out trapping
- ;; contents in ref.cast, but not br_on_cast, so test both.
+ ;; An unrelated type is cast to a struct type, and then we read from that.
+ ;; The cast will trap at runtime, of course; for here, we should not error
+ ;; and also we can optimize these to unreachables. atm we filter out
+ ;; trapping contents in ref.cast, but not br_on_cast, so test both.
(drop
(struct.get $parent 0
(ref.cast null $parent
- (ref.func $func)
+ (struct.new $unrelated)
)
)
)
@@ -1103,7 +1099,7 @@
(block $parent (result (ref $parent))
(drop
(br_on_cast $parent $parent
- (ref.func $func)
+ (struct.new $unrelated)
)
)
(unreachable)
diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast
index 2d3e25b9b..741cd3921 100644
--- a/test/lit/passes/optimize-instructions-gc-tnh.wast
+++ b/test/lit/passes/optimize-instructions-gc-tnh.wast
@@ -48,43 +48,34 @@
)
)
- ;; TNH: (func $ref.eq-no (type $eqref_eqref_=>_none) (param $a eqref) (param $b eqref)
+ ;; TNH: (func $ref.eq-no (type $eqref_eqref_anyref_=>_none) (param $a eqref) (param $b eqref) (param $any anyref)
;; TNH-NEXT: (drop
;; TNH-NEXT: (i32.const 1)
;; TNH-NEXT: )
;; TNH-NEXT: )
- ;; NO_TNH: (func $ref.eq-no (type $eqref_eqref_=>_none) (param $a eqref) (param $b eqref)
+ ;; 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: (block (result (ref $struct))
- ;; NO_TNH-NEXT: (drop
- ;; NO_TNH-NEXT: (ref.func $ref.eq-no)
- ;; NO_TNH-NEXT: )
- ;; NO_TNH-NEXT: (unreachable)
+ ;; NO_TNH-NEXT: (ref.cast null $struct
+ ;; NO_TNH-NEXT: (local.get $any)
;; NO_TNH-NEXT: )
- ;; NO_TNH-NEXT: (block (result (ref data))
- ;; NO_TNH-NEXT: (drop
- ;; NO_TNH-NEXT: (ref.func $ref.eq-no)
- ;; NO_TNH-NEXT: )
- ;; NO_TNH-NEXT: (unreachable)
+ ;; NO_TNH-NEXT: (ref.as_data
+ ;; NO_TNH-NEXT: (local.get $any)
;; NO_TNH-NEXT: )
;; NO_TNH-NEXT: )
;; NO_TNH-NEXT: )
;; NO_TNH-NEXT: )
- (func $ref.eq-no (param $a (ref null eq)) (param $b (ref null eq))
- ;; We must leave the inputs to ref.eq of type eqref or a subtype. Note that
- ;; these casts will trap, so other opts might get in the way before we can
- ;; do anything. The crucial thing we test here is that we do not emit
- ;; something that does not validate (as ref.eq inputs must be eqrefs).
+ (func $ref.eq-no (param $a (ref null eq)) (param $b (ref null eq)) (param $any anyref)
+ ;; We must leave the inputs to ref.eq of type eqref or a subtype.
(drop
(ref.eq
(ref.cast null $struct
- (ref.func $ref.eq-no) ;; *Not* an eqref!
+ (local.get $any) ;; *Not* an eqref!
)
(ref.as_non_null
(ref.as_data
(ref.as_non_null
- (ref.func $ref.eq-no) ;; *Not* an eqref!
+ (local.get $any) ;; *Not* an eqref!
)
)
)
diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast
index 61b558868..d0ab6f859 100644
--- a/test/lit/passes/optimize-instructions-gc.wast
+++ b/test/lit/passes/optimize-instructions-gc.wast
@@ -1000,13 +1000,6 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.cast null $struct
- ;; CHECK-NEXT: (ref.as_func
- ;; CHECK-NEXT: (local.get $x)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (ref.cast null $struct
;; CHECK-NEXT: (ref.as_i31
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: )
@@ -1030,13 +1023,6 @@
;; NOMNL-NEXT: )
;; NOMNL-NEXT: (drop
;; NOMNL-NEXT: (ref.cast null $struct
- ;; NOMNL-NEXT: (ref.as_func
- ;; NOMNL-NEXT: (local.get $x)
- ;; NOMNL-NEXT: )
- ;; NOMNL-NEXT: )
- ;; NOMNL-NEXT: )
- ;; NOMNL-NEXT: (drop
- ;; NOMNL-NEXT: (ref.cast null $struct
;; NOMNL-NEXT: (ref.as_i31
;; NOMNL-NEXT: (local.get $x)
;; NOMNL-NEXT: )
@@ -1066,13 +1052,6 @@
;; other ref.as* operations are ignored for now
(drop
(ref.cast null $struct
- (ref.as_func
- (local.get $x)
- )
- )
- )
- (drop
- (ref.cast null $struct
(ref.as_i31
(local.get $x)
)
@@ -2130,35 +2109,6 @@
)
)
- ;; CHECK: (func $ref-cast-static-impossible (type $ref|func|_=>_none) (param $func (ref func))
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (block (result (ref $struct))
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $func)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (unreachable)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; NOMNL: (func $ref-cast-static-impossible (type $ref|func|_=>_none) (param $func (ref func))
- ;; NOMNL-NEXT: (drop
- ;; NOMNL-NEXT: (block (result (ref $struct))
- ;; NOMNL-NEXT: (drop
- ;; NOMNL-NEXT: (local.get $func)
- ;; NOMNL-NEXT: )
- ;; NOMNL-NEXT: (unreachable)
- ;; NOMNL-NEXT: )
- ;; NOMNL-NEXT: )
- ;; NOMNL-NEXT: )
- (func $ref-cast-static-impossible (param $func (ref func))
- ;; A func cannot be cast to a struct, so this will trap.
- (drop
- (ref.cast null $struct
- (local.get $func)
- )
- )
- )
-
;; CHECK: (func $ref-cast-static-general (type $ref?|$A|_ref?|$B|_=>_none) (param $a (ref null $A)) (param $b (ref null $B))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $a)