summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/help/wasm-opt.test5
-rw-r--r--test/lit/help/wasm2js.test5
-rw-r--r--test/lit/passes/type-finalizing.wast96
3 files changed, 106 insertions, 0 deletions
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 563a885f0..77974d4b2 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -478,6 +478,8 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --tuple-optimization optimize trivial tuples away
;; CHECK-NEXT:
+;; CHECK-NEXT: --type-finalizing mark all leaf types as final
+;; CHECK-NEXT:
;; CHECK-NEXT: --type-merging merge types to their supertypes
;; CHECK-NEXT: where possible
;; CHECK-NEXT:
@@ -487,6 +489,9 @@
;; CHECK-NEXT: --type-ssa create new nominal types to help
;; CHECK-NEXT: other optimizations
;; CHECK-NEXT:
+;; CHECK-NEXT: --type-unfinalizing mark all types as non-final
+;; CHECK-NEXT: (open)
+;; CHECK-NEXT:
;; CHECK-NEXT: --untee removes local.tees, replacing
;; CHECK-NEXT: them with sets and gets
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index 54a593b75..b896730a3 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -437,6 +437,8 @@
;; CHECK-NEXT:
;; CHECK-NEXT: --tuple-optimization optimize trivial tuples away
;; CHECK-NEXT:
+;; CHECK-NEXT: --type-finalizing mark all leaf types as final
+;; CHECK-NEXT:
;; CHECK-NEXT: --type-merging merge types to their supertypes
;; CHECK-NEXT: where possible
;; CHECK-NEXT:
@@ -446,6 +448,9 @@
;; CHECK-NEXT: --type-ssa create new nominal types to help
;; CHECK-NEXT: other optimizations
;; CHECK-NEXT:
+;; CHECK-NEXT: --type-unfinalizing mark all types as non-final
+;; CHECK-NEXT: (open)
+;; CHECK-NEXT:
;; CHECK-NEXT: --untee removes local.tees, replacing
;; CHECK-NEXT: them with sets and gets
;; CHECK-NEXT:
diff --git a/test/lit/passes/type-finalizing.wast b/test/lit/passes/type-finalizing.wast
new file mode 100644
index 000000000..d8265fe04
--- /dev/null
+++ b/test/lit/passes/type-finalizing.wast
@@ -0,0 +1,96 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; RUN: foreach %s %t wasm-opt -all --type-unfinalizing -S -o - | filecheck %s --check-prefix UNFINAL
+;; RUN: foreach %s %t wasm-opt -all --type-finalizing -S -o - | filecheck %s --check-prefix DOFINAL
+
+;; The public types should never be modified. The private ones should become
+;; final or not depending on what we do.
+(module
+ ;; Types.
+
+ ;; UNFINAL: (type $open-public (sub (struct (field i32))))
+ ;; DOFINAL: (type $open-public (sub (struct (field i32))))
+ (type $open-public (sub (struct (field i32))))
+
+ ;; UNFINAL: (type $final-public (struct (field i64)))
+ ;; DOFINAL: (type $final-public (struct (field i64)))
+ (type $final-public (sub final (struct (field i64))))
+
+ ;; UNFINAL: (rec
+ ;; UNFINAL-NEXT: (type $final-private (sub (struct (field f64))))
+ ;; DOFINAL: (rec
+ ;; DOFINAL-NEXT: (type $final-private (struct (field f64)))
+ (type $final-private (sub final (struct (field f64))))
+
+ ;; UNFINAL: (type $open-private (sub (struct (field f32))))
+ ;; DOFINAL: (type $open-private (struct (field f32)))
+ (type $open-private (sub (struct (field f32))))
+
+ ;; Globals.
+
+ ;; UNFINAL: (global $open-public (ref null $open-public) (ref.null none))
+ ;; DOFINAL: (global $open-public (ref null $open-public) (ref.null none))
+ (global $open-public (ref null $open-public) (ref.null $open-public))
+
+ ;; UNFINAL: (global $final-public (ref null $final-public) (ref.null none))
+ ;; DOFINAL: (global $final-public (ref null $final-public) (ref.null none))
+ (global $final-public (ref null $final-public) (ref.null $final-public))
+
+ ;; UNFINAL: (global $open-private (ref null $open-private) (ref.null none))
+ ;; DOFINAL: (global $open-private (ref null $open-private) (ref.null none))
+ (global $open-private (ref null $open-private) (ref.null $open-private))
+
+ ;; UNFINAL: (global $final-private (ref null $final-private) (ref.null none))
+ ;; DOFINAL: (global $final-private (ref null $final-private) (ref.null none))
+ (global $final-private (ref null $final-private) (ref.null $final-private))
+
+ ;; Exports.
+
+ ;; UNFINAL: (export "a" (global $open-public))
+ ;; DOFINAL: (export "a" (global $open-public))
+ (export "a" (global $open-public))
+ ;; UNFINAL: (export "b" (global $final-public))
+ ;; DOFINAL: (export "b" (global $final-public))
+ (export "b" (global $final-public))
+)
+
+;; Test we do not make a type with a subtype final. $parent should always
+;; remain open, while the children can be modified.
+(module
+ (rec
+ ;; UNFINAL: (rec
+ ;; UNFINAL-NEXT: (type $parent (sub (struct )))
+ ;; DOFINAL: (rec
+ ;; DOFINAL-NEXT: (type $parent (sub (struct )))
+ (type $parent (sub (struct)))
+
+ ;; UNFINAL: (type $child-open (sub $parent (struct )))
+ ;; DOFINAL: (type $child-open (sub final $parent (struct )))
+ (type $child-open (sub $parent (struct)))
+
+ ;; UNFINAL: (type $child-final (sub $parent (struct )))
+ ;; DOFINAL: (type $child-final (sub final $parent (struct )))
+ (type $child-final (sub final $parent (struct)))
+ )
+
+ ;; UNFINAL: (type $3 (sub (func)))
+
+ ;; UNFINAL: (func $keepalive (type $3)
+ ;; UNFINAL-NEXT: (local $parent (ref $parent))
+ ;; UNFINAL-NEXT: (local $child-final (ref $child-final))
+ ;; UNFINAL-NEXT: (local $child-open (ref $child-open))
+ ;; UNFINAL-NEXT: (nop)
+ ;; UNFINAL-NEXT: )
+ ;; DOFINAL: (type $3 (func))
+
+ ;; DOFINAL: (func $keepalive (type $3)
+ ;; DOFINAL-NEXT: (local $parent (ref $parent))
+ ;; DOFINAL-NEXT: (local $child-final (ref $child-final))
+ ;; DOFINAL-NEXT: (local $child-open (ref $child-open))
+ ;; DOFINAL-NEXT: (nop)
+ ;; DOFINAL-NEXT: )
+ (func $keepalive
+ (local $parent (ref $parent))
+ (local $child-final (ref $child-final))
+ (local $child-open (ref $child-open))
+ )
+)