summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-03-22 11:12:49 -0700
committerGitHub <noreply@github.com>2024-03-22 11:12:49 -0700
commit57dc0c975dbb82c96826f29559136c703afce3e2 (patch)
treed81f52d34b2e090b6185bcb3ca7b62540a2d51f4 /test
parentf5147a14e7a7c447bfbc38d05dff19a5231697c0 (diff)
downloadbinaryen-57dc0c975dbb82c96826f29559136c703afce3e2.tar.gz
binaryen-57dc0c975dbb82c96826f29559136c703afce3e2.tar.bz2
binaryen-57dc0c975dbb82c96826f29559136c703afce3e2.zip
CodeFolding: Fix up old EH when we fold away an If (#6420)
The pass does (among other things) this: (if condition X X ) => (block (drop condition ) X ;; deduplicated ) After that the condition is now nested in a block, so we may need EH fixups if it contains a pop.
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/code-folding-eh-old.wast58
1 files changed, 57 insertions, 1 deletions
diff --git a/test/lit/passes/code-folding-eh-old.wast b/test/lit/passes/code-folding-eh-old.wast
index e83559c2b..836df867c 100644
--- a/test/lit/passes/code-folding-eh-old.wast
+++ b/test/lit/passes/code-folding-eh-old.wast
@@ -72,7 +72,7 @@
;; CHECK-NEXT: )
(func $foo)
- ;; CHECK: (func $try-call-optimize-terminating-tails (type $2) (result i32)
+ ;; CHECK: (func $try-call-optimize-terminating-tails (type $1) (result i32)
;; CHECK-NEXT: (try
;; CHECK-NEXT: (do
;; CHECK-NEXT: (call $foo)
@@ -155,4 +155,60 @@
(unreachable)
)
)
+
+ ;; CHECK: (func $if-arms-in-catch (type $1) (result i32)
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (try
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (catch $e-i32
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (pop i32)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (local.get $0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.eqz
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $if-arms-in-catch (result i32)
+ (try
+ (do
+ (unreachable)
+ )
+ (catch $e-i32
+ ;; These if arms can be folded, after which the if is replaced by a
+ ;; block, so we need a fixup for the pop.
+ (if
+ (pop i32)
+ (then
+ (drop
+ (i32.eqz
+ (i32.const 1)
+ )
+ )
+ )
+ (else
+ (drop
+ (i32.eqz
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (unreachable)
+ )
+ )
+ )
)