diff options
author | Alon Zakai <azakai@google.com> | 2024-10-03 09:06:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-03 09:06:46 -0700 |
commit | 36181c881c67f2b11386fdf885dbe33567db0d67 (patch) | |
tree | d72adfff75bfcd4c74371eb54a488a5e22bcf9db /test | |
parent | ce1a13c06aca0690b296f34401011b5a0bc07636 (diff) | |
download | binaryen-36181c881c67f2b11386fdf885dbe33567db0d67.tar.gz binaryen-36181c881c67f2b11386fdf885dbe33567db0d67.tar.bz2 binaryen-36181c881c67f2b11386fdf885dbe33567db0d67.zip |
[NFC] Refactor out the dropped-block optimization code in MergeBlocks (#6982)
This just moves the code out into a function. A later PR will use it in another place.
Add a test that shows the motivation for that later PR: we fail to optimize away
a block return value at the top level of a function. Fixing that will involve calling
the new function here from another place.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/merge-blocks.wast | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/test/lit/passes/merge-blocks.wast b/test/lit/passes/merge-blocks.wast index 66b0e8b71..e1ac88dd8 100644 --- a/test/lit/passes/merge-blocks.wast +++ b/test/lit/passes/merge-blocks.wast @@ -15,7 +15,7 @@ (type $array (array (mut i32))) - ;; CHECK: (func $br_on_to_drop (type $5) + ;; CHECK: (func $br_on_to_drop (type $4) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $label$1 (result i31ref) @@ -43,7 +43,7 @@ ) ) - ;; CHECK: (func $struct.set (type $4) (param $struct (ref null $struct)) + ;; CHECK: (func $struct.set (type $5) (param $struct (ref null $struct)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.const 1234) @@ -68,7 +68,7 @@ ) ) - ;; CHECK: (func $struct.get (type $4) (param $struct (ref null $struct)) + ;; CHECK: (func $struct.get (type $5) (param $struct (ref null $struct)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (i32.const 1234) @@ -404,6 +404,27 @@ ) ) + ;; CHECK: (func $toplevel (type $4) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block $label (result i32) + ;; CHECK-NEXT: (br $label + ;; CHECK-NEXT: (i32.const 42) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $toplevel + ;; Test we can remove a block value even when the drop is at the toplevel of + ;; a function. This is not done yet TODO + (drop + (block $label (result i32) + (br $label + (i32.const 42) + ) + ) + ) + ) + ;; CHECK: (func $helper (type $7) (param $x i32) (result i32) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) |