summaryrefslogtreecommitdiff
path: root/test/lit/passes/inlining-eh-legacy.wast
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-05-28 10:32:02 -0700
committerGitHub <noreply@github.com>2024-05-28 10:32:02 -0700
commit13f3fd2bb76a41f146382ebf7303869c1088c73e (patch)
tree8895e95a07eddeddf13598de22b6cb94bf0696aa /test/lit/passes/inlining-eh-legacy.wast
parentf9ce00bd1f2457f5d2779d122199251978c7f851 (diff)
downloadbinaryen-13f3fd2bb76a41f146382ebf7303869c1088c73e.tar.gz
binaryen-13f3fd2bb76a41f146382ebf7303869c1088c73e.tar.bz2
binaryen-13f3fd2bb76a41f146382ebf7303869c1088c73e.zip
[EH] Rename old EH tests from -old to -legacy (#6627)
This renames old EH tests in the form of `-eh-old.wast` to `-eh-legacy.wast`, to be clearer in names.
Diffstat (limited to 'test/lit/passes/inlining-eh-legacy.wast')
-rw-r--r--test/lit/passes/inlining-eh-legacy.wast146
1 files changed, 146 insertions, 0 deletions
diff --git a/test/lit/passes/inlining-eh-legacy.wast b/test/lit/passes/inlining-eh-legacy.wast
new file mode 100644
index 000000000..b6e3caec2
--- /dev/null
+++ b/test/lit/passes/inlining-eh-legacy.wast
@@ -0,0 +1,146 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --inlining -all -S -o - | filecheck %s
+
+(module
+ ;; ---------------------------------------------------------------------------
+ ;; CHECK: (import "a" "b" (func $foo (type $2) (result i32)))
+ (import "a" "b" (func $foo (result i32)))
+ ;; CHECK: (tag $tag$0 (param i32))
+ (tag $tag$0 (param i32))
+ (func $callee-with-label
+ (try $label
+ (do)
+ (catch $tag$0
+ (drop
+ (pop i32)
+ )
+ )
+ )
+ )
+
+ ;; Properly ensure unique try labels after an inlining
+
+ ;; CHECK: (func $caller-with-label (type $1) (param $x i32)
+ ;; CHECK-NEXT: (loop $label
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (block $__inlined_func$callee-with-label
+ ;; CHECK-NEXT: (try $label0
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (catch $tag$0
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (pop i32)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (br_if $label
+ ;; CHECK-NEXT: (call $foo)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $caller-with-label (param $x i32)
+ (loop $label ;; The same label as the try that will be inlined into here
+ (call $callee-with-label)
+ (br_if $label
+ (call $foo)
+ )
+ )
+ )
+
+ ;; ---------------------------------------------------------------------------
+ ;; CHECK: (func $callee-with-try-delegate (type $0)
+ ;; CHECK-NEXT: (try $label$3
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (delegate 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $callee-with-try-delegate
+ (try $label$3
+ (do)
+ (delegate 0)
+ )
+ )
+
+ ;; For now, do not inline a try-delegate
+
+ ;; CHECK: (func $caller (type $0)
+ ;; CHECK-NEXT: (call $callee-with-try-delegate)
+ ;; CHECK-NEXT: )
+ (func $caller
+ (call $callee-with-try-delegate)
+ )
+
+ ;; ---------------------------------------------------------------------------
+ (func $callee-a (result i32)
+ (i32.const 42)
+ )
+
+ ;; Properly support inlining into a function with a try-delegate
+
+ ;; CHECK: (func $caller-with-try-delegate (type $2) (result i32)
+ ;; CHECK-NEXT: (try $label$3
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (delegate 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (block $__inlined_func$callee-a$1 (result i32)
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $caller-with-try-delegate (result i32)
+ (try $label$3
+ (do)
+ (delegate 0)
+ )
+ (call $callee-a)
+ )
+
+
+ ;; ---------------------------------------------------------------------------
+ (func $callee-b (param i32))
+
+ ;; CHECK: (func $caller-with-pop (type $0)
+ ;; CHECK-NEXT: (local $0 i32)
+ ;; CHECK-NEXT: (local $1 i32)
+ ;; CHECK-NEXT: (try
+ ;; CHECK-NEXT: (do
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (catch $tag$0
+ ;; CHECK-NEXT: (local.set $1
+ ;; CHECK-NEXT: (pop i32)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block
+ ;; CHECK-NEXT: (block $__inlined_func$callee-b$2
+ ;; CHECK-NEXT: (local.set $0
+ ;; CHECK-NEXT: (local.get $1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $caller-with-pop
+ (try
+ (do)
+ (catch $tag$0
+ ;; After this $callee-b is inlined, there will be additional 'block's
+ ;; surrouding this 'pop', which makes its location invalid. We fix it by
+ ;; creating a new local to set the result of 'pop' and later use
+ ;; local.get to get the value within the inlined function body.
+ (call $callee-b
+ (pop i32)
+ )
+ )
+ )
+ )
+)