diff options
author | Thomas Lively <tlively@google.com> | 2023-11-16 19:56:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 10:56:25 -0800 |
commit | 5241d8796c2cf42dca45ebf53d5aea00d8a555d8 (patch) | |
tree | 204bdf8cba3c9c926b0447b07152aca2d6c72cfa /test | |
parent | 0e37557d779147375655c0bb46838709ba459091 (diff) | |
download | binaryen-5241d8796c2cf42dca45ebf53d5aea00d8a555d8.tar.gz binaryen-5241d8796c2cf42dca45ebf53d5aea00d8a555d8.tar.bz2 binaryen-5241d8796c2cf42dca45ebf53d5aea00d8a555d8.zip |
Update IRBuilder to visit control flow correctly (#6124)
Besides If, no control flow structure consumes values from the stack. Fix a
bug in IRBuilder that was causing it to pop control flow children. Also fix a
follow on bug in outlining where it did not make the If condition available on
the stack when starting to visit an If. This required making push() part of
the public API of IRBuilder.
As a drive-by, also add helpful debug logging to IRBuilder.
Co-authored-by: Ashley Nelson <nashley@google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/outlining.wast | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/lit/passes/outlining.wast b/test/lit/passes/outlining.wast index ffd5eb081..a080162ca 100644 --- a/test/lit/passes/outlining.wast +++ b/test/lit/passes/outlining.wast @@ -243,3 +243,54 @@ ) ) ) + + +;; Tests that outlining works correctly with If control flow +(module + ;; CHECK: (type $0 (func (param i32))) + + ;; CHECK: (type $1 (func)) + + ;; CHECK: (func $outline$ + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + + ;; CHECK: (func $a (param $0 i32) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a (param i32) + (if + (i32.eqz + (local.get 0) + ) + (drop + (i32.const 10) + ) + ) + ) + ;; CHECK: (func $b (param $0 i32) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $outline$) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $b (param i32) + (if + (i32.eqz + (local.get 0) + ) + (drop + (i32.const 10) + ) + ) + ) +) |