summaryrefslogtreecommitdiff
path: root/test/lit/passes/coalesce-locals-gc.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-04-16 10:09:17 -0700
committerGitHub <noreply@github.com>2024-04-16 10:09:17 -0700
commite29d77848b89846cf3519491fee581b507e3b194 (patch)
treee4fa41f2c63638ba30aeb6f7ec84703bd0555a0e /test/lit/passes/coalesce-locals-gc.wast
parente4608772910d4d879b0a4783bacba3b4890b828c (diff)
downloadbinaryen-e29d77848b89846cf3519491fee581b507e3b194.tar.gz
binaryen-e29d77848b89846cf3519491fee581b507e3b194.tar.bz2
binaryen-e29d77848b89846cf3519491fee581b507e3b194.zip
CoalesceLocals: ReFinalize when we refine a type (#6502)
The code had a different workaround, namely to add a block with an explicit type to avoid changing the type at all (i.e. the block declared the original type of the thing we replaced, not the refined type). But by adding a block we can end up with an invalid pop, as the fuzzer found, see the EH testcase here. To fix this, use the usual workaround of just running ReFinalize. That is simpler and also improves the code while we do it. It does add more work, but this is likely a very rare situation anyhow.
Diffstat (limited to 'test/lit/passes/coalesce-locals-gc.wast')
-rw-r--r--test/lit/passes/coalesce-locals-gc.wast21
1 files changed, 8 insertions, 13 deletions
diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast
index b485f90d0..0fc83d74e 100644
--- a/test/lit/passes/coalesce-locals-gc.wast
+++ b/test/lit/passes/coalesce-locals-gc.wast
@@ -181,19 +181,16 @@
)
;; CHECK: (func $remove-tee-refinalize (type $5) (param $0 (ref null $A)) (param $1 (ref null $B)) (result structref)
- ;; CHECK-NEXT: (struct.get $A 0
- ;; CHECK-NEXT: (block (result (ref null $A))
- ;; CHECK-NEXT: (local.get $1)
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (struct.get $B 0
+ ;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $remove-tee-refinalize
(param $a (ref null $A))
(param $b (ref null $B))
(result (ref null struct))
- ;; The local.tee receives a $B and flows out an $A. We want to avoid changing
- ;; types here, so we'll wrap it in a block, and leave further improvements
- ;; for other passes.
+ ;; The local.tee receives a $B and flows out an $A. We will ReFinalize here as
+ ;; we remove the tee, making the struct.get operate on $B.
(struct.get $A 0
(local.tee $a
(local.get $b)
@@ -202,10 +199,8 @@
)
;; CHECK: (func $remove-tee-refinalize-2 (type $5) (param $0 (ref null $A)) (param $1 (ref null $B)) (result structref)
- ;; CHECK-NEXT: (struct.get $A 0
- ;; CHECK-NEXT: (block (result (ref null $A))
- ;; CHECK-NEXT: (local.get $1)
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (struct.get $B 0
+ ;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $remove-tee-refinalize-2
@@ -311,9 +306,9 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (global.set $nn-tuple-global
- ;; CHECK-NEXT: (block (type $1) (result (ref any) i32)
+ ;; CHECK-NEXT: (block (type $0) (result (ref any) i32)
;; CHECK-NEXT: (local.set $1
- ;; CHECK-NEXT: (if (type $1) (result (ref any) i32)
+ ;; CHECK-NEXT: (if (type $0) (result (ref any) i32)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (then
;; CHECK-NEXT: (tuple.make 2