diff options
author | Ben Smith <binjimin@gmail.com> | 2018-12-18 09:27:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 09:27:18 -0800 |
commit | 3ac02b6d3cc5bc3ff6cfe57df312b2677ca83d75 (patch) | |
tree | 6a470c926a25457fadab32cffc8373b255b73cbd /test/roundtrip | |
parent | 32ee1f63cf9489d47896dfc2e7d294fdfee13d3d (diff) | |
download | wabt-3ac02b6d3cc5bc3ff6cfe57df312b2677ca83d75.tar.gz wabt-3ac02b6d3cc5bc3ff6cfe57df312b2677ca83d75.tar.bz2 wabt-3ac02b6d3cc5bc3ff6cfe57df312b2677ca83d75.zip |
Fold multi-value results properly (#984)
Expressions need to be treated specially when folding an expression
with a result count > 1. Since the expression cannot be split, we can
only include it as a child of another expression if all of its values
are used, for example:
```
(func $dup (result i32 i32) ...)
(call $dup) ;; produces two values
(i32.add) ;; consumes two values
```
Diffstat (limited to 'test/roundtrip')
-rw-r--r-- | test/roundtrip/fold-multi.txt | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/roundtrip/fold-multi.txt b/test/roundtrip/fold-multi.txt new file mode 100644 index 00000000..55a6a49f --- /dev/null +++ b/test/roundtrip/fold-multi.txt @@ -0,0 +1,50 @@ +;;; TOOL: run-roundtrip +;;; ARGS: --stdout --fold-exprs --enable-multi-value +(module + (func $dup (result i32 i32) + i32.const 0 + i32.const 1 + ) + + (func $fold-two (result i32) + call $dup + i32.add + ) + + (func $cant-fold (result i32) + call $dup + i32.const 1 + i32.add + drop + ) + + (func $partial-fold (result i32) + call $dup + call $dup + i32.add + i32.sub + drop + ) +) +(;; STDOUT ;;; +(module + (type (;0;) (func (result i32 i32))) + (type (;1;) (func (result i32))) + (func (;0;) (type 0) (result i32 i32) + (i32.const 0) + (i32.const 1)) + (func (;1;) (type 1) (result i32) + (i32.add + (call 0))) + (func (;2;) (type 1) (result i32) + (call 0) + (i32.const 1) + (i32.add) + (drop)) + (func (;3;) (type 1) (result i32) + (call 0) + (i32.add + (call 0)) + (i32.sub) + (drop))) +;;; STDOUT ;;) |