diff options
author | Heejin Ahn <aheejin@gmail.com> | 2024-05-28 10:32:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 10:32:02 -0700 |
commit | 13f3fd2bb76a41f146382ebf7303869c1088c73e (patch) | |
tree | 8895e95a07eddeddf13598de22b6cb94bf0696aa /test/lit/binary/stacky-eh-legacy.test | |
parent | f9ce00bd1f2457f5d2779d122199251978c7f851 (diff) | |
download | binaryen-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/binary/stacky-eh-legacy.test')
-rw-r--r-- | test/lit/binary/stacky-eh-legacy.test | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/lit/binary/stacky-eh-legacy.test b/test/lit/binary/stacky-eh-legacy.test new file mode 100644 index 000000000..c22a5165d --- /dev/null +++ b/test/lit/binary/stacky-eh-legacy.test @@ -0,0 +1,66 @@ +;; Verify stacky EH binary can be parsed correctly. +;; +;; stacky-eh-old.test.wasm contains below: +;; try +;; nop +;; catch 0 # tag type i32 +;; i32.const 3 +;; local.set 1 +;; local.set 2 +;; +;; (This binary was generated by +;; 'wasm-opt --optimize-level=3 --generate-stack-ir -optimize-stack-ir') +;; +;; This code is 'stacky' in Binaryen parlance. In the binary reader, Binaryen has +;; a special routine of creating a block and a local.get/local.set to read stacky +;; code into Binaryen AST. So if we don't do any post-fixup, the 'catch' block +;; becomes: +;; (catch $e-i32 +;; (local.set 2 +;; (block (result i32) +;; (local.set $new +;; (pop i32) +;; ) +;; (local.set 1 +;; (i32.const 3) +;; ) +;; (local.get $new) +;; ) +;; ) +;; ) +;; Here the 'block' and `local $new' are newly created to read the stacky code. +;; But now the 'pop' ends up nested within the 'block', which is invalid. This +;; test tests if this invalid code is correctly fixed up in the binary reader. +;; The fixup will hoist the 'pop' and create another local to store it right +;; after 'catch'. + +RUN: wasm-opt -all %s.wasm --print | filecheck %s + +;; CHECK: (func $0 +;; CHECK-NEXT: (local $0 i32) +;; CHECK-NEXT: (local $1 i32) +;; CHECK-NEXT: (local $2 i32) +;; CHECK-NEXT: (local $3 i32) +;; CHECK-NEXT: (local $4 i32) +;; CHECK-NEXT: (try $label$3 +;; CHECK-NEXT: (do +;; CHECK-NEXT: (nop) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (catch $tag$0 +;; CHECK-NEXT: (local.set $4 +;; CHECK-NEXT: (pop i32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (local.set $2 +;; CHECK-NEXT: (block (result i32) +;; CHECK-NEXT: (local.set $3 +;; CHECK-NEXT: (local.get $4) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (local.set $1 +;; CHECK-NEXT: (i32.const 3) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (local.get $3) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) |