summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/help/wasm-opt.test2
-rw-r--r--test/lit/help/wasm2js.test2
-rw-r--r--test/lit/passes/remove-unused-types.wast39
-rw-r--r--test/lit/passes/signature-refining_gto.wat8
4 files changed, 50 insertions, 1 deletions
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 22e3baaf1..042807e2f 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -365,6 +365,8 @@
;; CHECK-NEXT: --remove-unused-nonfunction-module-elements removes unused module elements
;; CHECK-NEXT: that are not functions
;; CHECK-NEXT:
+;; CHECK-NEXT: --remove-unused-types remove unused private GC types
+;; CHECK-NEXT:
;; CHECK-NEXT: --reorder-functions sorts functions by access
;; CHECK-NEXT: frequency
;; CHECK-NEXT:
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index b901c253c..ab56ff4e8 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -324,6 +324,8 @@
;; CHECK-NEXT: --remove-unused-nonfunction-module-elements removes unused module elements
;; CHECK-NEXT: that are not functions
;; CHECK-NEXT:
+;; CHECK-NEXT: --remove-unused-types remove unused private GC types
+;; CHECK-NEXT:
;; CHECK-NEXT: --reorder-functions sorts functions by access
;; CHECK-NEXT: frequency
;; CHECK-NEXT:
diff --git a/test/lit/passes/remove-unused-types.wast b/test/lit/passes/remove-unused-types.wast
new file mode 100644
index 000000000..5dcf889e4
--- /dev/null
+++ b/test/lit/passes/remove-unused-types.wast
@@ -0,0 +1,39 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; RUN: wasm-opt %s --remove-unused-types -all -S -o - | filecheck %s
+
+(module
+ (rec
+ ;; CHECK: (rec
+ ;; CHECK-NEXT: (type $mutually-used-2 (struct (field (ref null $mutually-used-1))))
+
+ ;; CHECK: (type $indirectly-used (struct ))
+
+ ;; CHECK: (type $mutually-used-1 (struct (field (ref null $mutually-used-2))))
+
+ ;; CHECK: (type $directly-used (struct (field (ref null $indirectly-used))))
+
+ ;; CHECK: (type $used (struct ))
+ (type $used (struct))
+ (type $unused (struct))
+ )
+ (rec
+ (type $indirectly-used (struct))
+ (type $directly-used (struct (ref null $indirectly-used)))
+ (type $unused2 (struct (ref null $unused2)))
+ (type $unused3 (struct (ref null $unused2)))
+ )
+ (rec
+ (type $mutually-used-1 (struct (ref null $mutually-used-2)))
+ (type $mutually-used-2 (struct (ref null $mutually-used-1)))
+ (type $mutually-unused-1 (struct (ref null $mutually-unused-2)))
+ (type $mutually-unused-2 (struct (ref null $mutually-unused-1)))
+ )
+
+ ;; CHECK: (global $g1 (ref null $used) (ref.null none))
+ (global $g1 (ref null $used) (ref.null none))
+ ;; CHECK: (global $g2 (ref null $directly-used) (ref.null none))
+ (global $g2 (ref null $directly-used) (ref.null none))
+ ;; CHECK: (global $g4 (ref null $mutually-used-1) (ref.null none))
+ (global $g4 (ref null $mutually-used-1) (ref.null none))
+)
diff --git a/test/lit/passes/signature-refining_gto.wat b/test/lit/passes/signature-refining_gto.wat
index 5ce8aa576..2a6f768c8 100644
--- a/test/lit/passes/signature-refining_gto.wat
+++ b/test/lit/passes/signature-refining_gto.wat
@@ -1,8 +1,14 @@
-;; RUN: foreach %s %t wasm-opt --nominal --signature-refining --gto --roundtrip -all -S -o - | filecheck %s
+;; RUN: foreach %s %t wasm-opt --nominal --signature-refining --gto --roundtrip -all -S -o - | filecheck %s
+;; RUN: foreach %s %t wasm-opt --signature-refining --gto --remove-unused-types --roundtrip -all -S -o - | filecheck %s --check-prefix ISOREC
+
+;; Check that type $A is not included in the final binary after the signature
+;; refining optimization. For isorecursive types, this requires an additional
+;; --remove-unused-types pass after signature refining.
(module
;; The type $A should not be emitted at all (see below).
;; CHECK-NOT: (type $A
+ ;; ISOREC-NOT: (type $A
(type $A (struct (field (mut (ref null $A)))))
;; CHECK: (type $ref|none|_=>_none (func (param (ref none))))