summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/abstract-type-refining.wast52
-rw-r--r--test/lit/passes/gto-mutability.wast36
2 files changed, 88 insertions, 0 deletions
diff --git a/test/lit/passes/abstract-type-refining.wast b/test/lit/passes/abstract-type-refining.wast
index 814f5c1f0..e887894ea 100644
--- a/test/lit/passes/abstract-type-refining.wast
+++ b/test/lit/passes/abstract-type-refining.wast
@@ -1304,3 +1304,55 @@
)
)
)
+
+;; $A is never created, but $B is, so all appearances of $A, like in the cast
+;; and the struct field, could be replaced by $B, except that $A is a public type,
+;; so might be created outside the module.
+(module
+ (rec
+ ;; YESTNH: (rec
+ ;; YESTNH-NEXT: (type $A (sub (struct (field (ref null $A)))))
+ ;; NO_TNH: (rec
+ ;; NO_TNH-NEXT: (type $A (sub (struct (field (ref null $A)))))
+ (type $A (sub (struct (field (ref null $A)))))
+
+ ;; YESTNH: (type $B (sub $A (struct (field (ref null $A)))))
+ ;; NO_TNH: (type $B (sub $A (struct (field (ref null $A)))))
+ (type $B (sub $A (struct (field (ref null $A)))))
+ )
+
+ ;; YESTNH: (type $2 (func (param anyref)))
+
+ ;; YESTNH: (global $global (ref $B) (struct.new_default $B))
+ ;; NO_TNH: (type $2 (func (param anyref)))
+
+ ;; NO_TNH: (global $global (ref $B) (struct.new_default $B))
+ (global $global (ref $B) (struct.new_default $B))
+
+ ;; YESTNH: (export "global" (global $global))
+ ;; NO_TNH: (export "global" (global $global))
+ (export "global" (global $global))
+
+ ;; YESTNH: (func $new (type $2) (param $x anyref)
+ ;; YESTNH-NEXT: (drop
+ ;; YESTNH-NEXT: (ref.cast (ref $A)
+ ;; YESTNH-NEXT: (local.get $x)
+ ;; YESTNH-NEXT: )
+ ;; YESTNH-NEXT: )
+ ;; YESTNH-NEXT: )
+ ;; NO_TNH: (func $new (type $2) (param $x anyref)
+ ;; NO_TNH-NEXT: (drop
+ ;; NO_TNH-NEXT: (ref.cast (ref $A)
+ ;; NO_TNH-NEXT: (local.get $x)
+ ;; NO_TNH-NEXT: )
+ ;; NO_TNH-NEXT: )
+ ;; NO_TNH-NEXT: )
+ (func $new (param $x anyref)
+ (drop
+ (ref.cast (ref $A)
+ (local.get $x)
+ )
+ )
+ )
+)
+
diff --git a/test/lit/passes/gto-mutability.wast b/test/lit/passes/gto-mutability.wast
index 13b416b1b..3b01572c8 100644
--- a/test/lit/passes/gto-mutability.wast
+++ b/test/lit/passes/gto-mutability.wast
@@ -652,3 +652,39 @@
)
)
)
+
+;; The parent is public, which prevents us from making any field immutable in
+;; the child.
+(module
+ ;; CHECK: (type $parent (sub (struct (field (mut i32)))))
+ (type $parent (sub (struct (field (mut i32)))))
+ ;; CHECK: (type $1 (func))
+
+ ;; CHECK: (type $child (sub $parent (struct (field (mut i32)))))
+ (type $child (sub $parent (struct (field (mut i32)))))
+
+ ;; CHECK: (global $global (ref $parent) (struct.new $parent
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: ))
+ (global $global (ref $parent) (struct.new $parent
+ (i32.const 0)
+ ))
+
+ ;; Make the parent public by exporting the global.
+ ;; CHECK: (export "global" (global $global))
+ (export "global" (global $global))
+
+ ;; CHECK: (func $func (type $1)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (struct.new_default $child)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $func
+ ;; Create the child so the type is used. No sets to the fields exist, so
+ ;; in theory all fields could be immutable.
+ (drop
+ (struct.new_default $child)
+ )
+ )
+)
+