summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-04-24 00:59:36 +0900
committerGitHub <noreply@github.com>2024-04-24 00:59:36 +0900
commit3b9dc42525553653d7477874e854584e957887b2 (patch)
treea53c1467e4f44eb0352afacbd8333c0baf03cde1 /test
parent4bbae113dc144f80ff4880c74c7068a9f7b14295 (diff)
downloadbinaryen-3b9dc42525553653d7477874e854584e957887b2.tar.gz
binaryen-3b9dc42525553653d7477874e854584e957887b2.tar.bz2
binaryen-3b9dc42525553653d7477874e854584e957887b2.zip
[EH] Fix missing outer block for catchless try (#6519)
When translating a `try` expression, we may need an 'outer' block that wraps the newly generated `try_table` so we can jump out of the expression when an exception does not occur. (The condition we use is when the `try` has any catches or if the `try` is a target of any inner `try-delegate`s: https://github.com/WebAssembly/binaryen/blob/219e668e87b012c0634043ed702534b8be31231f/src/passes/TranslateEH.cpp#L677) In case the `try` has either of `catch` or `delegate`, when we have the 'outer' block, we add the newly created `try_table` in the 'outer' block and replace the whole expression with the block: https://github.com/WebAssembly/binaryen/blob/219e668e87b012c0634043ed702534b8be31231f/src/passes/TranslateEH.cpp#L670 https://github.com/WebAssembly/binaryen/blob/219e668e87b012c0634043ed702534b8be31231f/src/passes/TranslateEH.cpp#L332-L340 But in case of a catchless `try`, we forgot to do that: https://github.com/WebAssembly/binaryen/blob/219e668e87b012c0634043ed702534b8be31231f/src/passes/TranslateEH.cpp#L388 So this PR fixes it.
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/translate-to-new-eh.wast41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/lit/passes/translate-to-new-eh.wast b/test/lit/passes/translate-to-new-eh.wast
index b1bbb4b98..ba3997951 100644
--- a/test/lit/passes/translate-to-new-eh.wast
+++ b/test/lit/passes/translate-to-new-eh.wast
@@ -2170,4 +2170,45 @@
(unreachable)
)
)
+
+ ;; CHECK: (func $try-delegate-within-catchless-try (type $1)
+ ;; CHECK-NEXT: (block $outer1
+ ;; CHECK-NEXT: (try_table
+ ;; CHECK-NEXT: (throw_ref
+ ;; CHECK-NEXT: (block $l00 (result exnref)
+ ;; CHECK-NEXT: (try_table (catch_all_ref $l00)
+ ;; CHECK-NEXT: (call $foo)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (br $outer1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; STACKIR-OPT: (func $try-delegate-within-catchless-try (type $1)
+ ;; STACKIR-OPT-NEXT: block $outer1
+ ;; STACKIR-OPT-NEXT: try_table
+ ;; STACKIR-OPT-NEXT: block $l00 (result exnref)
+ ;; STACKIR-OPT-NEXT: try_table (catch_all_ref $l00)
+ ;; STACKIR-OPT-NEXT: call $foo
+ ;; STACKIR-OPT-NEXT: end
+ ;; STACKIR-OPT-NEXT: br $outer1
+ ;; STACKIR-OPT-NEXT: end
+ ;; STACKIR-OPT-NEXT: throw_ref
+ ;; STACKIR-OPT-NEXT: end
+ ;; STACKIR-OPT-NEXT: unreachable
+ ;; STACKIR-OPT-NEXT: end
+ ;; STACKIR-OPT-NEXT: )
+ (func $try-delegate-within-catchless-try
+ (try $l0
+ (do
+ (try
+ (do
+ (call $foo)
+ )
+ (delegate $l0)
+ )
+ )
+ )
+ )
)