summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/coalesce-locals-gc-nn.wast84
-rw-r--r--test/lit/passes/rse-gc.wast11
2 files changed, 91 insertions, 4 deletions
diff --git a/test/lit/passes/coalesce-locals-gc-nn.wast b/test/lit/passes/coalesce-locals-gc-nn.wast
new file mode 100644
index 000000000..21b6d2a33
--- /dev/null
+++ b/test/lit/passes/coalesce-locals-gc-nn.wast
@@ -0,0 +1,84 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --coalesce-locals -all --enable-gc-nn-locals -S -o - \
+;; RUN: | filecheck %s
+
+(module
+ ;; CHECK: (func $nn-locals (param $0 (ref any))
+ ;; CHECK-NEXT: (local $1 ((ref any) (ref any)))
+ ;; CHECK-NEXT: (local $2 ((ref any) (ref any)))
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (tuple.make
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $2
+ ;; CHECK-NEXT: (tuple.make
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $nn-locals
+ ;; CHECK-NEXT: (tuple.extract 0
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $nn-locals
+ ;; CHECK-NEXT: (tuple.extract 0
+ ;; CHECK-NEXT: (local.get $2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $nn-locals
+ ;; CHECK-NEXT: (tuple.extract 1
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $nn-locals
+ ;; CHECK-NEXT: (tuple.extract 1
+ ;; CHECK-NEXT: (local.get $2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $nn-locals (param $any (ref any))
+ ;; When computing interferences, coalesce locals should not error on tuples
+ ;; that contain non-nullable locals.
+ (local $x ((ref any) (ref any)))
+ (local $y ((ref any) (ref any)))
+ ;; Set values into the tuple locals and use them.
+ ;; Note that while the values are the same, we do not optimize them because
+ ;; of current limitations on tuple handling in this pass, so we are mainly
+ ;; testing for not crashing here.
+ (local.set $x
+ (tuple.make
+ (local.get $any)
+ (local.get $any)
+ )
+ )
+ (local.set $y
+ (tuple.make
+ (local.get $any)
+ (local.get $any)
+ )
+ )
+ (call $nn-locals
+ (tuple.extract 0
+ (local.get $x)
+ )
+ )
+ (call $nn-locals
+ (tuple.extract 0
+ (local.get $y)
+ )
+ )
+ (call $nn-locals
+ (tuple.extract 1
+ (local.get $x)
+ )
+ )
+ (call $nn-locals
+ (tuple.extract 1
+ (local.get $y)
+ )
+ )
+ )
+)
diff --git a/test/lit/passes/rse-gc.wast b/test/lit/passes/rse-gc.wast
index 7bea92260..ddb4aaf87 100644
--- a/test/lit/passes/rse-gc.wast
+++ b/test/lit/passes/rse-gc.wast
@@ -2,14 +2,17 @@
;; RUN: wasm-opt %s --rse --enable-gc-nn-locals -all -S -o - | filecheck %s
(module
- ;; CHECK: (func $10
- ;; CHECK-NEXT: (local $1 (ref func))
+ ;; CHECK: (func $test
+ ;; CHECK-NEXT: (local $single (ref func))
+ ;; CHECK-NEXT: (local $tuple ((ref any) (ref any)))
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
- (func $10
+ (func $test
;; A non-nullable local. The pass should ignore it (as we cannot optimize
;; anything here anyhow: the code must assign to the local before reading from
;; it, so no sets can be redundant in that sense).
- (local $1 (ref func))
+ (local $single (ref func))
+ ;; A non-nullable tuple.
+ (local $tuple ((ref any) (ref any)))
)
)