summaryrefslogtreecommitdiff
path: root/test/lit/passes/remove-unused-brs-eh.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-10-08 11:41:24 -0700
committerGitHub <noreply@github.com>2024-10-08 11:41:24 -0700
commit930034ff1637f611a05582ac28fb734d6503b12e (patch)
tree6c09f7f37cd2be3105e10e9a6359fc41f6fa7e1b /test/lit/passes/remove-unused-brs-eh.wast
parent1eb01260efdcb65828c81cf5f72fb358b03d2328 (diff)
downloadbinaryen-930034ff1637f611a05582ac28fb734d6503b12e.tar.gz
binaryen-930034ff1637f611a05582ac28fb734d6503b12e.tar.bz2
binaryen-930034ff1637f611a05582ac28fb734d6503b12e.zip
Fix flow reset during throw => break opts in RemoveUnusedBrs (#6993)
#6980 was missing the logic to reset flows after replacing a throw. The process of replacing the throw introduces new code and in particular a drop, which blocks branches from flowing to their targets. In the testcase here, the br was turned into nop before this fix.
Diffstat (limited to 'test/lit/passes/remove-unused-brs-eh.wast')
-rw-r--r--test/lit/passes/remove-unused-brs-eh.wast40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/lit/passes/remove-unused-brs-eh.wast b/test/lit/passes/remove-unused-brs-eh.wast
index b3b89df63..bb4278f86 100644
--- a/test/lit/passes/remove-unused-brs-eh.wast
+++ b/test/lit/passes/remove-unused-brs-eh.wast
@@ -412,4 +412,44 @@
)
)
)
+
+ ;; CHECK: (func $no-flow-through-throw (type $4)
+ ;; CHECK-NEXT: (block $label
+ ;; CHECK-NEXT: (try_table (catch_all $label)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (if (result i32)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (then
+ ;; CHECK-NEXT: (br $label)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (else
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (br $label)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $no-flow-through-throw
+ ;; The throw here can turn into a break. While doing so, we must clear all
+ ;; the currently-flowing things, namely the br in the if arm. If we do not
+ ;; do so then it will try to flow out through the drop that we add for the
+ ;; throw's value, which is impossible.
+ (block $label
+ (try_table (catch_all $label)
+ (throw $e
+ (if (result i32)
+ (i32.const 0)
+ (then
+ (br $label)
+ )
+ (else
+ (i32.const 42)
+ )
+ )
+ )
+ )
+ )
+ )
)