summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-09-10 19:13:19 -0700
committerGitHub <noreply@github.com>2024-09-10 19:13:19 -0700
commit432ed1ccc62aea8c04ac0d2f89a25acedde6c948 (patch)
tree48d44eb852666db791bd5c74a14578d3d0ab2772 /test
parent1a2d26f4092897f88f8fc60fc7a4dee2083ae531 (diff)
downloadbinaryen-432ed1ccc62aea8c04ac0d2f89a25acedde6c948.tar.gz
binaryen-432ed1ccc62aea8c04ac0d2f89a25acedde6c948.tar.bz2
binaryen-432ed1ccc62aea8c04ac0d2f89a25acedde6c948.zip
[EH] Fix pop enclosed within a block in DCE (#6922)
#6400 fixed this case but that handled only when a `pop` is an immediate child of the current expression, but a `pop` can be nested deeper down. We conservatively run the EH fixup whenever we have a `pop` and create `block`s in the optimization. We considered using `FindAll<Pop>` to make it precise, but we decided the quadratic time plexity was not worth it. Fixes #6918.
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/dce-eh-legacy.wast72
1 files changed, 69 insertions, 3 deletions
diff --git a/test/lit/passes/dce-eh-legacy.wast b/test/lit/passes/dce-eh-legacy.wast
index ef6d569d6..107c35609 100644
--- a/test/lit/passes/dce-eh-legacy.wast
+++ b/test/lit/passes/dce-eh-legacy.wast
@@ -1,14 +1,28 @@
-;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-opt %s --dce -all -S -o - | filecheck %s
;; If either try body or catch body is reachable, the whole try construct is
;; reachable
(module
+ ;; CHECK: (type $0 (func))
+
+ ;; CHECK: (type $1 (func (param i32)))
+
+ ;; CHECK: (type $2 (func (param eqref)))
+
+ ;; CHECK: (type $3 (func (param i32 i32)))
+
+ ;; CHECK: (type $4 (func (result i32)))
+
+ ;; CHECK: (type $struct (struct (field (mut eqref))))
+ (type $struct (struct (field (mut (ref null eq)))))
+
;; CHECK: (tag $e)
(tag $e)
-
;; CHECK: (tag $e-i32 (param i32))
(tag $e-i32 (param i32))
+ ;; CHECK: (tag $e-eqref (param eqref))
+ (tag $e-eqref (param (ref null eq)))
;; CHECK: (func $foo (type $0)
;; CHECK-NEXT: (nop)
@@ -149,11 +163,63 @@
)
)
- ;; CHECK: (func $helper-i32-i32 (type $2) (param $0 i32) (param $1 i32)
+ ;; CHECK: (func $helper-i32-i32 (type $3) (param $0 i32) (param $1 i32)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
(func $helper-i32-i32 (param $0 i32) (param $1 i32)
(nop)
)
+
+ ;; CHECK: (func $pop-within-block (type $4) (result i32)
+ ;; CHECK-NEXT: (local $0 eqref)
+ ;; CHECK-NEXT: (try (result i32)
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (catch $e-eqref
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (pop eqref)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (struct.new $struct
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $pop-within-block (result i32)
+ (try (result i32)
+ (do
+ (i32.const 0)
+ )
+ (catch $e-eqref
+ (drop
+ ;; Optimization moves the 'pop' inside a block, which needs to be
+ ;; extracted out of the block at the end.
+ ;; (block
+ ;; (drop
+ ;; (struct.new $struct.0
+ ;; (pop eqref)
+ ;; )
+ ;; )
+ ;; (unreachable)
+ ;; )
+ (ref.eq
+ (struct.new $struct
+ (pop (ref null eq))
+ )
+ (unreachable)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ )
)