summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-04-04 17:21:29 -0700
committerGitHub <noreply@github.com>2022-04-05 00:21:29 +0000
commit18c969e74f14670e52cc9f74c4e76ff197af3f36 (patch)
tree38a300bd08225fd7333ad3f45c8f965f4ac1f918 /test
parent0315a5bb3d73ce6c9fe550b3661ec5e78e423520 (diff)
downloadbinaryen-18c969e74f14670e52cc9f74c4e76ff197af3f36.tar.gz
binaryen-18c969e74f14670e52cc9f74c4e76ff197af3f36.tar.bz2
binaryen-18c969e74f14670e52cc9f74c4e76ff197af3f36.zip
[Wasm GC] Fix unreachable local.gets of non-nullable locals in CoalesceLocals (#4574)
Normally we just replace unreachable local.gets with a constant (0, or null), but if the local is non-nullable we can't do that. Fixes #4573
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/coalesce-locals-gc-nn.wast23
-rw-r--r--test/lit/passes/coalesce-locals-gc.wast4
2 files changed, 26 insertions, 1 deletions
diff --git a/test/lit/passes/coalesce-locals-gc-nn.wast b/test/lit/passes/coalesce-locals-gc-nn.wast
index 21b6d2a33..69e96ac62 100644
--- a/test/lit/passes/coalesce-locals-gc-nn.wast
+++ b/test/lit/passes/coalesce-locals-gc-nn.wast
@@ -81,4 +81,27 @@
)
)
)
+
+ ;; CHECK: (func $unreachable-get-of-non-nullable
+ ;; CHECK-NEXT: (local $0 (ref any))
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block (result (ref any))
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $unreachable-get-of-non-nullable
+ ;; One local is unused entirely, the other is used but only in unreachable
+ ;; code. It does not really matter what we do here (coalesce, or not), but we
+ ;; should emit valid IR. Normally we would apply a constant to replace the
+ ;; local.get, however, the types here are non-nullable, so we must do
+ ;; something else.
+ (local $unused (ref any))
+ (local $used-in-unreachable (ref any))
+ (unreachable)
+ (drop
+ (local.get $used-in-unreachable)
+ )
+ )
)
diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast
index 2c0fc3f03..52243ebc8 100644
--- a/test/lit/passes/coalesce-locals-gc.wast
+++ b/test/lit/passes/coalesce-locals-gc.wast
@@ -11,7 +11,9 @@
;; CHECK: (func $test-dead-get-non-nullable (param $0 dataref)
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: (block (result dataref)
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test-dead-get-non-nullable (param $func (ref data))