summaryrefslogtreecommitdiff
path: root/test/lit/passes/gufa-eh.wast
diff options
context:
space:
mode:
authorSébastien Doeraene <sjrdoeraene@gmail.com>2024-08-21 00:43:25 +0200
committerGitHub <noreply@github.com>2024-08-20 15:43:25 -0700
commit340ad71810484c279b1a36a9a7e458c9b18855b9 (patch)
tree4167b08dea6f5ffcdb975d90eb6f3c7925f628e0 /test/lit/passes/gufa-eh.wast
parent2c9c74d8b64e1776c6c374af8631995b0be606f1 (diff)
downloadbinaryen-340ad71810484c279b1a36a9a7e458c9b18855b9.tar.gz
binaryen-340ad71810484c279b1a36a9a7e458c9b18855b9.tar.bz2
binaryen-340ad71810484c279b1a36a9a7e458c9b18855b9.zip
[Exceptions] Finish interpreter + optimizer support for try_table. (#6814)
* Add interpreter support for exnref values. * Fix optimization passes to support try_table. * Enable the interpreter (but not in V8, see code) on exceptions.
Diffstat (limited to 'test/lit/passes/gufa-eh.wast')
-rw-r--r--test/lit/passes/gufa-eh.wast60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/lit/passes/gufa-eh.wast b/test/lit/passes/gufa-eh.wast
new file mode 100644
index 000000000..79265a318
--- /dev/null
+++ b/test/lit/passes/gufa-eh.wast
@@ -0,0 +1,60 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; RUN: foreach %s %t wasm-opt -all --gufa -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (type $0 (func (param i32)))
+
+ ;; CHECK: (type $1 (func (result i32)))
+
+ ;; CHECK: (type $2 (func))
+
+ ;; CHECK: (tag $e (param i32))
+ (tag $e (param i32))
+
+ ;; CHECK: (func $try_table-target-block-is-not-unreachable (type $1) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $catch (result i32)
+ ;; CHECK-NEXT: (try_table (catch $e $catch)
+ ;; CHECK-NEXT: (throw $e
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ (func $try_table-target-block-is-not-unreachable (result i32)
+ ;; Ensure that try_table connects caught tags with their branch targets.
+ (block $catch (result i32)
+ (try_table (catch $e $catch)
+ (throw $e (i32.const 0))
+ )
+ )
+ )
+
+ ;; CHECK: (func $try_table-materializes-exnref (type $2)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $catch (result exnref)
+ ;; CHECK-NEXT: (try_table (catch_all_ref $catch)
+ ;; CHECK-NEXT: (throw $e
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $try_table-materializes-exnref
+ ;; Ensure that catch_all_ref materializes a non-null exnref value. If we do
+ ;; not connect a non-null exnref value to the branch target, GUFA will think
+ ;; no value can possibly get out of that block, and will insert an
+ ;; unreachable instruction after the block.
+ (drop
+ (block $catch (result exnref)
+ (try_table (catch_all_ref $catch)
+ (throw $e (i32.const 0))
+ )
+ )
+ )
+ )
+)