diff options
author | Ashley Nelson <nashley@google.com> | 2024-02-27 17:09:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-27 17:09:30 -0800 |
commit | 1ef95ae7b9e2c765abbbc6af6dff6c29c1fa4d13 (patch) | |
tree | 06a51c0fc5d395260a728362373e346bdbf5cc25 /test/lit | |
parent | c62a0c97168e88f97bca4bd96298a5ffc041844d (diff) | |
download | binaryen-1ef95ae7b9e2c765abbbc6af6dff6c29c1fa4d13.tar.gz binaryen-1ef95ae7b9e2c765abbbc6af6dff6c29c1fa4d13.tar.bz2 binaryen-1ef95ae7b9e2c765abbbc6af6dff6c29c1fa4d13.zip |
[Outlining] Fixes break reconstruction (#6352)
Adds new visitBreakWithType and visitSwitchWithType functions to the IRBuilder API. These functions work around an assumption in IRBuilder that the module is being traversed in the fully nested format, i.e., that the destination scope of a break or switch has been visited before visiting the break or switch. Instead, the type of the destination scope is passed to IRBuilder.
Diffstat (limited to 'test/lit')
-rw-r--r-- | test/lit/passes/outlining.wast | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/test/lit/passes/outlining.wast b/test/lit/passes/outlining.wast index befce7513..76f305db7 100644 --- a/test/lit/passes/outlining.wast +++ b/test/lit/passes/outlining.wast @@ -614,6 +614,106 @@ ) ) +;; Tests branch with condition is reconstructed without error. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (func $outline$ (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + + ;; CHECK: (func $a (type $0) + ;; CHECK-NEXT: (block $label1 + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: (loop $loop-in + ;; CHECK-NEXT: (br $label1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a + (block $label1 + (drop + (i32.const 2) + ) + (drop + (i32.const 1) + ) + (loop + (br $label1) + ) + (drop + (i32.const 2) + ) + (drop + (i32.const 1) + ) + ) + ) +) + +;; Tests br_table instruction is reconstructed without error. +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (type $1 (func (param i32) (result i32))) + + ;; CHECK: (func $outline$ (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + + ;; CHECK: (func $a (type $1) (param $0 i32) (result i32) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: (block $block + ;; CHECK-NEXT: (block $block0 + ;; CHECK-NEXT: (br_table $block $block0 + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (i32.const 21) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (return + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: (i32.const 22) + ;; CHECK-NEXT: ) + (func $a (param i32) (result i32) + (drop + (i32.const 2) + ) + (drop + (i32.const 1) + ) + (block + (block + (br_table 1 0 (local.get $0)) + (return (i32.const 21)) + ) + (return (i32.const 20)) + ) + (drop + (i32.const 2) + ) + (drop + (i32.const 1) + ) + (i32.const 22) + ) +) + ;; Tests return instructions are correctly filtered from being outlined. (module ;; CHECK: (type $0 (func (result i32))) |