diff options
author | Heejin Ahn <aheejin@gmail.com> | 2020-05-13 17:10:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 17:10:59 -0700 |
commit | 5db77a72a7c62d045e6650e96974fe1455fa1a1a (patch) | |
tree | d4b32705b0c6090d6763063025fc503ba650c8cf /test | |
parent | 5930ada5bee7061d8063f2638cdb1cb25dce5292 (diff) | |
download | binaryen-5db77a72a7c62d045e6650e96974fe1455fa1a1a.tar.gz binaryen-5db77a72a7c62d045e6650e96974fe1455fa1a1a.tar.bz2 binaryen-5db77a72a7c62d045e6650e96974fe1455fa1a1a.zip |
Add EH support in MergeBlocks (#2848)
This adds support for `throw`, `rethrow`, and `br_on_exn` in
MergeBlocks. While unrelated instructions within blocks can be hoisted
as in other instructions, `br_on_exn` requires a special handling in
`ProblemFinder`, because unlike `br_if`, its `exnref` argument itself
cannot be moved out of `br_on_exn`.
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/remove-unused-names_merge-blocks_all-features.txt (renamed from test/passes/remove-unused-names_merge-blocks_enable-threads.txt) | 47 | ||||
-rw-r--r-- | test/passes/remove-unused-names_merge-blocks_all-features.wast (renamed from test/passes/remove-unused-names_merge-blocks_enable-threads.wast) | 57 |
2 files changed, 104 insertions, 0 deletions
diff --git a/test/passes/remove-unused-names_merge-blocks_enable-threads.txt b/test/passes/remove-unused-names_merge-blocks_all-features.txt index cf37ebc9d..90a56d32d 100644 --- a/test/passes/remove-unused-names_merge-blocks_enable-threads.txt +++ b/test/passes/remove-unused-names_merge-blocks_all-features.txt @@ -1697,3 +1697,50 @@ ) ) ) +(module + (type $none_=>_none (func)) + (type $i32_=>_none (func (param i32))) + (type $none_=>_i32 (func (result i32))) + (event $e (attr 0) (param i32)) + (func $foo + (nop) + ) + (func $throw + (nop) + (throw $e + (i32.const 3) + ) + ) + (func $rethrow + (local $0 exnref) + (call $foo) + (rethrow + (local.get $0) + ) + ) + (func $br_on_exn (result i32) + (local $0 exnref) + (block $label$0 (result i32) + (call $foo) + (drop + (br_on_exn $label$0 $e + (local.get $0) + ) + ) + (i32.const 3) + ) + ) + (func $cannot_extract_br_on_exn_exnref + (local $0 exnref) + (drop + (block $label$0 (result i32) + (drop + (br_on_exn $label$0 $e + (local.get $0) + ) + ) + (i32.const 5) + ) + ) + ) +) diff --git a/test/passes/remove-unused-names_merge-blocks_enable-threads.wast b/test/passes/remove-unused-names_merge-blocks_all-features.wast index f9603a60d..9a6840650 100644 --- a/test/passes/remove-unused-names_merge-blocks_enable-threads.wast +++ b/test/passes/remove-unused-names_merge-blocks_all-features.wast @@ -1556,3 +1556,60 @@ ) ) ) + +(module + (event $e (attr 0) (param i32)) + (func $foo) + + ;; 'nop' within 'block' of `throw' can be hoisted + (func $throw + (throw $e + (block (result i32) + (nop) + (i32.const 3) + ) + ) + ) + + ;; 'call $foo' within 'block' of `rethrow' can be hoisted + (func $rethrow (local $0 exnref) + (rethrow + (block (result exnref) + (call $foo) + (local.get $0) + ) + ) + ) + + ;; 'call $foo' within 'block' of `br_on_exn' can be hoisted + (func $br_on_exn (result i32) (local $0 exnref) + (block $label$0 (result i32) + (drop + (br_on_exn $label$0 $e + (block (result exnref) + (call $foo) + (local.get $0) + ) + ) + ) + (i32.const 3) + ) + ) + + ;; Unlike br_if, br_on_exn's exnref argument itself cannot be extracted. + ;; Without proper handling for br_on_exn in ProblemFinder, this crashes. + (func $cannot_extract_br_on_exn_exnref (local $0 exnref) + (block + (drop + (block $label$0 (result i32) + (drop + (br_on_exn $label$0 $e + (local.get $0) + ) + ) + (i32.const 5) + ) + ) + ) + ) +) |