diff options
author | Alon Zakai <alonzakai@gmail.com> | 2019-04-16 10:00:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-16 10:00:19 -0700 |
commit | 324238cc44e51c65637d29a938c435248d384154 (patch) | |
tree | fcd7a35442c720385ff5746a3de83a7123e04be8 /test | |
parent | cb2d63586c08a3dd194d2b733ceb3f5051c081f8 (diff) | |
download | binaryen-324238cc44e51c65637d29a938c435248d384154.tar.gz binaryen-324238cc44e51c65637d29a938c435248d384154.tar.bz2 binaryen-324238cc44e51c65637d29a938c435248d384154.zip |
Verify flat IR where it is expected, and give a nice error (#2009)
Fixes #2007 #2008
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/1.passes | 2 | ||||
-rw-r--r-- | test/passes/1.txt | 4 | ||||
-rw-r--r-- | test/passes/flatten_i64-to-i32-lowering.txt | 81 | ||||
-rw-r--r-- | test/passes/flatten_i64-to-i32-lowering.wast (renamed from test/passes/i64-to-i32-lowering.wast) | 0 | ||||
-rw-r--r-- | test/passes/flatten_local-cse.txt | 79 | ||||
-rw-r--r-- | test/passes/flatten_local-cse.wast | 30 | ||||
-rw-r--r-- | test/passes/flatten_rereloop.txt | 789 | ||||
-rw-r--r-- | test/passes/flatten_rereloop.wast | 604 | ||||
-rw-r--r-- | test/passes/i64-to-i32-lowering.txt | 62 | ||||
-rw-r--r-- | test/passes/local-cse.txt | 37 | ||||
-rw-r--r-- | test/passes/local-cse.wast | 29 | ||||
-rw-r--r-- | test/passes/rereloop.txt | 575 | ||||
-rw-r--r-- | test/passes/rereloop.wast | 221 |
13 files changed, 1585 insertions, 928 deletions
diff --git a/test/passes/1.passes b/test/passes/1.passes index 275436f40..86b9bf7e3 100644 --- a/test/passes/1.passes +++ b/test/passes/1.passes @@ -1 +1 @@ -rereloop_dce_remove-unused-brs_remove-unused-names_coalesce-locals_simplify-locals_reorder-locals_remove-unused-brs_merge-blocks_vacuum +flatten_rereloop_dce_remove-unused-brs_remove-unused-names_coalesce-locals_simplify-locals_reorder-locals_remove-unused-brs_merge-blocks_vacuum diff --git a/test/passes/1.txt b/test/passes/1.txt index edc8ff9a2..08aa9f611 100644 --- a/test/passes/1.txt +++ b/test/passes/1.txt @@ -185,9 +185,9 @@ (call $switch (i32.const 1) ) - (block $block$6$break + (block $block$7$break (block $switch$3$default - (br_table $block$6$break $block$6$break $block$6$break $switch$3$default + (br_table $block$7$break $block$7$break $block$7$break $switch$3$default (local.get $0) ) ) diff --git a/test/passes/flatten_i64-to-i32-lowering.txt b/test/passes/flatten_i64-to-i32-lowering.txt new file mode 100644 index 000000000..3c3535e53 --- /dev/null +++ b/test/passes/flatten_i64-to-i32-lowering.txt @@ -0,0 +1,81 @@ +(module + (type $FUNCSIG$j (func (result i32))) + (import "env" "func" (func $import (result i32))) + (global $i64toi32_i32$HIGH_BITS (mut i32) (i32.const 0)) + (func $defined (; 1 ;) (type $FUNCSIG$j) (result i32) + (local $0 i32) + (local $0$hi i32) + (local $i64toi32_i32$0 i32) + (local $i64toi32_i32$1 i32) + (local $i64toi32_i32$2 i32) + (local $i64toi32_i32$3 i32) + (local $i64toi32_i32$4 i32) + (local $i64toi32_i32$5 i32) + (block + (local.set $0 + (block (result i32) + (local.set $i64toi32_i32$2 + (block (result i32) + (local.set $i64toi32_i32$0 + (i32.const 0) + ) + (i32.const 1) + ) + ) + (local.set $i64toi32_i32$3 + (block (result i32) + (local.set $i64toi32_i32$1 + (i32.const 0) + ) + (i32.const 2) + ) + ) + (local.set $i64toi32_i32$4 + (i32.add + (local.get $i64toi32_i32$2) + (local.get $i64toi32_i32$3) + ) + ) + (local.set $i64toi32_i32$5 + (i32.add + (local.get $i64toi32_i32$0) + (local.get $i64toi32_i32$1) + ) + ) + (if + (i32.lt_u + (local.get $i64toi32_i32$4) + (local.get $i64toi32_i32$3) + ) + (local.set $i64toi32_i32$5 + (i32.add + (local.get $i64toi32_i32$5) + (i32.const 1) + ) + ) + ) + (local.get $i64toi32_i32$4) + ) + ) + (local.set $0$hi + (local.get $i64toi32_i32$5) + ) + ) + (block + (local.set $i64toi32_i32$2 + (block (result i32) + (local.set $i64toi32_i32$5 + (local.get $0$hi) + ) + (local.get $0) + ) + ) + (global.set $i64toi32_i32$HIGH_BITS + (local.get $i64toi32_i32$5) + ) + (return + (local.get $i64toi32_i32$2) + ) + ) + ) +) diff --git a/test/passes/i64-to-i32-lowering.wast b/test/passes/flatten_i64-to-i32-lowering.wast index 179cac467..179cac467 100644 --- a/test/passes/i64-to-i32-lowering.wast +++ b/test/passes/flatten_i64-to-i32-lowering.wast diff --git a/test/passes/flatten_local-cse.txt b/test/passes/flatten_local-cse.txt index e68b62782..dde07a89f 100644 --- a/test/passes/flatten_local-cse.txt +++ b/test/passes/flatten_local-cse.txt @@ -762,3 +762,82 @@ (nop) ) ) +(module + (type $0 (func (result i64))) + (type $1 (func)) + (global $glob (mut i32) (i32.const 1)) + (func $i64-shifts (; 0 ;) (type $0) (result i64) + (local $temp i64) + (local $1 i64) + (local $2 i64) + (local $3 i64) + (local $4 i64) + (local $5 i64) + (block + (local.set $1 + (i64.add + (i64.const 1) + (i64.const 2) + ) + ) + (local.set $temp + (local.get $1) + ) + (nop) + (local.set $temp + (i64.const 9999) + ) + (nop) + (local.set $2 + (local.get $1) + ) + (local.set $temp + (local.get $1) + ) + (nop) + (local.set $3 + (local.get $temp) + ) + (local.set $4 + (local.get $temp) + ) + ) + (local.set $5 + (local.get $temp) + ) + (return + (local.get $temp) + ) + ) + (func $global (; 1 ;) (type $1) + (local $x i32) + (local $y i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (block + (local.set $2 + (global.get $glob) + ) + (local.set $x + (local.get $2) + ) + (nop) + (local.set $3 + (local.get $x) + ) + (local.set $y + (local.get $x) + ) + (nop) + (local.set $4 + (local.get $x) + ) + (local.set $y + (local.get $x) + ) + (nop) + ) + (nop) + ) +) diff --git a/test/passes/flatten_local-cse.wast b/test/passes/flatten_local-cse.wast index 61ea1e129..b967e9177 100644 --- a/test/passes/flatten_local-cse.wast +++ b/test/passes/flatten_local-cse.wast @@ -258,4 +258,32 @@ ) ) ) - +(module + (global $glob (mut i32) (i32.const 1)) + (func $i64-shifts (result i64) + (local $temp i64) + (local.set $temp + (i64.add + (i64.const 1) + (i64.const 2) + ) + ) + (local.set $temp + (i64.const 9999) + ) + (local.set $temp + (i64.add + (i64.const 1) + (i64.const 2) + ) + ) + (local.get $temp) + ) + (func $global + (local $x i32) + (local $y i32) + (local.set $x (global.get $glob)) + (local.set $y (global.get $glob)) + (local.set $y (global.get $glob)) + ) +) diff --git a/test/passes/flatten_rereloop.txt b/test/passes/flatten_rereloop.txt index 162336420..de2b3bbea 100644 --- a/test/passes/flatten_rereloop.txt +++ b/test/passes/flatten_rereloop.txt @@ -391,3 +391,792 @@ ) ) ) +(module + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func (param i32))) + (func $trivial (; 0 ;) (type $0) + (local $0 i32) + (return) + ) + (func $trivial2 (; 1 ;) (type $0) + (local $0 i32) + (block + (block + (call $trivial) + (call $trivial) + ) + (return) + ) + ) + (func $return-void (; 2 ;) (type $0) + (local $0 i32) + (return) + ) + (func $return-val (; 3 ;) (type $1) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (return + (i32.const 1) + ) + ) + (func $ifs (; 4 ;) (type $2) (param $x i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (block + (local.set $6 + (local.get $x) + ) + (local.set $1 + (local.get $6) + ) + (local.set $7 + (local.get $1) + ) + ) + (if + (local.get $7) + (block + (block + (local.set $8 + (local.get $x) + ) + (local.set $2 + (local.get $8) + ) + (local.set $9 + (local.get $2) + ) + ) + (if + (local.get $9) + (block + (return + (i32.const 2) + ) + ) + (block + (return + (i32.const 3) + ) + ) + ) + ) + (block + (block + (local.set $10 + (local.get $x) + ) + (local.set $3 + (local.get $10) + ) + (local.set $11 + (local.get $3) + ) + ) + (if + (local.get $11) + (block + (return + (i32.const 4) + ) + ) + (block + (return + (i32.const 5) + ) + ) + ) + ) + ) + ) + (func $loops (; 5 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (block $block$21$break + (block + (local.set $4 + (local.get $x) + ) + (local.set $1 + (local.get $4) + ) + (local.set $5 + (local.get $1) + ) + ) + (if + (local.get $5) + (loop $shape$2$continue + (call $trivial) + (block + (br $shape$2$continue) + ) + ) + (br $block$21$break) + ) + ) + (block + (block $block$24$break + (loop $shape$4$continue + (block + (call $trivial) + (local.set $6 + (local.get $x) + ) + (local.set $2 + (local.get $6) + ) + (local.set $7 + (local.get $2) + ) + ) + (if + (local.get $7) + (br $shape$4$continue) + (br $block$24$break) + ) + ) + ) + (block + (block $block$2$break + (loop $shape$6$continue + (block + (call $trivial) + (local.set $8 + (local.get $x) + ) + (local.set $3 + (local.get $8) + ) + (local.set $9 + (local.get $3) + ) + ) + (if + (local.get $9) + (br $shape$6$continue) + (br $block$2$break) + ) + ) + ) + (block + (return) + ) + ) + ) + ) + (func $br-out (; 6 ;) (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (call $br-out + (i32.const 5) + ) + (block + (br $block$2$break) + ) + ) + (block + (return) + ) + ) + (func $unreachable (; 7 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (block $block$4$break + (block + (local.set $3 + (local.get $x) + ) + (local.set $1 + (local.get $3) + ) + (local.set $4 + (local.get $1) + ) + ) + (if + (local.get $4) + (br $block$4$break) + (block + (block $block$2$break + (call $unreachable + (i32.const 5) + ) + (block + (br $block$2$break) + ) + ) + (block + (return) + ) + ) + ) + ) + (block + (block + (local.set $5 + (local.get $x) + ) + (local.set $2 + (local.get $5) + ) + (local.set $6 + (local.get $2) + ) + ) + (if + (local.get $6) + (block + (block + (call $unreachable + (i32.const 1) + ) + (unreachable) + ) + ) + (block + (block + (call $unreachable + (i32.const 3) + ) + (return) + ) + ) + ) + ) + ) + (func $empty-blocks (; 8 ;) (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (block + ) + (block + (br $block$2$break) + ) + ) + (block + (return) + ) + ) + (func $before-and-after (; 9 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (block $block$4$break + (block + (block + (call $before-and-after + (i32.const 1) + ) + (call $before-and-after + (i32.const 2) + ) + ) + (block + (call $before-and-after + (i32.const 3) + ) + (call $before-and-after + (i32.const 4) + ) + (local.set $6 + (local.get $x) + ) + (local.set $1 + (local.get $6) + ) + (local.set $7 + (local.get $1) + ) + ) + ) + (if + (local.get $7) + (br $block$4$break) + (block + (call $before-and-after + (i32.const 5) + ) + (block + (br $block$4$break) + ) + ) + ) + ) + (block + (block $block$8$break + (block + (block + (call $before-and-after + (i32.const 6) + ) + (call $before-and-after + (i32.const 7) + ) + ) + (call $before-and-after + (i32.const 8) + ) + ) + (block + (br $block$8$break) + ) + ) + (block + (block $block$10$break + (loop $shape$4$continue + (block + (call $before-and-after + (i32.const 9) + ) + (local.set $8 + (local.get $x) + ) + (local.set $2 + (local.get $8) + ) + (local.set $9 + (local.get $2) + ) + ) + (if + (local.get $9) + (br $shape$4$continue) + (br $block$10$break) + ) + ) + ) + (block + (block $block$11$break + (block + (call $before-and-after + (i32.const 10) + ) + (block + (call $before-and-after + (i32.const 11) + ) + (local.set $10 + (local.get $x) + ) + (local.set $3 + (local.get $10) + ) + (local.set $11 + (local.get $3) + ) + ) + ) + (if + (local.get $11) + (block + (call $before-and-after + (i32.const 12) + ) + (block + (br $block$11$break) + ) + ) + (br $block$11$break) + ) + ) + (block + (block $block$15$break + (block + (call $before-and-after + (i32.const 13) + ) + (local.set $12 + (local.get $x) + ) + (local.set $4 + (local.get $12) + ) + (local.set $13 + (local.get $4) + ) + ) + (if + (local.get $13) + (block + (call $before-and-after + (i32.const 14) + ) + (block + (br $block$15$break) + ) + ) + (block + (call $before-and-after + (i32.const 15) + ) + (block + (br $block$15$break) + ) + ) + ) + ) + (block + (block $block$21$break + (block + (local.set $14 + (local.get $x) + ) + (local.set $5 + (local.get $14) + ) + (local.set $15 + (local.get $5) + ) + ) + (if + (local.get $15) + (block + (call $before-and-after + (i32.const 16) + ) + (block + (br $block$21$break) + ) + ) + (br $block$21$break) + ) + ) + (block + (block $block$28$break + (block + (block + (block + (call $before-and-after + (i32.const 17) + ) + (call $before-and-after + (i32.const 18) + ) + (call $before-and-after + (i32.const 19) + ) + ) + (call $before-and-after + (i32.const 20) + ) + ) + (block + (call $before-and-after + (i32.const 21) + ) + (call $before-and-after + (i32.const 22) + ) + ) + ) + (block + (br $block$28$break) + ) + ) + (block + (block $block$30$break + (block + (call $before-and-after + (i32.const 23) + ) + (call $before-and-after + (i32.const 24) + ) + ) + (block + (br $block$30$break) + ) + ) + (block + (block + (call $before-and-after + (i32.const 25) + ) + (return) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (func $switch (; 10 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (block $block$3$break + (block + (local.set $3 + (local.get $x) + ) + (local.set $1 + (local.get $3) + ) + (local.set $4 + (local.get $1) + ) + ) + (block + (br $block$3$break) + ) + ) + (block + (block $block$9$break + (block + (call $switch + (i32.const 1) + ) + (local.set $5 + (local.get $x) + ) + (local.set $2 + (local.get $5) + ) + (local.set $6 + (local.get $2) + ) + ) + (block $switch$3$leave + (block $switch$3$default + (block $switch$3$case$9 + (br_table $switch$3$case$9 $switch$3$case$9 $switch$3$case$9 $switch$3$default + (local.get $6) + ) + ) + (block + (br $block$9$break) + ) + ) + (block + (block + (call $switch + (i32.const 2) + ) + (block + (br $block$9$break) + ) + ) + ) + ) + ) + (block + (block + (call $switch + (i32.const 3) + ) + (return) + ) + ) + ) + ) + (func $no-return (; 11 ;) (type $0) + (local $0 i32) + (block $block$6$break + (block + ) + (if + (i32.const 1) + (block + (drop + (i32.const 2) + ) + (block + (br $block$6$break) + ) + ) + (block + (drop + (i32.const 3) + ) + (block + (br $block$6$break) + ) + ) + ) + ) + (block + (return) + ) + ) + (func $if-br-wat (; 12 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (block $block$3$break + (block $block$4$break + (block + (call $if-br-wat + (i32.const 0) + ) + (local.set $3 + (local.get $x) + ) + (local.set $1 + (local.get $3) + ) + (local.set $4 + (local.get $1) + ) + ) + (if + (local.get $4) + (block + (call $if-br-wat + (i32.const 1) + ) + (block + (br $block$4$break) + ) + ) + (block + (block + (local.set $5 + (local.get $x) + ) + (local.set $2 + (local.get $5) + ) + (local.set $6 + (local.get $2) + ) + ) + (if + (local.get $6) + (br $block$3$break) + (br $block$4$break) + ) + ) + ) + ) + (block + (call $if-br-wat + (i32.const 2) + ) + (block + (br $block$3$break) + ) + ) + ) + (block + (block + (call $if-br-wat + (i32.const 3) + ) + (return) + ) + ) + ) + (func $switcher-to-nowhere (; 13 ;) (type $2) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (block + (block + (local.set $4 + (local.get $0) + ) + (local.set $1 + (local.get $4) + ) + (local.set $5 + (local.get $1) + ) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$4 + (block $switch$1$case$5 + (br_table $switch$1$case$5 $switch$1$case$4 $switch$1$default + (local.get $5) + ) + ) + (block + (block + (return + (i32.const 1) + ) + ) + ) + ) + (block + (block + (return + (i32.const 2) + ) + ) + ) + ) + (block + (block + (return + (i32.const 3) + ) + ) + ) + ) + ) + (unreachable) + ) +) diff --git a/test/passes/flatten_rereloop.wast b/test/passes/flatten_rereloop.wast index 5ff0e9960..c6625805e 100644 --- a/test/passes/flatten_rereloop.wast +++ b/test/passes/flatten_rereloop.wast @@ -177,3 +177,607 @@ ) ) ;; manual TODO: merge branches, all the parts +(module + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func (param i32))) + (func $trivial (; 0 ;) (type $0) + (nop) + ) + (func $trivial2 (; 1 ;) (type $0) + (block + (call $trivial) + (nop) + (call $trivial) + (nop) + ) + (nop) + ) + (func $return-void (; 2 ;) (type $0) + (return) + (unreachable) + ) + (func $return-val (; 3 ;) (type $1) (result i32) + (return + (i32.const 1) + ) + (unreachable) + ) + (func $ifs (; 4 ;) (type $2) (param $x i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (block + (block + (local.set $1 + (local.get $x) + ) + (if + (local.get $1) + (block + (block + (local.set $2 + (local.get $x) + ) + (if + (local.get $2) + (block + (return + (i32.const 2) + ) + (unreachable) + ) + (block + (return + (i32.const 3) + ) + (unreachable) + ) + ) + ) + (unreachable) + ) + ) + ) + (nop) + (block + (local.set $3 + (local.get $x) + ) + (if + (local.get $3) + (block + (return + (i32.const 4) + ) + (unreachable) + ) + ) + ) + (nop) + (return + (i32.const 5) + ) + (unreachable) + ) + (local.set $5 + (local.get $4) + ) + (return + (local.get $5) + ) + ) + (func $loops (; 5 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (block + (block + (local.set $1 + (local.get $x) + ) + (if + (local.get $1) + (block + (loop $top + (block + (call $trivial) + (nop) + (br $top) + (unreachable) + ) + (unreachable) + ) + (unreachable) + ) + ) + ) + (nop) + (loop $top2 + (block + (call $trivial) + (nop) + (local.set $2 + (local.get $x) + ) + (br_if $top2 + (local.get $2) + ) + (nop) + ) + (nop) + ) + (nop) + (loop $top3 + (block + (call $trivial) + (nop) + (block + (local.set $3 + (local.get $x) + ) + (if + (local.get $3) + (block + (br $top3) + (unreachable) + ) + ) + ) + (nop) + ) + (nop) + ) + (nop) + ) + (nop) + ) + (func $br-out (; 6 ;) (type $3) (param $x i32) + (block $out + (call $br-out + (i32.const 5) + ) + (nop) + (br $out) + (unreachable) + ) + (nop) + ) + (func $unreachable (; 7 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (block + (block + (local.set $1 + (local.get $x) + ) + (if + (local.get $1) + (block + (block + (local.set $2 + (local.get $x) + ) + (if + (local.get $2) + (block + (block $block + (call $unreachable + (i32.const 1) + ) + (nop) + (unreachable) + (unreachable) + (call $unreachable + (i32.const 2) + ) + (nop) + ) + (unreachable) + ) + (block + (block $block4 + (call $unreachable + (i32.const 3) + ) + (nop) + (return) + (unreachable) + (call $unreachable + (i32.const 4) + ) + (nop) + ) + (unreachable) + ) + ) + ) + (unreachable) + ) + ) + ) + (nop) + (block $out + (call $unreachable + (i32.const 5) + ) + (nop) + (br $out) + (unreachable) + (call $unreachable + (i32.const 6) + ) + (nop) + ) + (nop) + ) + (nop) + ) + (func $empty-blocks (; 8 ;) (type $3) (param $x i32) + (block + (block $block + ) + (nop) + (block $block5 + ) + (nop) + ) + (nop) + ) + (func $before-and-after (; 9 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (block + (call $before-and-after + (i32.const 1) + ) + (nop) + (block $block + (call $before-and-after + (i32.const 2) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 3) + ) + (nop) + (block $out + (call $before-and-after + (i32.const 4) + ) + (nop) + (local.set $1 + (local.get $x) + ) + (br_if $out + (local.get $1) + ) + (nop) + (call $before-and-after + (i32.const 5) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 6) + ) + (nop) + (loop $loop-in + (nop) + ) + (nop) + (call $before-and-after + (i32.const 7) + ) + (nop) + (loop $top + (nop) + ) + (nop) + (call $before-and-after + (i32.const 8) + ) + (nop) + (loop $top2 + (block + (call $before-and-after + (i32.const 9) + ) + (nop) + (local.set $2 + (local.get $x) + ) + (br_if $top2 + (local.get $2) + ) + (nop) + (call $before-and-after + (i32.const 10) + ) + (nop) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 11) + ) + (nop) + (block + (local.set $3 + (local.get $x) + ) + (if + (local.get $3) + (block + (call $before-and-after + (i32.const 12) + ) + (nop) + ) + ) + ) + (nop) + (call $before-and-after + (i32.const 13) + ) + (nop) + (block + (local.set $4 + (local.get $x) + ) + (if + (local.get $4) + (block + (call $before-and-after + (i32.const 14) + ) + (nop) + ) + (block + (call $before-and-after + (i32.const 15) + ) + (nop) + ) + ) + ) + (nop) + (block + (local.set $5 + (local.get $x) + ) + (if + (local.get $5) + (block + (block $block8 + (call $before-and-after + (i32.const 16) + ) + (nop) + ) + (nop) + ) + ) + ) + (nop) + (call $before-and-after + (i32.const 17) + ) + (nop) + (block $block9 + (call $before-and-after + (i32.const 18) + ) + (nop) + (block $block10 + (call $before-and-after + (i32.const 19) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 20) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 21) + ) + (nop) + (block $block11 + (block $block12 + (call $before-and-after + (i32.const 22) + ) + (nop) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 23) + ) + (nop) + (block $no1 + (block $no2 + (call $before-and-after + (i32.const 24) + ) + (nop) + ) + (nop) + ) + (nop) + (call $before-and-after + (i32.const 25) + ) + (nop) + ) + (nop) + ) + (func $switch (; 10 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (block $out + (block $a + (local.set $1 + (local.get $x) + ) + (br_table $a $a + (local.get $1) + ) + (unreachable) + ) + (nop) + (call $switch + (i32.const 1) + ) + (nop) + (block $b + (block $c + (local.set $2 + (local.get $x) + ) + (br_table $b $b $b $c + (local.get $2) + ) + (unreachable) + ) + (nop) + (call $switch + (i32.const 2) + ) + (nop) + ) + (nop) + (call $switch + (i32.const 3) + ) + (nop) + ) + (nop) + ) + (func $no-return (; 11 ;) (type $0) + (if + (i32.const 1) + (block + (drop + (i32.const 2) + ) + (nop) + ) + (block + (drop + (i32.const 3) + ) + (nop) + ) + ) + (nop) + ) + (func $if-br-wat (; 12 ;) (type $3) (param $x i32) + (local $1 i32) + (local $2 i32) + (block + (call $if-br-wat + (i32.const 0) + ) + (nop) + (block $label$2 + (block + (local.set $1 + (local.get $x) + ) + (if + (local.get $1) + (block + (call $if-br-wat + (i32.const 1) + ) + (nop) + ) + (block + (block + (local.set $2 + (local.get $x) + ) + (if + (local.get $2) + (block + (br $label$2) + (unreachable) + ) + ) + ) + (nop) + ) + ) + ) + (nop) + (call $if-br-wat + (i32.const 2) + ) + (nop) + ) + (nop) + (call $if-br-wat + (i32.const 3) + ) + (nop) + ) + (nop) + ) + (func $switcher-to-nowhere (; 13 ;) (type $2) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (block + (block $switch + (block $switch-case0 + (block $switch-case + (local.set $1 + (local.get $0) + ) + (br_table $switch-case $switch-case0 $switch + (local.get $1) + ) + (unreachable) + ) + (nop) + (return + (i32.const 1) + ) + (unreachable) + ) + (nop) + (return + (i32.const 2) + ) + (unreachable) + ) + (nop) + (return + (i32.const 3) + ) + (unreachable) + ) + (local.set $3 + (local.get $2) + ) + (return + (local.get $3) + ) + ) +) diff --git a/test/passes/i64-to-i32-lowering.txt b/test/passes/i64-to-i32-lowering.txt deleted file mode 100644 index 6f4911322..000000000 --- a/test/passes/i64-to-i32-lowering.txt +++ /dev/null @@ -1,62 +0,0 @@ -(module - (type $FUNCSIG$j (func (result i32))) - (import "env" "func" (func $import (result i32))) - (global $i64toi32_i32$HIGH_BITS (mut i32) (i32.const 0)) - (func $defined (; 1 ;) (type $FUNCSIG$j) (result i32) - (local $i64toi32_i32$0 i32) - (local $i64toi32_i32$1 i32) - (local $i64toi32_i32$2 i32) - (local $i64toi32_i32$3 i32) - (local $i64toi32_i32$4 i32) - (local $i64toi32_i32$5 i32) - (local.set $i64toi32_i32$2 - (block (result i32) - (local.set $i64toi32_i32$2 - (block (result i32) - (local.set $i64toi32_i32$0 - (i32.const 0) - ) - (i32.const 1) - ) - ) - (local.set $i64toi32_i32$3 - (block (result i32) - (local.set $i64toi32_i32$1 - (i32.const 0) - ) - (i32.const 2) - ) - ) - (local.set $i64toi32_i32$4 - (i32.add - (local.get $i64toi32_i32$2) - (local.get $i64toi32_i32$3) - ) - ) - (local.set $i64toi32_i32$5 - (i32.add - (local.get $i64toi32_i32$0) - (local.get $i64toi32_i32$1) - ) - ) - (if - (i32.lt_u - (local.get $i64toi32_i32$4) - (local.get $i64toi32_i32$3) - ) - (local.set $i64toi32_i32$5 - (i32.add - (local.get $i64toi32_i32$5) - (i32.const 1) - ) - ) - ) - (local.get $i64toi32_i32$4) - ) - ) - (global.set $i64toi32_i32$HIGH_BITS - (local.get $i64toi32_i32$5) - ) - (local.get $i64toi32_i32$2) - ) -) diff --git a/test/passes/local-cse.txt b/test/passes/local-cse.txt deleted file mode 100644 index 286f29e7c..000000000 --- a/test/passes/local-cse.txt +++ /dev/null @@ -1,37 +0,0 @@ -(module - (type $0 (func (result i64))) - (type $1 (func)) - (global $glob (mut i32) (i32.const 1)) - (func $i64-shifts (; 0 ;) (type $0) (result i64) - (local $temp i64) - (local.set $temp - (i64.add - (i64.const 1) - (i64.const 2) - ) - ) - (local.set $temp - (i64.const 9999) - ) - (local.set $temp - (i64.add - (i64.const 1) - (i64.const 2) - ) - ) - (local.get $temp) - ) - (func $global (; 1 ;) (type $1) - (local $x i32) - (local $y i32) - (local.set $x - (global.get $glob) - ) - (local.set $y - (local.get $x) - ) - (local.set $y - (local.get $x) - ) - ) -) diff --git a/test/passes/local-cse.wast b/test/passes/local-cse.wast deleted file mode 100644 index 5c5a0cf74..000000000 --- a/test/passes/local-cse.wast +++ /dev/null @@ -1,29 +0,0 @@ -(module - (global $glob (mut i32) (i32.const 1)) - (func $i64-shifts (result i64) - (local $temp i64) - (local.set $temp - (i64.add - (i64.const 1) - (i64.const 2) - ) - ) - (local.set $temp - (i64.const 9999) - ) - (local.set $temp - (i64.add - (i64.const 1) - (i64.const 2) - ) - ) - (local.get $temp) - ) - (func $global - (local $x i32) - (local $y i32) - (local.set $x (global.get $glob)) - (local.set $y (global.get $glob)) - (local.set $y (global.get $glob)) - ) -) diff --git a/test/passes/rereloop.txt b/test/passes/rereloop.txt deleted file mode 100644 index 1f0b40565..000000000 --- a/test/passes/rereloop.txt +++ /dev/null @@ -1,575 +0,0 @@ -(module - (type $0 (func)) - (type $1 (func (result i32))) - (type $2 (func (param i32) (result i32))) - (type $3 (func (param i32))) - (func $trivial (; 0 ;) (type $0) - (local $0 i32) - (return) - ) - (func $trivial2 (; 1 ;) (type $0) - (local $0 i32) - (block - (call $trivial) - (call $trivial) - (return) - ) - ) - (func $return-void (; 2 ;) (type $0) - (local $0 i32) - (return) - ) - (func $return-val (; 3 ;) (type $1) (result i32) - (local $0 i32) - (return - (i32.const 1) - ) - ) - (func $ifs (; 4 ;) (type $2) (param $x i32) (result i32) - (local $1 i32) - (block - ) - (if - (local.get $x) - (block - (block - ) - (if - (local.get $x) - (block - (return - (i32.const 2) - ) - ) - (block - (return - (i32.const 3) - ) - ) - ) - ) - (block - (block - ) - (if - (local.get $x) - (block - (return - (i32.const 4) - ) - ) - (block - (return - (i32.const 5) - ) - ) - ) - ) - ) - ) - (func $loops (; 5 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$6$break - (block - ) - (if - (local.get $x) - (loop $shape$2$continue - (call $trivial) - (block - (br $shape$2$continue) - ) - ) - (br $block$6$break) - ) - ) - (block - (block $block$8$break - (loop $shape$4$continue - (call $trivial) - (if - (local.get $x) - (br $shape$4$continue) - (br $block$8$break) - ) - ) - ) - (block - (block $block$11$break - (loop $shape$6$continue - (call $trivial) - (if - (local.get $x) - (br $shape$6$continue) - (br $block$11$break) - ) - ) - ) - (block - (return) - ) - ) - ) - ) - (func $br-out (; 6 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$2$break - (call $br-out - (i32.const 5) - ) - (block - (br $block$2$break) - ) - ) - (block - (return) - ) - ) - (func $unreachable (; 7 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$2$break - (block - ) - (if - (local.get $x) - (br $block$2$break) - (block - (block $block$11$break - (call $unreachable - (i32.const 5) - ) - (block - (br $block$11$break) - ) - ) - (block - (return) - ) - ) - ) - ) - (block - (block - ) - (if - (local.get $x) - (block - (block - (call $unreachable - (i32.const 1) - ) - (unreachable) - ) - ) - (block - (block - (call $unreachable - (i32.const 3) - ) - (return) - ) - ) - ) - ) - ) - (func $empty-blocks (; 8 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$3$break - (block - ) - (block - (br $block$3$break) - ) - ) - (block - (return) - ) - ) - (func $before-and-after (; 9 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$3$break - (block - (block - (call $before-and-after - (i32.const 1) - ) - (call $before-and-after - (i32.const 2) - ) - ) - (block - (call $before-and-after - (i32.const 3) - ) - (call $before-and-after - (i32.const 4) - ) - ) - ) - (if - (local.get $x) - (br $block$3$break) - (block - (call $before-and-after - (i32.const 5) - ) - (block - (br $block$3$break) - ) - ) - ) - ) - (block - (block $block$7$break - (block - (block - (call $before-and-after - (i32.const 6) - ) - (call $before-and-after - (i32.const 7) - ) - ) - (call $before-and-after - (i32.const 8) - ) - ) - (block - (br $block$7$break) - ) - ) - (block - (block $block$8$break - (loop $shape$4$continue - (call $before-and-after - (i32.const 9) - ) - (if - (local.get $x) - (br $shape$4$continue) - (br $block$8$break) - ) - ) - ) - (block - (block $block$10$break - (block - (call $before-and-after - (i32.const 10) - ) - (call $before-and-after - (i32.const 11) - ) - ) - (if - (local.get $x) - (block - (call $before-and-after - (i32.const 12) - ) - (block - (br $block$10$break) - ) - ) - (br $block$10$break) - ) - ) - (block - (block $block$13$break - (call $before-and-after - (i32.const 13) - ) - (if - (local.get $x) - (block - (call $before-and-after - (i32.const 14) - ) - (block - (br $block$13$break) - ) - ) - (block - (call $before-and-after - (i32.const 15) - ) - (block - (br $block$13$break) - ) - ) - ) - ) - (block - (block $block$16$break - (block - ) - (if - (local.get $x) - (block - (call $before-and-after - (i32.const 16) - ) - (block - (br $block$16$break) - ) - ) - (br $block$16$break) - ) - ) - (block - (block $block$19$break - (block - (block - (block - (call $before-and-after - (i32.const 17) - ) - (call $before-and-after - (i32.const 18) - ) - (call $before-and-after - (i32.const 19) - ) - ) - (call $before-and-after - (i32.const 20) - ) - ) - (block - (call $before-and-after - (i32.const 21) - ) - (call $before-and-after - (i32.const 22) - ) - ) - ) - (block - (br $block$19$break) - ) - ) - (block - (block $block$21$break - (block - (call $before-and-after - (i32.const 23) - ) - (call $before-and-after - (i32.const 24) - ) - ) - (block - (br $block$21$break) - ) - ) - (block - (block - (call $before-and-after - (i32.const 25) - ) - (return) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - (func $switch (; 10 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$3$break - (block - ) - (block - (br $block$3$break) - ) - ) - (block - (block $block$6$break - (call $switch - (i32.const 1) - ) - (block $switch$3$leave - (block $switch$3$default - (block $switch$3$case$6 - (br_table $switch$3$case$6 $switch$3$case$6 $switch$3$case$6 $switch$3$default - (local.get $x) - ) - ) - (block - (br $block$6$break) - ) - ) - (block - (block - (call $switch - (i32.const 2) - ) - (block - (br $block$6$break) - ) - ) - ) - ) - ) - (block - (block - (call $switch - (i32.const 3) - ) - (return) - ) - ) - ) - ) - (func $no-return (; 11 ;) (type $0) - (local $0 i32) - (block $block$4$break - (block - ) - (if - (i32.const 1) - (block - (drop - (i32.const 2) - ) - (block - (br $block$4$break) - ) - ) - (block - (drop - (i32.const 3) - ) - (block - (br $block$4$break) - ) - ) - ) - ) - (block - (return) - ) - ) - (func $if-br-wat (; 12 ;) (type $3) (param $x i32) - (local $1 i32) - (block $block$2$break - (block $block$8$break - (call $if-br-wat - (i32.const 0) - ) - (if - (local.get $x) - (block - (call $if-br-wat - (i32.const 1) - ) - (block - (br $block$8$break) - ) - ) - (block - (block - ) - (if - (local.get $x) - (br $block$2$break) - (br $block$8$break) - ) - ) - ) - ) - (block - (call $if-br-wat - (i32.const 2) - ) - (block - (br $block$2$break) - ) - ) - ) - (block - (block - (call $if-br-wat - (i32.const 3) - ) - (return) - ) - ) - ) - (func $switcher-to-nowhere (; 13 ;) (type $2) (param $0 i32) (result i32) - (local $1 i32) - (block - (block - ) - (block $switch$1$leave - (block $switch$1$default - (block $switch$1$case$3 - (block $switch$1$case$4 - (br_table $switch$1$case$4 $switch$1$case$3 $switch$1$default - (local.get $0) - ) - ) - (block - (block - (return - (i32.const 1) - ) - ) - ) - ) - (block - (block - (return - (i32.const 2) - ) - ) - ) - ) - (block - (block - (return - (i32.const 3) - ) - ) - ) - ) - ) - (unreachable) - ) -) -(module - (type $0 (func)) - (type $1 (func (result i32))) - (global $global$0 (mut i32) (i32.const 1)) - (export "one" (func $0)) - (export "two" (func $1)) - (func $0 (; 0 ;) (type $0) - (local $0 i32) - (block - ) - (if - (i32.const 1) - (block - (return) - ) - (block - (block - (global.set $global$0 - (i32.const 0) - ) - (unreachable) - ) - ) - ) - ) - (func $1 (; 1 ;) (type $1) (result i32) - (local $0 i32) - (return - (global.get $global$0) - ) - ) -) diff --git a/test/passes/rereloop.wast b/test/passes/rereloop.wast deleted file mode 100644 index 7b3ebc3f1..000000000 --- a/test/passes/rereloop.wast +++ /dev/null @@ -1,221 +0,0 @@ -(module - (func $trivial - (nop) - ) - (func $trivial2 - (call $trivial) - (call $trivial) - ) - (func $return-void - (return) - ) - (func $return-val (result i32) - (return (i32.const 1)) - ) - (func $ifs (param $x i32) (result i32) - (if - (local.get $x) - (if - (local.get $x) - (return (i32.const 2)) - (return (i32.const 3)) - ) - ) - (if - (local.get $x) - (return (i32.const 4)) - ) - (return (i32.const 5)) - ) - (func $loops (param $x i32) - (if (local.get $x) - (loop $top - (call $trivial) - (br $top) - ) - ) - (loop $top2 - (call $trivial) - (br_if $top2 (local.get $x)) - ) - (loop $top3 - (call $trivial) - (if (local.get $x) (br $top3)) - ) - ) - (func $br-out (param $x i32) - (block $out - (call $br-out (i32.const 5)) - (br $out) - ) - ) - (func $unreachable (param $x i32) - (if (local.get $x) - (if (local.get $x) - (block - (call $unreachable (i32.const 1)) - (unreachable) - (call $unreachable (i32.const 2)) - ) - (block - (call $unreachable (i32.const 3)) - (return) - (call $unreachable (i32.const 4)) - ) - ) - ) - (block $out - (call $unreachable (i32.const 5)) - (br $out) - (call $unreachable (i32.const 6)) - ) - ) - (func $empty-blocks (param $x i32) - (block) - (block) - ) - (func $before-and-after (param $x i32) - (call $before-and-after (i32.const 1)) - (block - (call $before-and-after (i32.const 2)) - ) - (call $before-and-after (i32.const 3)) - (block $out - (call $before-and-after (i32.const 4)) - (br_if $out (local.get $x)) - (call $before-and-after (i32.const 5)) - ) - (call $before-and-after (i32.const 6)) - (loop) - (call $before-and-after (i32.const 7)) - (loop $top) - (call $before-and-after (i32.const 8)) - (loop $top2 - (call $before-and-after (i32.const 9)) - (br_if $top2 (local.get $x)) - (call $before-and-after (i32.const 10)) - ) - (call $before-and-after (i32.const 11)) - (if (local.get $x) - (call $before-and-after (i32.const 12)) - ) - (call $before-and-after (i32.const 13)) - (if (local.get $x) - (call $before-and-after (i32.const 14)) - (call $before-and-after (i32.const 15)) - ) - (if (local.get $x) - (block - (call $before-and-after (i32.const 16)) - ) - ) - (call $before-and-after (i32.const 17)) - (block - (call $before-and-after (i32.const 18)) - (block - (call $before-and-after (i32.const 19)) - ) - (call $before-and-after (i32.const 20)) - ) - (call $before-and-after (i32.const 21)) - (block - (block - (call $before-and-after (i32.const 22)) - ) - ) - (call $before-and-after (i32.const 23)) - (block $no1 - (block $no2 - (call $before-and-after (i32.const 24)) - ) - ) - (call $before-and-after (i32.const 25)) - ) - (func $switch (param $x i32) - (block $out - (block $a - (br_table $a $a (local.get $x)) - ) - (call $switch (i32.const 1)) - (block $b - (block $c - (br_table $b $b $b $c (local.get $x)) - ) - (call $switch (i32.const 2)) - ) - (call $switch (i32.const 3)) - ) - ) - (func $no-return - (if (i32.const 1) - (drop (i32.const 2)) - (drop (i32.const 3)) - ) - ) - (func $if-br-wat (param $x i32) - (call $if-br-wat - (i32.const 0) - ) - (block $label$2 - (if - (local.get $x) - (call $if-br-wat - (i32.const 1) - ) - (if - (local.get $x) - (br $label$2) ;; waka - ) - ) - (call $if-br-wat - (i32.const 2) - ) - ) - (call $if-br-wat - (i32.const 3) - ) - ) - - (func $switcher-to-nowhere (param $0 i32) (result i32) - (block $switch - (block $switch-case0 - (block $switch-case - (br_table $switch-case $switch-case0 $switch - (local.get $0) - ) - ) - (return - (i32.const 1) - ) - ) - (return - (i32.const 2) - ) - ) - (return - (i32.const 3) - ) - ) -) -(module - (global $global$0 (mut i32) (i32.const 1)) - (export "one" (func $0)) - (export "two" (func $1)) - (func $0 - (block $outer - (block - (br_if $outer ;; taken - do not modify the global, stay it at 1 - (i32.const 1) - ) - (global.set $global$0 ;; never get here! - (i32.const 0) - ) - ) - (unreachable) - ) - ) - (func $1 (result i32) - (return (global.get $global$0)) - ) -) - |