summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-09-05 13:44:43 -0700
committerGitHub <noreply@github.com>2018-09-05 13:44:43 -0700
commita0cbc9dbbfcfd5bb254da904c19e3f6b0a1716c1 (patch)
treee06fcb231cb49378e6dc9b20e289c8f69a7a1898 /test
parent8900ceb7e1adf6b91374c236a30ad7f20b980106 (diff)
downloadbinaryen-a0cbc9dbbfcfd5bb254da904c19e3f6b0a1716c1.tar.gz
binaryen-a0cbc9dbbfcfd5bb254da904c19e3f6b0a1716c1.tar.bz2
binaryen-a0cbc9dbbfcfd5bb254da904c19e3f6b0a1716c1.zip
DeadArgumentElimination Pass (#1641)
This adds a pass to remove unnecessary call arguments in an LTO-like manner, that is: * If a parameter is not actually used in a function, we don't need to send anything, and can remove it from the function's declaration. Concretely, (func $a (param $x i32) ..no uses of $x.. ) (func $b (call $a (..)) ) => (func $a ..no uses of $x.. ) (func $b (call $a) ) And * If a parameter is only ever sent the same constant value, we can just set that constant value in the function (which then means that the values sent from the outside are no longer used, as in the previous point). Concretely, (func $a (param $x i32) ..may use $x.. ) (func $b (call $a (i32.const 1)) (call $a (i32.const 1)) ) => (func $a (local $x i32) (set_local $x (i32.const 1) ..may use $x.. ) (func $b (call $a) (call $a) ) How much this helps depends on the codebase obviously, but sometimes it is pretty useful. For example, it shrinks 0.72% on Unity and 0.37% on Mono. Note that those numbers include not just the optimization itself, but the other optimizations it then enables - in particular the second point from earlier leads to inlining a constant value, which often allows constant propagation, and also removing parameters may enable more duplicate function elimination, etc. - which explains how this can shrink Unity by almost 1%. Implementation is pretty straightforward, but there is some work to make the heavy part of the pass parallel, and a bunch of corner cases to avoid (can't change a function that is exported or in the table, etc.). Like the Inlining pass, there is both a standard and an "optimizing" version of this pass - the latter also optimizes the functions it changes, as like Inlining, it's useful to not need to re-run all function optimizations on the whole module.
Diffstat (limited to 'test')
-rw-r--r--test/emcc_O2_hello_world.fromasm130
-rw-r--r--test/emcc_O2_hello_world.fromasm.clamp130
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise128
-rw-r--r--test/emcc_hello_world.fromasm145
-rw-r--r--test/emcc_hello_world.fromasm.clamp145
-rw-r--r--test/emcc_hello_world.fromasm.imprecise146
-rw-r--r--test/memorygrowth.fromasm123
-rw-r--r--test/memorygrowth.fromasm.clamp123
-rw-r--r--test/memorygrowth.fromasm.imprecise149
-rw-r--r--test/passes/converge_O3_metrics.bin.txt441
-rw-r--r--test/passes/dae.txt174
-rw-r--r--test/passes/dae.wast87
-rw-r--r--test/wasm-only.asm.js2
-rw-r--r--test/wasm-only.fromasm335
-rw-r--r--test/wasm-only.fromasm.clamp335
-rw-r--r--test/wasm-only.fromasm.clamp.no-opts8
-rw-r--r--test/wasm-only.fromasm.imprecise335
-rw-r--r--test/wasm-only.fromasm.imprecise.no-opts8
-rw-r--r--test/wasm-only.fromasm.no-opts8
19 files changed, 1243 insertions, 1709 deletions
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index 0566193d0..5bc940d9f 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -8488,7 +8488,8 @@
(get_local $3)
)
)
- (func $___overflow (; 21 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $___overflow (; 21 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -8496,9 +8497,7 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
- (local $9 i32)
- (local $10 i32)
- (set_local $5
+ (set_local $4
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -8508,20 +8507,15 @@
)
)
(i32.store8
- (tee_local $6
- (get_local $5)
- )
- (tee_local $9
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $5
+ (get_local $4)
)
+ (i32.const 10)
)
(if
- (tee_local $3
+ (tee_local $2
(i32.load
- (tee_local $2
+ (tee_local $1
(i32.add
(get_local $0)
(i32.const 16)
@@ -8530,10 +8524,10 @@
)
)
(block
- (set_local $7
- (get_local $3)
+ (set_local $6
+ (get_local $2)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8541,16 +8535,16 @@
(call $___towrite
(get_local $0)
)
- (set_local $4
+ (set_local $3
(i32.const -1)
)
(block
- (set_local $7
+ (set_local $6
(i32.load
- (get_local $2)
+ (get_local $1)
)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8559,16 +8553,16 @@
(block $do-once
(if
(i32.eq
- (get_local $8)
+ (get_local $7)
(i32.const 4)
)
(block
(if
(if (result i32)
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $0)
(i32.const 20)
@@ -8576,14 +8570,11 @@
)
)
)
- (get_local $7)
+ (get_local $6)
)
(i32.ne
- (tee_local $10
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $8
+ (i32.const 10)
)
(i32.load8_s offset=75
(get_local $0)
@@ -8593,28 +8584,28 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
- (get_local $9)
+ (get_local $1)
+ (i32.const 10)
)
- (set_local $4
- (get_local $10)
+ (set_local $3
+ (get_local $8)
)
(br $do-once)
)
)
- (set_local $4
+ (set_local $3
(if (result i32)
(i32.eq
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
- (get_local $6)
+ (get_local $5)
(i32.const 1)
(i32.add
(i32.and
@@ -8629,7 +8620,7 @@
(i32.const 1)
)
(i32.load8_u
- (get_local $6)
+ (get_local $5)
)
(i32.const -1)
)
@@ -8638,9 +8629,9 @@
)
)
(set_global $STACKTOP
- (get_local $5)
+ (get_local $4)
)
- (get_local $4)
+ (get_local $3)
)
(func $___fflush_unlocked (; 22 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
@@ -9053,13 +9044,13 @@
(get_local $2)
)
)
- (func $_puts (; 26 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (func $_puts (; 26 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
(local $2 i32)
- (local $3 i32)
(drop
(i32.load offset=76
- (tee_local $1
+ (tee_local $0
(i32.load
(i32.const 52)
)
@@ -9074,12 +9065,11 @@
(i32.lt_s
(i32.add
(call $_fwrite
- (get_local $0)
+ (i32.const 672)
(call $_strlen
- (get_local $0)
+ (i32.const 672)
)
- (i32.const 1)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
)
@@ -9091,37 +9081,37 @@
(if (result i32)
(i32.ne
(i32.load8_s offset=75
- (get_local $1)
+ (get_local $0)
)
(i32.const 10)
)
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
- (get_local $1)
+ (get_local $0)
(i32.const 20)
)
)
)
)
(i32.load offset=16
- (get_local $1)
+ (get_local $0)
)
)
(i32.const 0)
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
+ (get_local $1)
(i32.const 10)
)
(br $do-once
@@ -9131,8 +9121,7 @@
)
(i32.lt_s
(call $___overflow
- (get_local $1)
- (i32.const 10)
+ (get_local $0)
)
(i32.const 0)
)
@@ -9292,33 +9281,34 @@
)
)
)
- (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
(local $4 i32)
(set_local $4
- (i32.mul
- (get_local $2)
- (get_local $1)
- )
+ (i32.const 1)
+ )
+ (set_local $3
+ (get_local $1)
)
(if
(block (result i32)
(drop
(i32.load offset=76
- (get_local $3)
+ (get_local $2)
)
)
(i32.ne
(tee_local $0
(call $___fwritex
(get_local $0)
- (get_local $4)
(get_local $3)
+ (get_local $2)
)
)
- (get_local $4)
+ (get_local $3)
)
)
- (set_local $2
+ (set_local $4
(if (result i32)
(get_local $1)
(i32.div_u
@@ -9329,7 +9319,7 @@
)
)
)
- (get_local $2)
+ (get_local $4)
)
(func $___stdout_write (; 30 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@@ -9574,9 +9564,7 @@
)
(func $_main (; 46 ;) (; has Stack IR ;) (result i32)
(drop
- (call $_puts
- (i32.const 672)
- )
+ (call $_puts)
)
(i32.const 0)
)
diff --git a/test/emcc_O2_hello_world.fromasm.clamp b/test/emcc_O2_hello_world.fromasm.clamp
index 0566193d0..5bc940d9f 100644
--- a/test/emcc_O2_hello_world.fromasm.clamp
+++ b/test/emcc_O2_hello_world.fromasm.clamp
@@ -8488,7 +8488,8 @@
(get_local $3)
)
)
- (func $___overflow (; 21 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $___overflow (; 21 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -8496,9 +8497,7 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
- (local $9 i32)
- (local $10 i32)
- (set_local $5
+ (set_local $4
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -8508,20 +8507,15 @@
)
)
(i32.store8
- (tee_local $6
- (get_local $5)
- )
- (tee_local $9
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $5
+ (get_local $4)
)
+ (i32.const 10)
)
(if
- (tee_local $3
+ (tee_local $2
(i32.load
- (tee_local $2
+ (tee_local $1
(i32.add
(get_local $0)
(i32.const 16)
@@ -8530,10 +8524,10 @@
)
)
(block
- (set_local $7
- (get_local $3)
+ (set_local $6
+ (get_local $2)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8541,16 +8535,16 @@
(call $___towrite
(get_local $0)
)
- (set_local $4
+ (set_local $3
(i32.const -1)
)
(block
- (set_local $7
+ (set_local $6
(i32.load
- (get_local $2)
+ (get_local $1)
)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8559,16 +8553,16 @@
(block $do-once
(if
(i32.eq
- (get_local $8)
+ (get_local $7)
(i32.const 4)
)
(block
(if
(if (result i32)
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $0)
(i32.const 20)
@@ -8576,14 +8570,11 @@
)
)
)
- (get_local $7)
+ (get_local $6)
)
(i32.ne
- (tee_local $10
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $8
+ (i32.const 10)
)
(i32.load8_s offset=75
(get_local $0)
@@ -8593,28 +8584,28 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
- (get_local $9)
+ (get_local $1)
+ (i32.const 10)
)
- (set_local $4
- (get_local $10)
+ (set_local $3
+ (get_local $8)
)
(br $do-once)
)
)
- (set_local $4
+ (set_local $3
(if (result i32)
(i32.eq
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
- (get_local $6)
+ (get_local $5)
(i32.const 1)
(i32.add
(i32.and
@@ -8629,7 +8620,7 @@
(i32.const 1)
)
(i32.load8_u
- (get_local $6)
+ (get_local $5)
)
(i32.const -1)
)
@@ -8638,9 +8629,9 @@
)
)
(set_global $STACKTOP
- (get_local $5)
+ (get_local $4)
)
- (get_local $4)
+ (get_local $3)
)
(func $___fflush_unlocked (; 22 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
@@ -9053,13 +9044,13 @@
(get_local $2)
)
)
- (func $_puts (; 26 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (func $_puts (; 26 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
(local $2 i32)
- (local $3 i32)
(drop
(i32.load offset=76
- (tee_local $1
+ (tee_local $0
(i32.load
(i32.const 52)
)
@@ -9074,12 +9065,11 @@
(i32.lt_s
(i32.add
(call $_fwrite
- (get_local $0)
+ (i32.const 672)
(call $_strlen
- (get_local $0)
+ (i32.const 672)
)
- (i32.const 1)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
)
@@ -9091,37 +9081,37 @@
(if (result i32)
(i32.ne
(i32.load8_s offset=75
- (get_local $1)
+ (get_local $0)
)
(i32.const 10)
)
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
- (get_local $1)
+ (get_local $0)
(i32.const 20)
)
)
)
)
(i32.load offset=16
- (get_local $1)
+ (get_local $0)
)
)
(i32.const 0)
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
+ (get_local $1)
(i32.const 10)
)
(br $do-once
@@ -9131,8 +9121,7 @@
)
(i32.lt_s
(call $___overflow
- (get_local $1)
- (i32.const 10)
+ (get_local $0)
)
(i32.const 0)
)
@@ -9292,33 +9281,34 @@
)
)
)
- (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
(local $4 i32)
(set_local $4
- (i32.mul
- (get_local $2)
- (get_local $1)
- )
+ (i32.const 1)
+ )
+ (set_local $3
+ (get_local $1)
)
(if
(block (result i32)
(drop
(i32.load offset=76
- (get_local $3)
+ (get_local $2)
)
)
(i32.ne
(tee_local $0
(call $___fwritex
(get_local $0)
- (get_local $4)
(get_local $3)
+ (get_local $2)
)
)
- (get_local $4)
+ (get_local $3)
)
)
- (set_local $2
+ (set_local $4
(if (result i32)
(get_local $1)
(i32.div_u
@@ -9329,7 +9319,7 @@
)
)
)
- (get_local $2)
+ (get_local $4)
)
(func $___stdout_write (; 30 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@@ -9574,9 +9564,7 @@
)
(func $_main (; 46 ;) (; has Stack IR ;) (result i32)
(drop
- (call $_puts
- (i32.const 672)
- )
+ (call $_puts)
)
(i32.const 0)
)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index d34cf8655..bbc3b3373 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -8482,7 +8482,8 @@
(get_local $3)
)
)
- (func $___overflow (; 21 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $___overflow (; 21 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -8490,9 +8491,7 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
- (local $9 i32)
- (local $10 i32)
- (set_local $5
+ (set_local $4
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -8502,20 +8501,15 @@
)
)
(i32.store8
- (tee_local $6
- (get_local $5)
- )
- (tee_local $9
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $5
+ (get_local $4)
)
+ (i32.const 10)
)
(if
- (tee_local $3
+ (tee_local $2
(i32.load
- (tee_local $2
+ (tee_local $1
(i32.add
(get_local $0)
(i32.const 16)
@@ -8524,10 +8518,10 @@
)
)
(block
- (set_local $7
- (get_local $3)
+ (set_local $6
+ (get_local $2)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8535,16 +8529,16 @@
(call $___towrite
(get_local $0)
)
- (set_local $4
+ (set_local $3
(i32.const -1)
)
(block
- (set_local $7
+ (set_local $6
(i32.load
- (get_local $2)
+ (get_local $1)
)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8553,16 +8547,16 @@
(block $do-once
(if
(i32.eq
- (get_local $8)
+ (get_local $7)
(i32.const 4)
)
(block
(if
(if (result i32)
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $0)
(i32.const 20)
@@ -8570,14 +8564,11 @@
)
)
)
- (get_local $7)
+ (get_local $6)
)
(i32.ne
- (tee_local $10
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $8
+ (i32.const 10)
)
(i32.load8_s offset=75
(get_local $0)
@@ -8587,28 +8578,28 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
- (get_local $9)
+ (get_local $1)
+ (i32.const 10)
)
- (set_local $4
- (get_local $10)
+ (set_local $3
+ (get_local $8)
)
(br $do-once)
)
)
- (set_local $4
+ (set_local $3
(if (result i32)
(i32.eq
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
- (get_local $6)
+ (get_local $5)
(i32.const 1)
(i32.add
(i32.and
@@ -8623,7 +8614,7 @@
(i32.const 1)
)
(i32.load8_u
- (get_local $6)
+ (get_local $5)
)
(i32.const -1)
)
@@ -8632,9 +8623,9 @@
)
)
(set_global $STACKTOP
- (get_local $5)
+ (get_local $4)
)
- (get_local $4)
+ (get_local $3)
)
(func $___fflush_unlocked (; 22 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
@@ -9047,13 +9038,13 @@
(get_local $2)
)
)
- (func $_puts (; 26 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (func $_puts (; 26 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
(local $2 i32)
- (local $3 i32)
(drop
(i32.load offset=76
- (tee_local $1
+ (tee_local $0
(i32.load
(i32.const 52)
)
@@ -9068,12 +9059,11 @@
(i32.lt_s
(i32.add
(call $_fwrite
- (get_local $0)
+ (i32.const 672)
(call $_strlen
- (get_local $0)
+ (i32.const 672)
)
- (i32.const 1)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
)
@@ -9085,37 +9075,37 @@
(if (result i32)
(i32.ne
(i32.load8_s offset=75
- (get_local $1)
+ (get_local $0)
)
(i32.const 10)
)
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
- (get_local $1)
+ (get_local $0)
(i32.const 20)
)
)
)
)
(i32.load offset=16
- (get_local $1)
+ (get_local $0)
)
)
(i32.const 0)
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
+ (get_local $1)
(i32.const 10)
)
(br $do-once
@@ -9125,8 +9115,7 @@
)
(i32.lt_s
(call $___overflow
- (get_local $1)
- (i32.const 10)
+ (get_local $0)
)
(i32.const 0)
)
@@ -9286,33 +9275,34 @@
)
)
)
- (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
(local $4 i32)
(set_local $4
- (i32.mul
- (get_local $2)
- (get_local $1)
- )
+ (i32.const 1)
+ )
+ (set_local $3
+ (get_local $1)
)
(if
(i32.ne
(tee_local $0
(call $___fwritex
(get_local $0)
- (get_local $4)
(get_local $3)
+ (get_local $2)
)
)
- (get_local $4)
+ (get_local $3)
)
- (set_local $2
+ (set_local $4
(i32.div_u
(get_local $0)
(get_local $1)
)
)
)
- (get_local $2)
+ (get_local $4)
)
(func $___stdout_write (; 30 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@@ -9553,9 +9543,7 @@
)
(func $_main (; 46 ;) (; has Stack IR ;) (result i32)
(drop
- (call $_puts
- (i32.const 672)
- )
+ (call $_puts)
)
(i32.const 0)
)
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 6811213dc..cffc2ad79 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -151,7 +151,6 @@
)
(drop
(call $_printf
- (i32.const 672)
(get_local $0)
)
)
@@ -571,10 +570,8 @@
)
)
(set_local $0
- (tee_local $1
- (call $___fflush_unlocked
- (get_local $0)
- )
+ (call $___fflush_unlocked
+ (get_local $0)
)
)
)
@@ -642,9 +639,9 @@
)
(get_local $0)
)
- (func $_printf (; 34 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
- (local $2 i32)
- (set_local $2
+ (func $_printf (; 34 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (local $1 i32)
+ (set_local $1
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -661,20 +658,20 @@
(call $abort)
)
(i32.store
- (get_local $2)
(get_local $1)
+ (get_local $0)
)
(set_local $0
(call $_vfprintf
(i32.load
(i32.const 8)
)
- (get_local $0)
- (get_local $2)
+ (i32.const 672)
+ (get_local $1)
)
)
(set_global $STACKTOP
- (get_local $2)
+ (get_local $1)
)
(get_local $0)
)
@@ -1564,7 +1561,7 @@
)
)
)
- (func $_wcrtomb (; 39 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_wcrtomb (; 39 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
(block $do-once (result i32)
(if (result i32)
(get_local $0)
@@ -1744,28 +1741,20 @@
(call $_wcrtomb
(get_local $0)
(get_local $1)
- (i32.const 0)
)
(i32.const 0)
)
)
- (func $_memchr (; 41 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memchr (; 41 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (local $2 i32)
(local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (set_local $5
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
(block $label$break$L8
(block $__rjti$2
(if
(i32.and
- (tee_local $4
+ (tee_local $3
(i32.ne
- (get_local $2)
+ (get_local $1)
(i32.const 0)
)
)
@@ -1778,27 +1767,17 @@
)
)
(block
- (set_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
- (set_local $3
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(loop $while-in
(br_if $__rjti$2
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
- (get_local $4)
- (i32.const 255)
+ (get_local $1)
)
)
)
@@ -1806,9 +1785,9 @@
(i32.and
(tee_local $0
(i32.ne
- (tee_local $3
+ (tee_local $2
(i32.add
- (get_local $3)
+ (get_local $2)
(i32.const -1)
)
)
@@ -1817,9 +1796,9 @@
)
(i32.ne
(i32.and
- (tee_local $2
+ (tee_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -1832,14 +1811,14 @@
)
)
(block
- (set_local $3
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(set_local $0
- (get_local $4)
+ (get_local $3)
)
)
)
@@ -1852,27 +1831,13 @@
(br $label$break$L8)
)
(set_local $0
- (get_local $3)
+ (get_local $2)
)
(if
- (i32.ne
- (i32.load8_u
- (get_local $2)
- )
- (tee_local $1
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (i32.load8_u
+ (get_local $1)
)
(block
- (set_local $3
- (i32.mul
- (get_local $5)
- (i32.const 16843009)
- )
- )
(block $__rjto$0
(block $__rjti$0
(br_if $__rjti$0
@@ -1887,12 +1852,9 @@
(i32.and
(i32.xor
(i32.and
- (tee_local $4
- (i32.xor
- (i32.load
- (get_local $2)
- )
- (get_local $3)
+ (tee_local $3
+ (i32.load
+ (get_local $1)
)
)
(i32.const -2139062144)
@@ -1900,15 +1862,15 @@
(i32.const -2139062144)
)
(i32.add
- (get_local $4)
+ (get_local $3)
(i32.const -16843009)
)
)
)
(block
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 4)
)
)
@@ -1943,19 +1905,15 @@
)
(loop $while-in5
(br_if $label$break$L8
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
(get_local $1)
- (i32.const 255)
)
)
)
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -1975,7 +1933,7 @@
)
)
(select
- (get_local $2)
+ (get_local $1)
(i32.const 0)
(get_local $0)
)
@@ -4539,7 +4497,6 @@
(get_global $tempRet0)
)
(i32.const 1000000000)
- (i32.const 0)
)
)
(set_local $12
@@ -4547,7 +4504,6 @@
(get_local $12)
(get_local $18)
(i32.const 1000000000)
- (i32.const 0)
)
)
(br_if $while-in66
@@ -6482,7 +6438,6 @@
(tee_local $13
(call $_memchr
(get_local $7)
- (i32.const 0)
(get_local $6)
)
)
@@ -7424,7 +7379,6 @@
(get_local $0)
(get_local $1)
(i32.const 10)
- (i32.const 0)
)
)
(i32.const 48)
@@ -7435,7 +7389,6 @@
(get_local $0)
(get_local $1)
(i32.const 10)
- (i32.const 0)
)
)
(set_local $4
@@ -15310,18 +15263,18 @@
)
(get_local $3)
)
- (func $___udivdi3 (; 61 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $___udivdi3 (; 61 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $___udivmoddi4
(get_local $0)
(get_local $1)
(get_local $2)
- (get_local $3)
+ (i32.const 0)
(i32.const 0)
)
)
- (func $___uremdi3 (; 62 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
- (local $4 i32)
- (set_local $4
+ (func $___uremdi3 (; 62 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
+ (set_local $3
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -15335,20 +15288,20 @@
(get_local $0)
(get_local $1)
(get_local $2)
+ (i32.const 0)
(get_local $3)
- (get_local $4)
)
)
(set_global $STACKTOP
- (get_local $4)
+ (get_local $3)
)
(set_global $tempRet0
(i32.load offset=4
- (get_local $4)
+ (get_local $3)
)
)
(i32.load
- (get_local $4)
+ (get_local $3)
)
)
(func $___udivmoddi4 (; 63 ;) (; has Stack IR ;) (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (param $r i32) (result i32)
diff --git a/test/emcc_hello_world.fromasm.clamp b/test/emcc_hello_world.fromasm.clamp
index ea687d264..17c1a9336 100644
--- a/test/emcc_hello_world.fromasm.clamp
+++ b/test/emcc_hello_world.fromasm.clamp
@@ -149,7 +149,6 @@
)
(drop
(call $_printf
- (i32.const 672)
(get_local $0)
)
)
@@ -569,10 +568,8 @@
)
)
(set_local $0
- (tee_local $1
- (call $___fflush_unlocked
- (get_local $0)
- )
+ (call $___fflush_unlocked
+ (get_local $0)
)
)
)
@@ -640,9 +637,9 @@
)
(get_local $0)
)
- (func $_printf (; 33 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
- (local $2 i32)
- (set_local $2
+ (func $_printf (; 33 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (local $1 i32)
+ (set_local $1
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -659,20 +656,20 @@
(call $abort)
)
(i32.store
- (get_local $2)
(get_local $1)
+ (get_local $0)
)
(set_local $0
(call $_vfprintf
(i32.load
(i32.const 8)
)
- (get_local $0)
- (get_local $2)
+ (i32.const 672)
+ (get_local $1)
)
)
(set_global $STACKTOP
- (get_local $2)
+ (get_local $1)
)
(get_local $0)
)
@@ -1562,7 +1559,7 @@
)
)
)
- (func $_wcrtomb (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_wcrtomb (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
(block $do-once (result i32)
(if (result i32)
(get_local $0)
@@ -1742,28 +1739,20 @@
(call $_wcrtomb
(get_local $0)
(get_local $1)
- (i32.const 0)
)
(i32.const 0)
)
)
- (func $_memchr (; 40 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memchr (; 40 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (local $2 i32)
(local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (set_local $5
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
(block $label$break$L8
(block $__rjti$2
(if
(i32.and
- (tee_local $4
+ (tee_local $3
(i32.ne
- (get_local $2)
+ (get_local $1)
(i32.const 0)
)
)
@@ -1776,27 +1765,17 @@
)
)
(block
- (set_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
- (set_local $3
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(loop $while-in
(br_if $__rjti$2
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
- (get_local $4)
- (i32.const 255)
+ (get_local $1)
)
)
)
@@ -1804,9 +1783,9 @@
(i32.and
(tee_local $0
(i32.ne
- (tee_local $3
+ (tee_local $2
(i32.add
- (get_local $3)
+ (get_local $2)
(i32.const -1)
)
)
@@ -1815,9 +1794,9 @@
)
(i32.ne
(i32.and
- (tee_local $2
+ (tee_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -1830,14 +1809,14 @@
)
)
(block
- (set_local $3
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(set_local $0
- (get_local $4)
+ (get_local $3)
)
)
)
@@ -1850,27 +1829,13 @@
(br $label$break$L8)
)
(set_local $0
- (get_local $3)
+ (get_local $2)
)
(if
- (i32.ne
- (i32.load8_u
- (get_local $2)
- )
- (tee_local $1
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (i32.load8_u
+ (get_local $1)
)
(block
- (set_local $3
- (i32.mul
- (get_local $5)
- (i32.const 16843009)
- )
- )
(block $__rjto$0
(block $__rjti$0
(br_if $__rjti$0
@@ -1885,12 +1850,9 @@
(i32.and
(i32.xor
(i32.and
- (tee_local $4
- (i32.xor
- (i32.load
- (get_local $2)
- )
- (get_local $3)
+ (tee_local $3
+ (i32.load
+ (get_local $1)
)
)
(i32.const -2139062144)
@@ -1898,15 +1860,15 @@
(i32.const -2139062144)
)
(i32.add
- (get_local $4)
+ (get_local $3)
(i32.const -16843009)
)
)
)
(block
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 4)
)
)
@@ -1941,19 +1903,15 @@
)
(loop $while-in5
(br_if $label$break$L8
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
(get_local $1)
- (i32.const 255)
)
)
)
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -1973,7 +1931,7 @@
)
)
(select
- (get_local $2)
+ (get_local $1)
(i32.const 0)
(get_local $0)
)
@@ -4589,7 +4547,6 @@
(get_global $tempRet0)
)
(i32.const 1000000000)
- (i32.const 0)
)
)
(set_local $12
@@ -4597,7 +4554,6 @@
(get_local $12)
(get_local $18)
(i32.const 1000000000)
- (i32.const 0)
)
)
(br_if $while-in66
@@ -6532,7 +6488,6 @@
(tee_local $13
(call $_memchr
(get_local $7)
- (i32.const 0)
(get_local $6)
)
)
@@ -7474,7 +7429,6 @@
(get_local $0)
(get_local $1)
(i32.const 10)
- (i32.const 0)
)
)
(i32.const 48)
@@ -7485,7 +7439,6 @@
(get_local $0)
(get_local $1)
(i32.const 10)
- (i32.const 0)
)
)
(set_local $4
@@ -15360,18 +15313,18 @@
)
(get_local $3)
)
- (func $___udivdi3 (; 62 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $___udivdi3 (; 62 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $___udivmoddi4
(get_local $0)
(get_local $1)
(get_local $2)
- (get_local $3)
+ (i32.const 0)
(i32.const 0)
)
)
- (func $___uremdi3 (; 63 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
- (local $4 i32)
- (set_local $4
+ (func $___uremdi3 (; 63 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
+ (set_local $3
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -15385,20 +15338,20 @@
(get_local $0)
(get_local $1)
(get_local $2)
+ (i32.const 0)
(get_local $3)
- (get_local $4)
)
)
(set_global $STACKTOP
- (get_local $4)
+ (get_local $3)
)
(set_global $tempRet0
(i32.load offset=4
- (get_local $4)
+ (get_local $3)
)
)
(i32.load
- (get_local $4)
+ (get_local $3)
)
)
(func $___udivmoddi4 (; 64 ;) (; has Stack IR ;) (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (param $r i32) (result i32)
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 25ca0c3da..46a1c48c4 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -148,7 +148,6 @@
)
(drop
(call $_printf
- (i32.const 672)
(get_local $0)
)
)
@@ -568,10 +567,8 @@
)
)
(set_local $0
- (tee_local $1
- (call $___fflush_unlocked
- (get_local $0)
- )
+ (call $___fflush_unlocked
+ (get_local $0)
)
)
)
@@ -634,9 +631,9 @@
)
(get_local $0)
)
- (func $_printf (; 33 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
- (local $2 i32)
- (set_local $2
+ (func $_printf (; 33 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (local $1 i32)
+ (set_local $1
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -653,20 +650,20 @@
(call $abort)
)
(i32.store
- (get_local $2)
(get_local $1)
+ (get_local $0)
)
(set_local $0
(call $_vfprintf
(i32.load
(i32.const 8)
)
- (get_local $0)
- (get_local $2)
+ (i32.const 672)
+ (get_local $1)
)
)
(set_global $STACKTOP
- (get_local $2)
+ (get_local $1)
)
(get_local $0)
)
@@ -1027,7 +1024,6 @@
(local $11 i32)
(local $12 i32)
(local $13 i32)
- (local $14 i32)
(set_local $4
(get_global $STACKTOP)
)
@@ -1551,7 +1547,7 @@
)
)
)
- (func $_wcrtomb (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_wcrtomb (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
(block $do-once (result i32)
(if (result i32)
(get_local $0)
@@ -1731,28 +1727,20 @@
(call $_wcrtomb
(get_local $0)
(get_local $1)
- (i32.const 0)
)
(i32.const 0)
)
)
- (func $_memchr (; 40 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $_memchr (; 40 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (local $2 i32)
(local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (set_local $5
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
(block $label$break$L8
(block $__rjti$2
(if
(i32.and
- (tee_local $4
+ (tee_local $3
(i32.ne
- (get_local $2)
+ (get_local $1)
(i32.const 0)
)
)
@@ -1765,27 +1753,17 @@
)
)
(block
- (set_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
- (set_local $3
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(loop $while-in
(br_if $__rjti$2
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
- (get_local $4)
- (i32.const 255)
+ (get_local $1)
)
)
)
@@ -1793,9 +1771,9 @@
(i32.and
(tee_local $0
(i32.ne
- (tee_local $3
+ (tee_local $2
(i32.add
- (get_local $3)
+ (get_local $2)
(i32.const -1)
)
)
@@ -1804,9 +1782,9 @@
)
(i32.ne
(i32.and
- (tee_local $2
+ (tee_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -1819,14 +1797,14 @@
)
)
(block
- (set_local $3
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(set_local $0
- (get_local $4)
+ (get_local $3)
)
)
)
@@ -1839,27 +1817,13 @@
(br $label$break$L8)
)
(set_local $0
- (get_local $3)
+ (get_local $2)
)
(if
- (i32.ne
- (i32.load8_u
- (get_local $2)
- )
- (tee_local $1
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (i32.load8_u
+ (get_local $1)
)
(block
- (set_local $3
- (i32.mul
- (get_local $5)
- (i32.const 16843009)
- )
- )
(block $__rjto$0
(block $__rjti$0
(br_if $__rjti$0
@@ -1874,12 +1838,9 @@
(i32.and
(i32.xor
(i32.and
- (tee_local $4
- (i32.xor
- (i32.load
- (get_local $2)
- )
- (get_local $3)
+ (tee_local $3
+ (i32.load
+ (get_local $1)
)
)
(i32.const -2139062144)
@@ -1887,15 +1848,15 @@
(i32.const -2139062144)
)
(i32.add
- (get_local $4)
+ (get_local $3)
(i32.const -16843009)
)
)
)
(block
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 4)
)
)
@@ -1930,19 +1891,15 @@
)
(loop $while-in5
(br_if $label$break$L8
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
(get_local $1)
- (i32.const 255)
)
)
)
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -1962,7 +1919,7 @@
)
)
(select
- (get_local $2)
+ (get_local $1)
(i32.const 0)
(get_local $0)
)
@@ -4460,7 +4417,6 @@
(get_global $tempRet0)
)
(i32.const 1000000000)
- (i32.const 0)
)
)
(set_local $12
@@ -4468,7 +4424,6 @@
(get_local $12)
(get_local $18)
(i32.const 1000000000)
- (i32.const 0)
)
)
(br_if $while-in66
@@ -6397,7 +6352,6 @@
(tee_local $13
(call $_memchr
(get_local $7)
- (i32.const 0)
(get_local $6)
)
)
@@ -7339,7 +7293,6 @@
(get_local $0)
(get_local $1)
(i32.const 10)
- (i32.const 0)
)
)
(i32.const 48)
@@ -7350,7 +7303,6 @@
(get_local $0)
(get_local $1)
(i32.const 10)
- (i32.const 0)
)
)
(set_local $4
@@ -15224,18 +15176,18 @@
)
(get_local $3)
)
- (func $___udivdi3 (; 57 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $___udivdi3 (; 57 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $___udivmoddi4
(get_local $0)
(get_local $1)
(get_local $2)
- (get_local $3)
+ (i32.const 0)
(i32.const 0)
)
)
- (func $___uremdi3 (; 58 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
- (local $4 i32)
- (set_local $4
+ (func $___uremdi3 (; 58 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
+ (set_local $3
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -15249,20 +15201,20 @@
(get_local $0)
(get_local $1)
(get_local $2)
+ (i32.const 0)
(get_local $3)
- (get_local $4)
)
)
(set_global $STACKTOP
- (get_local $4)
+ (get_local $3)
)
(set_global $tempRet0
(i32.load offset=4
- (get_local $4)
+ (get_local $3)
)
)
(i32.load
- (get_local $4)
+ (get_local $3)
)
)
(func $___udivmoddi4 (; 59 ;) (; has Stack IR ;) (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (param $r i32) (result i32)
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index 5afec926b..8c400ab68 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -8532,16 +8532,15 @@
)
)
)
- (func $ab (; 19 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $ab (; 19 ;) (; has Stack IR ;) (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)
- (set_local $5
+ (set_local $4
(get_global $r)
)
(set_global $r
@@ -8551,20 +8550,15 @@
)
)
(i32.store8
- (tee_local $6
- (get_local $5)
- )
- (tee_local $9
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $5
+ (get_local $4)
)
+ (i32.const 10)
)
(if
- (tee_local $3
+ (tee_local $2
(i32.load
- (tee_local $2
+ (tee_local $1
(i32.add
(get_local $0)
(i32.const 16)
@@ -8573,10 +8567,10 @@
)
)
(block
- (set_local $7
- (get_local $3)
+ (set_local $6
+ (get_local $2)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8584,16 +8578,16 @@
(call $Xa
(get_local $0)
)
- (set_local $4
+ (set_local $3
(i32.const -1)
)
(block
- (set_local $7
+ (set_local $6
(i32.load
- (get_local $2)
+ (get_local $1)
)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8602,15 +8596,15 @@
(block $do-once
(if
(i32.eq
- (get_local $8)
+ (get_local $7)
(i32.const 4)
)
(block
(if
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $0)
(i32.const 20)
@@ -8618,15 +8612,12 @@
)
)
)
- (get_local $7)
+ (get_local $6)
)
(if
(i32.ne
- (tee_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $3
+ (i32.const 10)
)
(i32.load8_s offset=75
(get_local $0)
@@ -8634,26 +8625,26 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
- (get_local $9)
+ (get_local $1)
+ (i32.const 10)
)
(br $do-once)
)
)
)
- (set_local $4
+ (set_local $3
(if (result i32)
(i32.eq
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
- (get_local $6)
+ (get_local $5)
(i32.const 1)
(i32.add
(i32.and
@@ -8668,7 +8659,7 @@
(i32.const 1)
)
(i32.load8_u
- (get_local $6)
+ (get_local $5)
)
(i32.const -1)
)
@@ -8677,9 +8668,9 @@
)
)
(set_global $r
- (get_local $5)
+ (get_local $4)
)
- (get_local $4)
+ (get_local $3)
)
(func $$a (; 20 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
@@ -9104,12 +9095,13 @@
(get_local $2)
)
)
- (func $db (; 24 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (func $db (; 24 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
(local $2 i32)
(drop
(i32.load offset=76
- (tee_local $1
+ (tee_local $0
(i32.load
(i32.const 1024)
)
@@ -9118,18 +9110,17 @@
)
(i32.shr_s
(i32.shl
- (tee_local $0
+ (tee_local $1
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
(i32.add
(call $bb
- (get_local $0)
+ (i32.const 1144)
(call $Za
- (get_local $0)
+ (i32.const 1144)
)
- (i32.const 1)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
)
@@ -9140,36 +9131,36 @@
(if
(i32.ne
(i32.load8_s offset=75
- (get_local $1)
+ (get_local $0)
)
(i32.const 10)
)
(if
(i32.lt_u
- (tee_local $0
+ (tee_local $1
(i32.load
(tee_local $2
(i32.add
- (get_local $1)
+ (get_local $0)
(i32.const 20)
)
)
)
)
(i32.load offset=16
- (get_local $1)
+ (get_local $0)
)
)
(block
(i32.store
(get_local $2)
(i32.add
- (get_local $0)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $0)
+ (get_local $1)
(i32.const 10)
)
(br $do-once
@@ -9180,8 +9171,7 @@
)
(i32.lt_s
(call $ab
- (get_local $1)
- (i32.const 10)
+ (get_local $0)
)
(i32.const 0)
)
@@ -9272,33 +9262,34 @@
)
)
)
- (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
(local $4 i32)
(set_local $4
- (i32.mul
- (get_local $2)
- (get_local $1)
- )
+ (i32.const 1)
+ )
+ (set_local $3
+ (get_local $1)
)
(if
(block (result i32)
(drop
(i32.load offset=76
- (get_local $3)
+ (get_local $2)
)
)
(i32.ne
(tee_local $0
(call $Wa
(get_local $0)
- (get_local $4)
(get_local $3)
+ (get_local $2)
)
)
- (get_local $4)
+ (get_local $3)
)
)
- (set_local $2
+ (set_local $4
(if (result i32)
(get_local $1)
(i32.div_u
@@ -9309,7 +9300,7 @@
)
)
)
- (get_local $2)
+ (get_local $4)
)
(func $Ua (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@@ -9611,9 +9602,7 @@
)
(func $Na (; 41 ;) (; has Stack IR ;) (result i32)
(drop
- (call $db
- (i32.const 1144)
- )
+ (call $db)
)
(i32.const 0)
)
diff --git a/test/memorygrowth.fromasm.clamp b/test/memorygrowth.fromasm.clamp
index 5afec926b..8c400ab68 100644
--- a/test/memorygrowth.fromasm.clamp
+++ b/test/memorygrowth.fromasm.clamp
@@ -8532,16 +8532,15 @@
)
)
)
- (func $ab (; 19 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $ab (; 19 ;) (; has Stack IR ;) (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)
- (set_local $5
+ (set_local $4
(get_global $r)
)
(set_global $r
@@ -8551,20 +8550,15 @@
)
)
(i32.store8
- (tee_local $6
- (get_local $5)
- )
- (tee_local $9
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $5
+ (get_local $4)
)
+ (i32.const 10)
)
(if
- (tee_local $3
+ (tee_local $2
(i32.load
- (tee_local $2
+ (tee_local $1
(i32.add
(get_local $0)
(i32.const 16)
@@ -8573,10 +8567,10 @@
)
)
(block
- (set_local $7
- (get_local $3)
+ (set_local $6
+ (get_local $2)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8584,16 +8578,16 @@
(call $Xa
(get_local $0)
)
- (set_local $4
+ (set_local $3
(i32.const -1)
)
(block
- (set_local $7
+ (set_local $6
(i32.load
- (get_local $2)
+ (get_local $1)
)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8602,15 +8596,15 @@
(block $do-once
(if
(i32.eq
- (get_local $8)
+ (get_local $7)
(i32.const 4)
)
(block
(if
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $0)
(i32.const 20)
@@ -8618,15 +8612,12 @@
)
)
)
- (get_local $7)
+ (get_local $6)
)
(if
(i32.ne
- (tee_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $3
+ (i32.const 10)
)
(i32.load8_s offset=75
(get_local $0)
@@ -8634,26 +8625,26 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
- (get_local $9)
+ (get_local $1)
+ (i32.const 10)
)
(br $do-once)
)
)
)
- (set_local $4
+ (set_local $3
(if (result i32)
(i32.eq
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
- (get_local $6)
+ (get_local $5)
(i32.const 1)
(i32.add
(i32.and
@@ -8668,7 +8659,7 @@
(i32.const 1)
)
(i32.load8_u
- (get_local $6)
+ (get_local $5)
)
(i32.const -1)
)
@@ -8677,9 +8668,9 @@
)
)
(set_global $r
- (get_local $5)
+ (get_local $4)
)
- (get_local $4)
+ (get_local $3)
)
(func $$a (; 20 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
@@ -9104,12 +9095,13 @@
(get_local $2)
)
)
- (func $db (; 24 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (func $db (; 24 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
(local $2 i32)
(drop
(i32.load offset=76
- (tee_local $1
+ (tee_local $0
(i32.load
(i32.const 1024)
)
@@ -9118,18 +9110,17 @@
)
(i32.shr_s
(i32.shl
- (tee_local $0
+ (tee_local $1
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
(i32.add
(call $bb
- (get_local $0)
+ (i32.const 1144)
(call $Za
- (get_local $0)
+ (i32.const 1144)
)
- (i32.const 1)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
)
@@ -9140,36 +9131,36 @@
(if
(i32.ne
(i32.load8_s offset=75
- (get_local $1)
+ (get_local $0)
)
(i32.const 10)
)
(if
(i32.lt_u
- (tee_local $0
+ (tee_local $1
(i32.load
(tee_local $2
(i32.add
- (get_local $1)
+ (get_local $0)
(i32.const 20)
)
)
)
)
(i32.load offset=16
- (get_local $1)
+ (get_local $0)
)
)
(block
(i32.store
(get_local $2)
(i32.add
- (get_local $0)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $0)
+ (get_local $1)
(i32.const 10)
)
(br $do-once
@@ -9180,8 +9171,7 @@
)
(i32.lt_s
(call $ab
- (get_local $1)
- (i32.const 10)
+ (get_local $0)
)
(i32.const 0)
)
@@ -9272,33 +9262,34 @@
)
)
)
- (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
(local $4 i32)
(set_local $4
- (i32.mul
- (get_local $2)
- (get_local $1)
- )
+ (i32.const 1)
+ )
+ (set_local $3
+ (get_local $1)
)
(if
(block (result i32)
(drop
(i32.load offset=76
- (get_local $3)
+ (get_local $2)
)
)
(i32.ne
(tee_local $0
(call $Wa
(get_local $0)
- (get_local $4)
(get_local $3)
+ (get_local $2)
)
)
- (get_local $4)
+ (get_local $3)
)
)
- (set_local $2
+ (set_local $4
(if (result i32)
(get_local $1)
(i32.div_u
@@ -9309,7 +9300,7 @@
)
)
)
- (get_local $2)
+ (get_local $4)
)
(func $Ua (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@@ -9611,9 +9602,7 @@
)
(func $Na (; 41 ;) (; has Stack IR ;) (result i32)
(drop
- (call $db
- (i32.const 1144)
- )
+ (call $db)
)
(i32.const 0)
)
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index c71b3b697..4f52c23de 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -8429,7 +8429,7 @@
(func $_a (; 18 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
- (tee_local $1
+ (tee_local $2
(block $do-once (result i32)
(if (result i32)
(get_local $0)
@@ -8469,16 +8469,16 @@
(i32.const 1188)
)
(if
- (tee_local $2
+ (tee_local $1
(i32.load
(i32.const 1184)
)
)
(block
- (set_local $1
- (get_local $2)
- )
(set_local $2
+ (get_local $1)
+ )
+ (set_local $1
(get_local $0)
)
(loop $while-in
@@ -8488,53 +8488,52 @@
(if
(i32.gt_u
(i32.load offset=20
- (get_local $1)
+ (get_local $2)
)
(i32.load offset=28
- (get_local $1)
+ (get_local $2)
)
)
- (set_local $2
+ (set_local $1
(i32.or
(call $$a
- (get_local $1)
+ (get_local $2)
)
- (get_local $2)
+ (get_local $1)
)
)
)
(br_if $while-in
- (tee_local $1
+ (tee_local $2
(i32.load offset=56
- (get_local $1)
+ (get_local $2)
)
)
)
)
)
- (set_local $2
+ (set_local $1
(get_local $0)
)
)
(call $xa
(i32.const 1188)
)
- (get_local $2)
+ (get_local $1)
)
)
)
)
)
- (func $ab (; 19 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
+ (func $ab (; 19 ;) (; has Stack IR ;) (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)
- (set_local $5
+ (set_local $4
(get_global $r)
)
(set_global $r
@@ -8544,20 +8543,15 @@
)
)
(i32.store8
- (tee_local $6
- (get_local $5)
- )
- (tee_local $9
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $5
+ (get_local $4)
)
+ (i32.const 10)
)
(if
- (tee_local $3
+ (tee_local $2
(i32.load
- (tee_local $2
+ (tee_local $1
(i32.add
(get_local $0)
(i32.const 16)
@@ -8566,10 +8560,10 @@
)
)
(block
- (set_local $7
- (get_local $3)
+ (set_local $6
+ (get_local $2)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8577,16 +8571,16 @@
(call $Xa
(get_local $0)
)
- (set_local $4
+ (set_local $3
(i32.const -1)
)
(block
- (set_local $7
+ (set_local $6
(i32.load
- (get_local $2)
+ (get_local $1)
)
)
- (set_local $8
+ (set_local $7
(i32.const 4)
)
)
@@ -8595,15 +8589,15 @@
(block $do-once
(if
(i32.eq
- (get_local $8)
+ (get_local $7)
(i32.const 4)
)
(block
(if
(i32.lt_u
- (tee_local $2
+ (tee_local $1
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $0)
(i32.const 20)
@@ -8611,15 +8605,12 @@
)
)
)
- (get_local $7)
+ (get_local $6)
)
(if
(i32.ne
- (tee_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
+ (tee_local $3
+ (i32.const 10)
)
(i32.load8_s offset=75
(get_local $0)
@@ -8627,26 +8618,26 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $2)
- (get_local $9)
+ (get_local $1)
+ (i32.const 10)
)
(br $do-once)
)
)
)
- (set_local $4
+ (set_local $3
(if (result i32)
(i32.eq
(call_indirect (type $FUNCSIG$iiii)
(get_local $0)
- (get_local $6)
+ (get_local $5)
(i32.const 1)
(i32.add
(i32.and
@@ -8661,7 +8652,7 @@
(i32.const 1)
)
(i32.load8_u
- (get_local $6)
+ (get_local $5)
)
(i32.const -1)
)
@@ -8670,9 +8661,9 @@
)
)
(set_global $r
- (get_local $5)
+ (get_local $4)
)
- (get_local $4)
+ (get_local $3)
)
(func $$a (; 20 ;) (; has Stack IR ;) (param $0 i32) (result i32)
(local $1 i32)
@@ -9097,12 +9088,13 @@
(get_local $2)
)
)
- (func $db (; 24 ;) (; has Stack IR ;) (param $0 i32) (result i32)
+ (func $db (; 24 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
(local $2 i32)
(drop
(i32.load offset=76
- (tee_local $1
+ (tee_local $0
(i32.load
(i32.const 1024)
)
@@ -9111,18 +9103,17 @@
)
(i32.shr_s
(i32.shl
- (tee_local $0
+ (tee_local $1
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
(i32.add
(call $bb
- (get_local $0)
+ (i32.const 1144)
(call $Za
- (get_local $0)
+ (i32.const 1144)
)
- (i32.const 1)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
)
@@ -9133,36 +9124,36 @@
(if
(i32.ne
(i32.load8_s offset=75
- (get_local $1)
+ (get_local $0)
)
(i32.const 10)
)
(if
(i32.lt_u
- (tee_local $0
+ (tee_local $1
(i32.load
(tee_local $2
(i32.add
- (get_local $1)
+ (get_local $0)
(i32.const 20)
)
)
)
)
(i32.load offset=16
- (get_local $1)
+ (get_local $0)
)
)
(block
(i32.store
(get_local $2)
(i32.add
- (get_local $0)
+ (get_local $1)
(i32.const 1)
)
)
(i32.store8
- (get_local $0)
+ (get_local $1)
(i32.const 10)
)
(br $do-once
@@ -9173,8 +9164,7 @@
)
(i32.lt_s
(call $ab
- (get_local $1)
- (i32.const 10)
+ (get_local $0)
)
(i32.const 0)
)
@@ -9265,33 +9255,34 @@
)
)
)
- (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
+ (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (local $3 i32)
(local $4 i32)
(set_local $4
- (i32.mul
- (get_local $2)
- (get_local $1)
- )
+ (i32.const 1)
+ )
+ (set_local $3
+ (get_local $1)
)
(if
(i32.ne
(tee_local $0
(call $Wa
(get_local $0)
- (get_local $4)
(get_local $3)
+ (get_local $2)
)
)
- (get_local $4)
+ (get_local $3)
)
- (set_local $2
+ (set_local $4
(i32.div_u
(get_local $0)
(get_local $1)
)
)
)
- (get_local $2)
+ (get_local $4)
)
(func $Ua (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@@ -9589,9 +9580,7 @@
)
(func $Na (; 41 ;) (; has Stack IR ;) (result i32)
(drop
- (call $db
- (i32.const 1144)
- )
+ (call $db)
)
(i32.const 0)
)
diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt
index a272a6288..637a9522f 100644
--- a/test/passes/converge_O3_metrics.bin.txt
+++ b/test/passes/converge_O3_metrics.bin.txt
@@ -1,30 +1,29 @@
total
- [funcs] : 9
+ [funcs] : 8
[memory-data] : 28
[table-data] : 429
- [total] : 136
+ [total] : 132
[vars] : 4
binary : 12
- block : 9
+ block : 8
break : 3
- call : 3
+ call : 2
call_import : 1
call_indirect : 4
- const : 48
+ const : 47
drop : 3
get_global : 1
- get_local : 20
+ get_local : 18
if : 3
load : 16
loop : 1
set_global : 1
- set_local : 6
+ set_local : 7
store : 5
(module
(type $0 (func (param i32 i32) (result i32)))
(type $1 (func (param i32 i32 i32) (result i32)))
(type $2 (func (param i32) (result i32)))
- (type $3 (func (param i32)))
(type $6 (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
(type $7 (func (result i32)))
(import "env" "memory" (memory $0 256 256))
@@ -48,30 +47,30 @@ total
(func $_malloc (; 2 ;) (; has Stack IR ;) (type $2) (param $0 i32) (result i32)
(i32.const 0)
)
- (func $___stdio_write (; 3 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $___stdio_write (; 3 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32)
(i32.store
(i32.const 8)
- (get_local $1)
+ (get_local $0)
)
(i32.store
(i32.const 12)
- (get_local $2)
+ (get_local $1)
)
(i32.store
- (tee_local $1
+ (tee_local $0
(get_global $global$0)
)
(i32.const 1)
)
(i32.store offset=8
- (get_local $1)
+ (get_local $0)
(i32.const 2)
)
(drop
(if (result i32)
(call $import$0
(i32.const 146)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
(i32.const 0)
@@ -81,45 +80,6 @@ total
)
(func $_main (; 4 ;) (; has Stack IR ;) (type $7) (result i32)
(local $0 i32)
- (call $__ZNSt3__224__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_j
- (block (result i32)
- (set_local $0
- (i32.const 10888)
- )
- (loop $label$3
- (br_if $label$3
- (i32.load8_s
- (tee_local $0
- (i32.add
- (get_local $0)
- (i32.const 1)
- )
- )
- )
- )
- )
- (i32.sub
- (get_local $0)
- (i32.const 10888)
- )
- )
- )
- (call $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc
- (i32.const 10)
- )
- (i32.const 0)
- )
- (func $___stdout_write (; 5 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
- (set_global $global$0
- (i32.const 32)
- )
- (call $___stdio_write
- (i32.const 1)
- (get_local $1)
- (get_local $2)
- )
- )
- (func $__ZNSt3__224__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_j (; 6 ;) (; has Stack IR ;) (type $3) (param $0 i32)
(local $1 i32)
(set_local $1
(i32.load offset=24
@@ -138,7 +98,29 @@ total
)
(block $label$2
(if
- (get_local $0)
+ (block (result i32)
+ (set_local $0
+ (i32.const 10888)
+ )
+ (loop $label$3
+ (br_if $label$3
+ (i32.load8_s
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ )
+ (tee_local $0
+ (i32.sub
+ (get_local $0)
+ (i32.const 10888)
+ )
+ )
+ )
(br_if $label$2
(call_indirect (type $1)
(get_local $1)
@@ -156,17 +138,28 @@ total
)
)
)
+ (call $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc)
+ (i32.const 0)
+ )
+ (func $___stdout_write (; 5 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (set_global $global$0
+ (i32.const 32)
+ )
+ (call $___stdio_write
+ (get_local $1)
+ (get_local $2)
+ )
)
- (func $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc (; 7 ;) (; has Stack IR ;) (type $3) (param $0 i32)
+ (func $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc (; 6 ;) (; has Stack IR ;)
+ (local $0 i32)
(local $1 i32)
- (local $2 i32)
(block $label$1
(br_if $label$1
(if (result i32)
(i32.load
(i32.add
- (tee_local $2
- (tee_local $1
+ (tee_local $1
+ (tee_local $0
(i32.load
(i32.add
(i32.load
@@ -187,12 +180,12 @@ total
)
(i32.const 0)
(call_indirect (type $0)
- (get_local $2)
- (get_local $0)
+ (get_local $1)
+ (i32.const 10)
(i32.add
(i32.load offset=52
(i32.load
- (get_local $1)
+ (get_local $0)
)
)
(i32.const 422)
@@ -202,7 +195,7 @@ total
)
)
)
- (func $__ZNSt3__211__stdoutbufIcE8overflowEi (; 8 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
+ (func $__ZNSt3__211__stdoutbufIcE8overflowEi (; 7 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
(i32.store8
(i32.const 0)
(get_local $1)
@@ -227,7 +220,7 @@ total
)
(i32.const 0)
)
- (func $__ZNSt3__211__stdoutbufIcE6xsputnEPKci (; 9 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $__ZNSt3__211__stdoutbufIcE6xsputnEPKci (; 8 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(drop
(call_indirect (type $1)
(i32.const 0)
@@ -247,34 +240,34 @@ total
)
)
total
- [funcs] : 9
+ [funcs] : 8
[memory-data] : 28
[table-data] : 429
- [total] : 136
+ [total] : 132
[vars] : 4
binary : 12
- block : 9
+ block : 8
break : 3
- call : 3
+ call : 2
call_import : 1
call_indirect : 4
- const : 48
+ const : 47
drop : 3
get_global : 1
- get_local : 20
+ get_local : 18
if : 3
load : 16
loop : 1
set_global : 1
- set_local : 6
+ set_local : 7
store : 5
(module
(type $0 (func (param i32 i32) (result i32)))
(type $1 (func (param i32 i32 i32) (result i32)))
(type $2 (func (param i32) (result i32)))
- (type $3 (func (param i32)))
(type $6 (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
(type $7 (func (result i32)))
+ (type $FUNCSIG$v (func))
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 478 478 anyfunc))
(import "env" "___syscall146" (func $import$0 (param i32 i32) (result i32)))
@@ -296,30 +289,30 @@ total
(func $_malloc (; 2 ;) (; has Stack IR ;) (type $2) (param $0 i32) (result i32)
(i32.const 0)
)
- (func $___stdio_write (; 3 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $___stdio_write (; 3 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
(i32.store
(i32.const 8)
- (get_local $1)
+ (get_local $0)
)
(i32.store
(i32.const 12)
- (get_local $2)
+ (get_local $1)
)
(i32.store
- (tee_local $1
+ (tee_local $0
(get_global $global$0)
)
(i32.const 1)
)
(i32.store offset=8
- (get_local $1)
+ (get_local $0)
(i32.const 2)
)
(drop
(if (result i32)
(call $import$0
(i32.const 146)
- (get_local $1)
+ (get_local $0)
)
(i32.const -1)
(i32.const 0)
@@ -329,32 +322,65 @@ total
)
(func $_main (; 4 ;) (; has Stack IR ;) (type $7) (result i32)
(local $0 i32)
- (call $__ZNSt3__224__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_j
- (block (result i32)
- (set_local $0
- (i32.const 10888)
+ (local $1 i32)
+ (set_local $1
+ (i32.load offset=24
+ (i32.add
+ (i32.load
+ (i32.add
+ (i32.load
+ (i32.const 18100)
+ )
+ (i32.const -12)
+ )
+ )
+ (i32.const 18100)
)
- (loop $label$3
- (br_if $label$3
- (i32.load8_s
- (tee_local $0
- (i32.add
- (get_local $0)
- (i32.const 1)
+ )
+ )
+ (block $label$2
+ (if
+ (block (result i32)
+ (set_local $0
+ (i32.const 10888)
+ )
+ (loop $label$3
+ (br_if $label$3
+ (i32.load8_s
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (i32.const 1)
+ )
)
)
)
)
+ (tee_local $0
+ (i32.sub
+ (get_local $0)
+ (i32.const 10888)
+ )
+ )
)
- (i32.sub
- (get_local $0)
- (i32.const 10888)
+ (br_if $label$2
+ (call_indirect (type $1)
+ (get_local $1)
+ (i32.const 10888)
+ (get_local $0)
+ (i32.add
+ (i32.load offset=48
+ (i32.load
+ (get_local $1)
+ )
+ )
+ (i32.const 8)
+ )
+ )
)
)
)
- (call $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc
- (i32.const 10)
- )
+ (call $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc)
(i32.const 0)
)
(func $___stdout_write (; 5 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
@@ -362,12 +388,182 @@ total
(i32.const 32)
)
(call $___stdio_write
- (i32.const 1)
(get_local $1)
(get_local $2)
)
)
- (func $__ZNSt3__224__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_j (; 6 ;) (; has Stack IR ;) (type $3) (param $0 i32)
+ (func $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc (; 6 ;) (; has Stack IR ;) (type $FUNCSIG$v)
+ (local $0 i32)
+ (local $1 i32)
+ (block $label$1
+ (br_if $label$1
+ (if (result i32)
+ (i32.load
+ (i32.add
+ (tee_local $1
+ (tee_local $0
+ (i32.load
+ (i32.add
+ (i32.load
+ (i32.add
+ (i32.load
+ (i32.const 18100)
+ )
+ (i32.const -12)
+ )
+ )
+ (i32.const 18124)
+ )
+ )
+ )
+ )
+ (i32.const 24)
+ )
+ )
+ (i32.const 0)
+ (call_indirect (type $0)
+ (get_local $1)
+ (i32.const 10)
+ (i32.add
+ (i32.load offset=52
+ (i32.load
+ (get_local $0)
+ )
+ )
+ (i32.const 422)
+ )
+ )
+ )
+ )
+ )
+ )
+ (func $__ZNSt3__211__stdoutbufIcE8overflowEi (; 7 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
+ (i32.store8
+ (i32.const 0)
+ (get_local $1)
+ )
+ (drop
+ (call_indirect (type $1)
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 1)
+ (i32.add
+ (i32.load offset=36
+ (i32.load
+ (i32.add
+ (get_local $0)
+ (i32.const 32)
+ )
+ )
+ )
+ (i32.const 8)
+ )
+ )
+ )
+ (i32.const 0)
+ )
+ (func $__ZNSt3__211__stdoutbufIcE6xsputnEPKci (; 8 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (drop
+ (call_indirect (type $1)
+ (i32.const 0)
+ (get_local $1)
+ (get_local $2)
+ (i32.add
+ (i32.load offset=36
+ (i32.load offset=32
+ (get_local $0)
+ )
+ )
+ (i32.const 8)
+ )
+ )
+ )
+ (i32.const 0)
+ )
+)
+total
+ [funcs] : 8
+ [memory-data] : 28
+ [table-data] : 429
+ [total] : 132
+ [vars] : 4
+ binary : 12
+ block : 8
+ break : 3
+ call : 2
+ call_import : 1
+ call_indirect : 4
+ const : 47
+ drop : 3
+ get_global : 1
+ get_local : 18
+ if : 3
+ load : 16
+ loop : 1
+ set_global : 1
+ set_local : 7
+ store : 5
+(module
+ (type $0 (func (param i32 i32) (result i32)))
+ (type $1 (func (param i32 i32 i32) (result i32)))
+ (type $2 (func (param i32) (result i32)))
+ (type $6 (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
+ (type $7 (func (result i32)))
+ (type $FUNCSIG$v (func))
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 478 478 anyfunc))
+ (import "env" "___syscall146" (func $import$0 (param i32 i32) (result i32)))
+ (global $global$0 (mut i32) (i32.const 1))
+ (elem (i32.const 0) $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $___stdout_write $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $__ZNSt3__211__stdoutbufIcE6xsputnEPKci $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $__ZNSt3__211__stdoutbufIcE8overflowEi)
+ (data (i32.const 2948) "\03")
+ (data (i32.const 6828) "\04")
+ (data (i32.const 7028) "\0d\00\00\00\06")
+ (data (i32.const 10888) "hello, world!")
+ (data (i32.const 18100) "\b8\1a")
+ (data (i32.const 18128) ",I")
+ (data (i32.const 18732) "D\1b")
+ (data (i32.const 18764) "`\0b")
+ (export "_main" (func $_main))
+ (export "_malloc" (func $_malloc))
+ (func $b0 (; 1 ;) (; has Stack IR ;) (type $6) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) (param $6 i32) (result i32)
+ (i32.const 0)
+ )
+ (func $_malloc (; 2 ;) (; has Stack IR ;) (type $2) (param $0 i32) (result i32)
+ (i32.const 0)
+ )
+ (func $___stdio_write (; 3 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
+ (i32.store
+ (i32.const 8)
+ (get_local $0)
+ )
+ (i32.store
+ (i32.const 12)
+ (get_local $1)
+ )
+ (i32.store
+ (tee_local $0
+ (get_global $global$0)
+ )
+ (i32.const 1)
+ )
+ (i32.store offset=8
+ (get_local $0)
+ (i32.const 2)
+ )
+ (drop
+ (if (result i32)
+ (call $import$0
+ (i32.const 146)
+ (get_local $0)
+ )
+ (i32.const -1)
+ (i32.const 0)
+ )
+ )
+ (i32.const 1)
+ )
+ (func $_main (; 4 ;) (; has Stack IR ;) (type $7) (result i32)
+ (local $0 i32)
(local $1 i32)
(set_local $1
(i32.load offset=24
@@ -386,7 +582,29 @@ total
)
(block $label$2
(if
- (get_local $0)
+ (block (result i32)
+ (set_local $0
+ (i32.const 10888)
+ )
+ (loop $label$3
+ (br_if $label$3
+ (i32.load8_s
+ (tee_local $0
+ (i32.add
+ (get_local $0)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ )
+ (tee_local $0
+ (i32.sub
+ (get_local $0)
+ (i32.const 10888)
+ )
+ )
+ )
(br_if $label$2
(call_indirect (type $1)
(get_local $1)
@@ -404,17 +622,28 @@ total
)
)
)
+ (call $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc)
+ (i32.const 0)
)
- (func $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc (; 7 ;) (; has Stack IR ;) (type $3) (param $0 i32)
+ (func $___stdout_write (; 5 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (set_global $global$0
+ (i32.const 32)
+ )
+ (call $___stdio_write
+ (get_local $1)
+ (get_local $2)
+ )
+ )
+ (func $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc (; 6 ;) (; has Stack IR ;) (type $FUNCSIG$v)
+ (local $0 i32)
(local $1 i32)
- (local $2 i32)
(block $label$1
(br_if $label$1
(if (result i32)
(i32.load
(i32.add
- (tee_local $2
- (tee_local $1
+ (tee_local $1
+ (tee_local $0
(i32.load
(i32.add
(i32.load
@@ -435,12 +664,12 @@ total
)
(i32.const 0)
(call_indirect (type $0)
- (get_local $2)
- (get_local $0)
+ (get_local $1)
+ (i32.const 10)
(i32.add
(i32.load offset=52
(i32.load
- (get_local $1)
+ (get_local $0)
)
)
(i32.const 422)
@@ -450,7 +679,7 @@ total
)
)
)
- (func $__ZNSt3__211__stdoutbufIcE8overflowEi (; 8 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
+ (func $__ZNSt3__211__stdoutbufIcE8overflowEi (; 7 ;) (; has Stack IR ;) (type $0) (param $0 i32) (param $1 i32) (result i32)
(i32.store8
(i32.const 0)
(get_local $1)
@@ -475,7 +704,7 @@ total
)
(i32.const 0)
)
- (func $__ZNSt3__211__stdoutbufIcE6xsputnEPKci (; 9 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (func $__ZNSt3__211__stdoutbufIcE6xsputnEPKci (; 8 ;) (; has Stack IR ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(drop
(call_indirect (type $1)
(i32.const 0)
diff --git a/test/passes/dae.txt b/test/passes/dae.txt
new file mode 100644
index 000000000..e62f03f5b
--- /dev/null
+++ b/test/passes/dae.txt
@@ -0,0 +1,174 @@
+(module
+ (type $0 (func (param i32)))
+ (type $1 (func))
+ (type $2 (func (param i32 f64)))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $a9)
+ (export "a8" (func $a8))
+ (func $a (; 0 ;)
+ (local $0 i32)
+ (set_local $0
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (func $b (; 1 ;) (type $1)
+ (call $a)
+ )
+ (func $a1 (; 2 ;)
+ (local $0 i32)
+ (set_local $0
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (func $b1 (; 3 ;) (type $1)
+ (call $a1)
+ )
+ (func $b11 (; 4 ;) (type $1)
+ (call $a1)
+ )
+ (func $a2 (; 5 ;) (type $0) (param $x i32)
+ (drop
+ (get_local $x)
+ )
+ )
+ (func $b2 (; 6 ;) (type $1)
+ (call $a2
+ (i32.const 3)
+ )
+ )
+ (func $b22 (; 7 ;) (type $1)
+ (call $a2
+ (i32.const 4)
+ )
+ )
+ (func $a3 (; 8 ;)
+ (local $0 i32)
+ (drop
+ (i32.const -1)
+ )
+ )
+ (func $b3 (; 9 ;) (type $1)
+ (call $a3)
+ )
+ (func $b33 (; 10 ;) (type $1)
+ (call $a3)
+ )
+ (func $a4 (; 11 ;) (type $0) (param $x i32)
+ (nop)
+ )
+ (func $b4 (; 12 ;) (type $1)
+ (call $a4
+ (unreachable)
+ )
+ )
+ (func $b43 (; 13 ;) (type $1)
+ (call $a4
+ (i32.const 4)
+ )
+ )
+ (func $a5 (; 14 ;)
+ (local $0 f64)
+ (local $1 i32)
+ (set_local $0
+ (f64.const 3.14159)
+ )
+ (block
+ (set_local $1
+ (i32.const 1)
+ )
+ (block
+ (drop
+ (get_local $1)
+ )
+ (drop
+ (get_local $0)
+ )
+ )
+ )
+ )
+ (func $b5 (; 15 ;) (type $1)
+ (call $a5)
+ )
+ (func $a6 (; 16 ;) (param $0 i32)
+ (local $1 f64)
+ (set_local $1
+ (f64.const 3.14159)
+ )
+ (block
+ (drop
+ (get_local $0)
+ )
+ (drop
+ (get_local $1)
+ )
+ )
+ )
+ (func $b6 (; 17 ;) (type $1)
+ (call $a6
+ (unreachable)
+ )
+ )
+ (func $a7 (; 18 ;) (param $0 f64)
+ (local $1 i32)
+ (set_local $1
+ (i32.const 1)
+ )
+ (block
+ (drop
+ (get_local $1)
+ )
+ (drop
+ (get_local $0)
+ )
+ )
+ )
+ (func $b7 (; 19 ;) (type $1)
+ (call $a7
+ (unreachable)
+ )
+ )
+ (func $a8 (; 20 ;) (type $0) (param $x i32)
+ (nop)
+ )
+ (func $b8 (; 21 ;) (type $1)
+ (call $a8
+ (i32.const 1)
+ )
+ )
+ (func $a9 (; 22 ;) (type $0) (param $x i32)
+ (nop)
+ )
+ (func $b9 (; 23 ;) (type $1)
+ (call $a9
+ (i32.const 1)
+ )
+ )
+ (func $a10 (; 24 ;)
+ (local $0 i32)
+ (set_local $0
+ (i32.const 1)
+ )
+ (block
+ (call $a10)
+ (call $a10)
+ )
+ )
+ (func $a11 (; 25 ;)
+ (local $0 i32)
+ (call $a11)
+ (call $a11)
+ )
+ (func $a12 (; 26 ;) (type $0) (param $x i32)
+ (drop
+ (get_local $x)
+ )
+ (call $a12
+ (i32.const 1)
+ )
+ (call $a12
+ (i32.const 2)
+ )
+ )
+)
diff --git a/test/passes/dae.wast b/test/passes/dae.wast
new file mode 100644
index 000000000..3400341a1
--- /dev/null
+++ b/test/passes/dae.wast
@@ -0,0 +1,87 @@
+(module
+ (export "a8" (func $a8))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $a9)
+ (func $a (param $x i32))
+ (func $b
+ (call $a (i32.const 1)) ;; best case scenario
+ )
+ (func $a1 (param $x i32)
+ (unreachable)
+ )
+ (func $b1
+ (call $a1 (i32.const 2)) ;; same value in both, so works
+ )
+ (func $b11
+ (call $a1 (i32.const 2))
+ )
+ (func $a2 (param $x i32)
+ (drop (get_local $x))
+ )
+ (func $b2
+ (call $a2 (i32.const 3)) ;; different value!
+ )
+ (func $b22
+ (call $a2 (i32.const 4))
+ )
+ (func $a3 (param $x i32)
+ (drop (i32.const -1)) ;; diff value, but at least unused, so no need to send
+ )
+ (func $b3
+ (call $a3 (i32.const 3))
+ )
+ (func $b33
+ (call $a3 (i32.const 4))
+ )
+ (func $a4 (param $x i32) ;; diff value, but with effects
+ )
+ (func $b4
+ (call $a4 (unreachable))
+ )
+ (func $b43
+ (call $a4 (i32.const 4))
+ )
+ (func $a5 (param $x i32) (param $y f64) ;; optimize two
+ (drop (get_local $x))
+ (drop (get_local $y))
+ )
+ (func $b5
+ (call $a5 (i32.const 1) (f64.const 3.14159))
+ )
+ (func $a6 (param $x i32) (param $y f64) ;; optimize just one
+ (drop (get_local $x))
+ (drop (get_local $y))
+ )
+ (func $b6
+ (call $a6 (unreachable) (f64.const 3.14159))
+ )
+ (func $a7 (param $x i32) (param $y f64) ;; optimize just the other one
+ (drop (get_local $x))
+ (drop (get_local $y))
+ )
+ (func $b7
+ (call $a7 (i32.const 1) (unreachable))
+ )
+ (func $a8 (param $x i32)) ;; exported, do not optimize
+ (func $b8
+ (call $a8 (i32.const 1))
+ )
+ (func $a9 (param $x i32)) ;; tabled, do not optimize
+ (func $b9
+ (call $a9 (i32.const 1))
+ )
+ (func $a10 (param $x i32) ;; recursion
+ (call $a10 (i32.const 1))
+ (call $a10 (i32.const 1))
+ )
+ (func $a11 (param $x i32) ;; partially successful recursion
+ (call $a11 (i32.const 1))
+ (call $a11 (i32.const 2))
+ )
+ (func $a12 (param $x i32) ;; unsuccessful recursion
+ (drop (get_local $x))
+ (call $a12 (i32.const 1))
+ (call $a12 (i32.const 2))
+ )
+)
+
diff --git a/test/wasm-only.asm.js b/test/wasm-only.asm.js
index 0013a30c3..056f45801 100644
--- a/test/wasm-only.asm.js
+++ b/test/wasm-only.asm.js
@@ -163,7 +163,9 @@ function asm(global, env, buffer) {
a = 0;
x = i64(x);
b = +0;
+ store4(50, a, 0);
store8(100, x, 0);
+ stored(200, b, 0);
illegalParam(0, i64(x), 12.34); // "coercion"/"cast"
}
function result() { // illegal result, but not exported
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index 0593e609a..f64f13f59 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -489,10 +489,18 @@
)
)
(func $illegalParam (; 15 ;) (; has Stack IR ;) (param $0 i32) (param $1 i64) (param $2 f64)
+ (i32.store
+ (i32.const 50)
+ (get_local $0)
+ )
(i64.store
(i32.const 100)
(get_local $1)
)
+ (f64.store
+ (i32.const 200)
+ (get_local $2)
+ )
(call $illegalParam
(i32.const 0)
(get_local $1)
@@ -520,235 +528,18 @@
(get_local $1)
)
)
- (func $switch64 (; 19 ;) (; has Stack IR ;) (param $0 i64) (result i32)
- (block $switch (result i32)
- (block $switch-default
- (block $switch-case0
- (block $switch-case
- (br_if $switch-default
- (i32.wrap/i64
- (i64.shr_u
- (tee_local $0
- (i64.sub
- (get_local $0)
- (i64.const 42949672965)
- )
- )
- (i64.const 32)
- )
- )
- )
- (br_table $switch-case0 $switch-default $switch-case $switch-default
- (i32.wrap/i64
- (get_local $0)
- )
- )
- )
- (br $switch
- (i32.const 11000)
- )
- )
- (br $switch
- (i32.const 10)
- )
- )
- (i32.const 1)
- )
- )
- (func $unreachable_leftovers (; 20 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32)
- (block $__rjto$0
- (if
- (i32.eqz
- (get_local $1)
- )
- (block
- (br_if $__rjto$0
- (get_local $2)
- )
- (i32.store
- (get_local $0)
- (i32.const -2)
- )
- (return)
- )
- )
- (i32.store
- (get_local $0)
- (i32.const -1)
- )
+ (func $unreachable_leftovers (; 19 ;) (; has Stack IR ;)
+ (i32.store
+ (i32.const 0)
+ (i32.const -2)
)
)
- (func $switch64TOOMUCH (; 21 ;) (; has Stack IR ;) (param $0 i64) (result i32)
+ (func $_memchr (; 20 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
- (local $2 i64)
- (block $switch-default
- (if
- (i64.ne
- (tee_local $2
- (get_local $0)
- )
- (i64.const -9223372036854775808)
- )
- (br_if $switch-default
- (i64.ne
- (get_local $2)
- (i64.const 4611686018427387904)
- )
- )
- )
- (return
- (i32.const 40)
- )
- )
- (block $switch-default4
- (if
- (i32.ne
- (tee_local $1
- (i32.const 100)
- )
- (i32.const 214748364)
- )
- (br_if $switch-default4
- (i32.ne
- (get_local $1)
- (i32.const 107374182)
- )
- )
- )
- (return
- (i32.const 41)
- )
- )
- (block $switch5
- (if
- (i64.ne
- (get_local $0)
- (i64.const -9223372036854775808)
- )
- (br_if $switch5
- (i64.ne
- (get_local $0)
- (i64.const 4611686018427387904)
- )
- )
- )
- (return
- (i32.const 42)
- )
- )
- (block $switch8
- (if
- (i32.ne
- (i32.const 100)
- (i32.const 214748364)
- )
- (br_if $switch8
- (i32.ne
- (get_local $1)
- (i32.const 107374182)
- )
- )
- )
- (return
- (i32.const 43)
- )
- )
- (i32.const 44)
- )
- (func $_memchr (; 22 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
- (local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (set_local $5
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (local $2 i32)
(block $label$break$L8
(block $__rjti$2
- (if
- (i32.and
- (tee_local $4
- (i32.ne
- (get_local $2)
- (i32.const 0)
- )
- )
- (i32.ne
- (i32.and
- (get_local $0)
- (i32.const 3)
- )
- (i32.const 0)
- )
- )
- (block
- (set_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
- (set_local $3
- (get_local $2)
- )
- (set_local $2
- (get_local $0)
- )
- (loop $while-in
- (br_if $__rjti$2
- (i32.eq
- (i32.load8_u
- (get_local $2)
- )
- (i32.and
- (get_local $4)
- (i32.const 255)
- )
- )
- )
- (br_if $while-in
- (i32.and
- (tee_local $0
- (i32.ne
- (tee_local $3
- (i32.add
- (get_local $3)
- (i32.const -1)
- )
- )
- (i32.const 0)
- )
- )
- (i32.ne
- (i32.and
- (tee_local $2
- (i32.add
- (get_local $2)
- (i32.const 1)
- )
- )
- (i32.const 3)
- )
- (i32.const 0)
- )
- )
- )
- )
- )
- (block
- (set_local $3
- (get_local $2)
- )
- (set_local $2
- (get_local $0)
- )
- (set_local $0
- (get_local $4)
- )
- )
- )
(br_if $__rjti$2
(get_local $0)
)
@@ -758,27 +549,13 @@
(br $label$break$L8)
)
(set_local $0
- (get_local $3)
+ (get_local $2)
)
(if
- (i32.ne
- (i32.load8_u
- (get_local $2)
- )
- (tee_local $1
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (i32.load8_u
+ (get_local $1)
)
(block
- (set_local $3
- (i32.mul
- (get_local $5)
- (i32.const 16843009)
- )
- )
(block $__rjto$0
(block $__rjti$0
(br_if $__rjti$0
@@ -793,12 +570,9 @@
(i32.and
(i32.xor
(i32.and
- (tee_local $4
- (i32.xor
- (i32.load
- (get_local $2)
- )
- (get_local $3)
+ (tee_local $2
+ (i32.load
+ (get_local $1)
)
)
(i32.const -2139062144)
@@ -806,15 +580,15 @@
(i32.const -2139062144)
)
(i32.add
- (get_local $4)
+ (get_local $2)
(i32.const -16843009)
)
)
)
(block
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 4)
)
)
@@ -849,19 +623,15 @@
)
(loop $while-in5
(br_if $label$break$L8
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
(get_local $1)
- (i32.const 255)
)
)
)
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -881,12 +651,12 @@
)
)
(select
- (get_local $2)
+ (get_local $1)
(i32.const 0)
(get_local $0)
)
)
- (func $keepAlive (; 23 ;) (; has Stack IR ;)
+ (func $keepAlive (; 21 ;) (; has Stack IR ;)
(call $loads)
(call $loads)
(call $stores)
@@ -947,40 +717,13 @@
(i32.const 0)
)
)
+ (call $unreachable_leftovers)
+ (call $unreachable_leftovers)
(drop
- (call $switch64
- (i64.const 0)
- )
- )
- (drop
- (call $switch64
- (i64.const 0)
- )
- )
- (call $unreachable_leftovers
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- (call $unreachable_leftovers
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- (drop
- (call $_memchr
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (call $switch64TOOMUCH
- (i64.const 0)
- )
+ (call $_memchr)
)
)
- (func $legalstub$illegalParam (; 24 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
+ (func $legalstub$illegalParam (; 22 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
(i64.or
@@ -997,13 +740,13 @@
(get_local $3)
)
)
- (func $legalstub$illegalResult (; 25 ;) (; has Stack IR ;) (result i32)
+ (func $legalstub$illegalResult (; 23 ;) (; has Stack IR ;) (result i32)
(set_global $tempRet0
(i32.const 2)
)
(i32.const 1)
)
- (func $legalfunc$illegalImport (; 26 ;) (; has Stack IR ;) (param $0 f64) (param $1 i64) (param $2 i32)
+ (func $legalfunc$illegalImport (; 24 ;) (; has Stack IR ;) (param $0 f64) (param $1 i64) (param $2 i32)
(call $legalimport$illegalImport
(get_local $0)
(i32.wrap/i64
@@ -1018,7 +761,7 @@
(get_local $2)
)
)
- (func $legalfunc$_fabsf (; 27 ;) (; has Stack IR ;) (param $0 f32) (result f32)
+ (func $legalfunc$_fabsf (; 25 ;) (; has Stack IR ;) (param $0 f32) (result f32)
(f32.demote/f64
(call $legalimport$_fabsf
(f64.promote/f32
@@ -1027,7 +770,7 @@
)
)
)
- (func $legalfunc$do_i64 (; 28 ;) (; has Stack IR ;) (result i64)
+ (func $legalfunc$do_i64 (; 26 ;) (; has Stack IR ;) (result i64)
(i64.or
(i64.extend_u/i32
(call $legalimport$do_i64)
@@ -1040,10 +783,10 @@
)
)
)
- (func $getTempRet0 (; 29 ;) (; has Stack IR ;) (result i32)
+ (func $getTempRet0 (; 27 ;) (; has Stack IR ;) (result i32)
(get_global $tempRet0)
)
- (func $setTempRet0 (; 30 ;) (; has Stack IR ;) (param $0 i32)
+ (func $setTempRet0 (; 28 ;) (; has Stack IR ;) (param $0 i32)
(set_global $tempRet0
(get_local $0)
)
diff --git a/test/wasm-only.fromasm.clamp b/test/wasm-only.fromasm.clamp
index 0593e609a..f64f13f59 100644
--- a/test/wasm-only.fromasm.clamp
+++ b/test/wasm-only.fromasm.clamp
@@ -489,10 +489,18 @@
)
)
(func $illegalParam (; 15 ;) (; has Stack IR ;) (param $0 i32) (param $1 i64) (param $2 f64)
+ (i32.store
+ (i32.const 50)
+ (get_local $0)
+ )
(i64.store
(i32.const 100)
(get_local $1)
)
+ (f64.store
+ (i32.const 200)
+ (get_local $2)
+ )
(call $illegalParam
(i32.const 0)
(get_local $1)
@@ -520,235 +528,18 @@
(get_local $1)
)
)
- (func $switch64 (; 19 ;) (; has Stack IR ;) (param $0 i64) (result i32)
- (block $switch (result i32)
- (block $switch-default
- (block $switch-case0
- (block $switch-case
- (br_if $switch-default
- (i32.wrap/i64
- (i64.shr_u
- (tee_local $0
- (i64.sub
- (get_local $0)
- (i64.const 42949672965)
- )
- )
- (i64.const 32)
- )
- )
- )
- (br_table $switch-case0 $switch-default $switch-case $switch-default
- (i32.wrap/i64
- (get_local $0)
- )
- )
- )
- (br $switch
- (i32.const 11000)
- )
- )
- (br $switch
- (i32.const 10)
- )
- )
- (i32.const 1)
- )
- )
- (func $unreachable_leftovers (; 20 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32)
- (block $__rjto$0
- (if
- (i32.eqz
- (get_local $1)
- )
- (block
- (br_if $__rjto$0
- (get_local $2)
- )
- (i32.store
- (get_local $0)
- (i32.const -2)
- )
- (return)
- )
- )
- (i32.store
- (get_local $0)
- (i32.const -1)
- )
+ (func $unreachable_leftovers (; 19 ;) (; has Stack IR ;)
+ (i32.store
+ (i32.const 0)
+ (i32.const -2)
)
)
- (func $switch64TOOMUCH (; 21 ;) (; has Stack IR ;) (param $0 i64) (result i32)
+ (func $_memchr (; 20 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
- (local $2 i64)
- (block $switch-default
- (if
- (i64.ne
- (tee_local $2
- (get_local $0)
- )
- (i64.const -9223372036854775808)
- )
- (br_if $switch-default
- (i64.ne
- (get_local $2)
- (i64.const 4611686018427387904)
- )
- )
- )
- (return
- (i32.const 40)
- )
- )
- (block $switch-default4
- (if
- (i32.ne
- (tee_local $1
- (i32.const 100)
- )
- (i32.const 214748364)
- )
- (br_if $switch-default4
- (i32.ne
- (get_local $1)
- (i32.const 107374182)
- )
- )
- )
- (return
- (i32.const 41)
- )
- )
- (block $switch5
- (if
- (i64.ne
- (get_local $0)
- (i64.const -9223372036854775808)
- )
- (br_if $switch5
- (i64.ne
- (get_local $0)
- (i64.const 4611686018427387904)
- )
- )
- )
- (return
- (i32.const 42)
- )
- )
- (block $switch8
- (if
- (i32.ne
- (i32.const 100)
- (i32.const 214748364)
- )
- (br_if $switch8
- (i32.ne
- (get_local $1)
- (i32.const 107374182)
- )
- )
- )
- (return
- (i32.const 43)
- )
- )
- (i32.const 44)
- )
- (func $_memchr (; 22 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
- (local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (set_local $5
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (local $2 i32)
(block $label$break$L8
(block $__rjti$2
- (if
- (i32.and
- (tee_local $4
- (i32.ne
- (get_local $2)
- (i32.const 0)
- )
- )
- (i32.ne
- (i32.and
- (get_local $0)
- (i32.const 3)
- )
- (i32.const 0)
- )
- )
- (block
- (set_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
- (set_local $3
- (get_local $2)
- )
- (set_local $2
- (get_local $0)
- )
- (loop $while-in
- (br_if $__rjti$2
- (i32.eq
- (i32.load8_u
- (get_local $2)
- )
- (i32.and
- (get_local $4)
- (i32.const 255)
- )
- )
- )
- (br_if $while-in
- (i32.and
- (tee_local $0
- (i32.ne
- (tee_local $3
- (i32.add
- (get_local $3)
- (i32.const -1)
- )
- )
- (i32.const 0)
- )
- )
- (i32.ne
- (i32.and
- (tee_local $2
- (i32.add
- (get_local $2)
- (i32.const 1)
- )
- )
- (i32.const 3)
- )
- (i32.const 0)
- )
- )
- )
- )
- )
- (block
- (set_local $3
- (get_local $2)
- )
- (set_local $2
- (get_local $0)
- )
- (set_local $0
- (get_local $4)
- )
- )
- )
(br_if $__rjti$2
(get_local $0)
)
@@ -758,27 +549,13 @@
(br $label$break$L8)
)
(set_local $0
- (get_local $3)
+ (get_local $2)
)
(if
- (i32.ne
- (i32.load8_u
- (get_local $2)
- )
- (tee_local $1
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (i32.load8_u
+ (get_local $1)
)
(block
- (set_local $3
- (i32.mul
- (get_local $5)
- (i32.const 16843009)
- )
- )
(block $__rjto$0
(block $__rjti$0
(br_if $__rjti$0
@@ -793,12 +570,9 @@
(i32.and
(i32.xor
(i32.and
- (tee_local $4
- (i32.xor
- (i32.load
- (get_local $2)
- )
- (get_local $3)
+ (tee_local $2
+ (i32.load
+ (get_local $1)
)
)
(i32.const -2139062144)
@@ -806,15 +580,15 @@
(i32.const -2139062144)
)
(i32.add
- (get_local $4)
+ (get_local $2)
(i32.const -16843009)
)
)
)
(block
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 4)
)
)
@@ -849,19 +623,15 @@
)
(loop $while-in5
(br_if $label$break$L8
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
(get_local $1)
- (i32.const 255)
)
)
)
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -881,12 +651,12 @@
)
)
(select
- (get_local $2)
+ (get_local $1)
(i32.const 0)
(get_local $0)
)
)
- (func $keepAlive (; 23 ;) (; has Stack IR ;)
+ (func $keepAlive (; 21 ;) (; has Stack IR ;)
(call $loads)
(call $loads)
(call $stores)
@@ -947,40 +717,13 @@
(i32.const 0)
)
)
+ (call $unreachable_leftovers)
+ (call $unreachable_leftovers)
(drop
- (call $switch64
- (i64.const 0)
- )
- )
- (drop
- (call $switch64
- (i64.const 0)
- )
- )
- (call $unreachable_leftovers
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- (call $unreachable_leftovers
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- (drop
- (call $_memchr
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (call $switch64TOOMUCH
- (i64.const 0)
- )
+ (call $_memchr)
)
)
- (func $legalstub$illegalParam (; 24 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
+ (func $legalstub$illegalParam (; 22 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
(i64.or
@@ -997,13 +740,13 @@
(get_local $3)
)
)
- (func $legalstub$illegalResult (; 25 ;) (; has Stack IR ;) (result i32)
+ (func $legalstub$illegalResult (; 23 ;) (; has Stack IR ;) (result i32)
(set_global $tempRet0
(i32.const 2)
)
(i32.const 1)
)
- (func $legalfunc$illegalImport (; 26 ;) (; has Stack IR ;) (param $0 f64) (param $1 i64) (param $2 i32)
+ (func $legalfunc$illegalImport (; 24 ;) (; has Stack IR ;) (param $0 f64) (param $1 i64) (param $2 i32)
(call $legalimport$illegalImport
(get_local $0)
(i32.wrap/i64
@@ -1018,7 +761,7 @@
(get_local $2)
)
)
- (func $legalfunc$_fabsf (; 27 ;) (; has Stack IR ;) (param $0 f32) (result f32)
+ (func $legalfunc$_fabsf (; 25 ;) (; has Stack IR ;) (param $0 f32) (result f32)
(f32.demote/f64
(call $legalimport$_fabsf
(f64.promote/f32
@@ -1027,7 +770,7 @@
)
)
)
- (func $legalfunc$do_i64 (; 28 ;) (; has Stack IR ;) (result i64)
+ (func $legalfunc$do_i64 (; 26 ;) (; has Stack IR ;) (result i64)
(i64.or
(i64.extend_u/i32
(call $legalimport$do_i64)
@@ -1040,10 +783,10 @@
)
)
)
- (func $getTempRet0 (; 29 ;) (; has Stack IR ;) (result i32)
+ (func $getTempRet0 (; 27 ;) (; has Stack IR ;) (result i32)
(get_global $tempRet0)
)
- (func $setTempRet0 (; 30 ;) (; has Stack IR ;) (param $0 i32)
+ (func $setTempRet0 (; 28 ;) (; has Stack IR ;) (param $0 i32)
(set_global $tempRet0
(get_local $0)
)
diff --git a/test/wasm-only.fromasm.clamp.no-opts b/test/wasm-only.fromasm.clamp.no-opts
index 3c717b31d..786bef708 100644
--- a/test/wasm-only.fromasm.clamp.no-opts
+++ b/test/wasm-only.fromasm.clamp.no-opts
@@ -737,10 +737,18 @@
)
)
(func $illegalParam (; 19 ;) (param $a i32) (param $x i64) (param $b f64)
+ (i32.store
+ (i32.const 50)
+ (get_local $a)
+ )
(i64.store
(i32.const 100)
(get_local $x)
)
+ (f64.store
+ (i32.const 200)
+ (get_local $b)
+ )
(call $illegalParam
(i32.const 0)
(get_local $x)
diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise
index 6077f9429..e9522a7c3 100644
--- a/test/wasm-only.fromasm.imprecise
+++ b/test/wasm-only.fromasm.imprecise
@@ -189,10 +189,18 @@
)
)
(func $illegalParam (; 9 ;) (; has Stack IR ;) (param $0 i32) (param $1 i64) (param $2 f64)
+ (i32.store
+ (i32.const 50)
+ (get_local $0)
+ )
(i64.store
(i32.const 100)
(get_local $1)
)
+ (f64.store
+ (i32.const 200)
+ (get_local $2)
+ )
(call $illegalParam
(i32.const 0)
(get_local $1)
@@ -220,235 +228,18 @@
(get_local $1)
)
)
- (func $switch64 (; 13 ;) (; has Stack IR ;) (param $0 i64) (result i32)
- (block $switch (result i32)
- (block $switch-default
- (block $switch-case0
- (block $switch-case
- (br_if $switch-default
- (i32.wrap/i64
- (i64.shr_u
- (tee_local $0
- (i64.sub
- (get_local $0)
- (i64.const 42949672965)
- )
- )
- (i64.const 32)
- )
- )
- )
- (br_table $switch-case0 $switch-default $switch-case $switch-default
- (i32.wrap/i64
- (get_local $0)
- )
- )
- )
- (br $switch
- (i32.const 11000)
- )
- )
- (br $switch
- (i32.const 10)
- )
- )
- (i32.const 1)
- )
- )
- (func $unreachable_leftovers (; 14 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32)
- (block $__rjto$0
- (if
- (i32.eqz
- (get_local $1)
- )
- (block
- (br_if $__rjto$0
- (get_local $2)
- )
- (i32.store
- (get_local $0)
- (i32.const -2)
- )
- (return)
- )
- )
- (i32.store
- (get_local $0)
- (i32.const -1)
- )
+ (func $unreachable_leftovers (; 13 ;) (; has Stack IR ;)
+ (i32.store
+ (i32.const 0)
+ (i32.const -2)
)
)
- (func $switch64TOOMUCH (; 15 ;) (; has Stack IR ;) (param $0 i64) (result i32)
+ (func $_memchr (; 14 ;) (; has Stack IR ;) (result i32)
+ (local $0 i32)
(local $1 i32)
- (local $2 i64)
- (block $switch-default
- (if
- (i64.ne
- (tee_local $2
- (get_local $0)
- )
- (i64.const -9223372036854775808)
- )
- (br_if $switch-default
- (i64.ne
- (get_local $2)
- (i64.const 4611686018427387904)
- )
- )
- )
- (return
- (i32.const 40)
- )
- )
- (block $switch-default4
- (if
- (i32.ne
- (tee_local $1
- (i32.const 100)
- )
- (i32.const 214748364)
- )
- (br_if $switch-default4
- (i32.ne
- (get_local $1)
- (i32.const 107374182)
- )
- )
- )
- (return
- (i32.const 41)
- )
- )
- (block $switch5
- (if
- (i64.ne
- (get_local $0)
- (i64.const -9223372036854775808)
- )
- (br_if $switch5
- (i64.ne
- (get_local $0)
- (i64.const 4611686018427387904)
- )
- )
- )
- (return
- (i32.const 42)
- )
- )
- (block $switch8
- (if
- (i32.ne
- (i32.const 100)
- (i32.const 214748364)
- )
- (br_if $switch8
- (i32.ne
- (get_local $1)
- (i32.const 107374182)
- )
- )
- )
- (return
- (i32.const 43)
- )
- )
- (i32.const 44)
- )
- (func $_memchr (; 16 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
- (local $3 i32)
- (local $4 i32)
- (local $5 i32)
- (set_local $5
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (local $2 i32)
(block $label$break$L8
(block $__rjti$2
- (if
- (i32.and
- (tee_local $4
- (i32.ne
- (get_local $2)
- (i32.const 0)
- )
- )
- (i32.ne
- (i32.and
- (get_local $0)
- (i32.const 3)
- )
- (i32.const 0)
- )
- )
- (block
- (set_local $4
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
- (set_local $3
- (get_local $2)
- )
- (set_local $2
- (get_local $0)
- )
- (loop $while-in
- (br_if $__rjti$2
- (i32.eq
- (i32.load8_u
- (get_local $2)
- )
- (i32.and
- (get_local $4)
- (i32.const 255)
- )
- )
- )
- (br_if $while-in
- (i32.and
- (tee_local $0
- (i32.ne
- (tee_local $3
- (i32.add
- (get_local $3)
- (i32.const -1)
- )
- )
- (i32.const 0)
- )
- )
- (i32.ne
- (i32.and
- (tee_local $2
- (i32.add
- (get_local $2)
- (i32.const 1)
- )
- )
- (i32.const 3)
- )
- (i32.const 0)
- )
- )
- )
- )
- )
- (block
- (set_local $3
- (get_local $2)
- )
- (set_local $2
- (get_local $0)
- )
- (set_local $0
- (get_local $4)
- )
- )
- )
(br_if $__rjti$2
(get_local $0)
)
@@ -458,27 +249,13 @@
(br $label$break$L8)
)
(set_local $0
- (get_local $3)
+ (get_local $2)
)
(if
- (i32.ne
- (i32.load8_u
- (get_local $2)
- )
- (tee_local $1
- (i32.and
- (get_local $1)
- (i32.const 255)
- )
- )
+ (i32.load8_u
+ (get_local $1)
)
(block
- (set_local $3
- (i32.mul
- (get_local $5)
- (i32.const 16843009)
- )
- )
(block $__rjto$0
(block $__rjti$0
(br_if $__rjti$0
@@ -493,12 +270,9 @@
(i32.and
(i32.xor
(i32.and
- (tee_local $4
- (i32.xor
- (i32.load
- (get_local $2)
- )
- (get_local $3)
+ (tee_local $2
+ (i32.load
+ (get_local $1)
)
)
(i32.const -2139062144)
@@ -506,15 +280,15 @@
(i32.const -2139062144)
)
(i32.add
- (get_local $4)
+ (get_local $2)
(i32.const -16843009)
)
)
)
(block
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 4)
)
)
@@ -549,19 +323,15 @@
)
(loop $while-in5
(br_if $label$break$L8
- (i32.eq
+ (i32.eqz
(i32.load8_u
- (get_local $2)
- )
- (i32.and
(get_local $1)
- (i32.const 255)
)
)
)
- (set_local $2
+ (set_local $1
(i32.add
- (get_local $2)
+ (get_local $1)
(i32.const 1)
)
)
@@ -581,12 +351,12 @@
)
)
(select
- (get_local $2)
+ (get_local $1)
(i32.const 0)
(get_local $0)
)
)
- (func $keepAlive (; 17 ;) (; has Stack IR ;)
+ (func $keepAlive (; 15 ;) (; has Stack IR ;)
(call $stores)
(call $stores)
(call $test)
@@ -645,40 +415,13 @@
(i32.const 0)
)
)
+ (call $unreachable_leftovers)
+ (call $unreachable_leftovers)
(drop
- (call $switch64
- (i64.const 0)
- )
- )
- (drop
- (call $switch64
- (i64.const 0)
- )
- )
- (call $unreachable_leftovers
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- (call $unreachable_leftovers
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- (drop
- (call $_memchr
- (i32.const 0)
- (i32.const 0)
- (i32.const 0)
- )
- )
- (drop
- (call $switch64TOOMUCH
- (i64.const 0)
- )
+ (call $_memchr)
)
)
- (func $legalstub$illegalParam (; 18 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
+ (func $legalstub$illegalParam (; 16 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 f64)
(call $illegalParam
(get_local $0)
(i64.or
@@ -695,13 +438,13 @@
(get_local $3)
)
)
- (func $legalstub$illegalResult (; 19 ;) (; has Stack IR ;) (result i32)
+ (func $legalstub$illegalResult (; 17 ;) (; has Stack IR ;) (result i32)
(set_global $tempRet0
(i32.const 2)
)
(i32.const 1)
)
- (func $legalfunc$illegalImport (; 20 ;) (; has Stack IR ;) (param $0 f64) (param $1 i64) (param $2 i32)
+ (func $legalfunc$illegalImport (; 18 ;) (; has Stack IR ;) (param $0 f64) (param $1 i64) (param $2 i32)
(call $legalimport$illegalImport
(get_local $0)
(i32.wrap/i64
@@ -716,7 +459,7 @@
(get_local $2)
)
)
- (func $legalfunc$_fabsf (; 21 ;) (; has Stack IR ;) (param $0 f32) (result f32)
+ (func $legalfunc$_fabsf (; 19 ;) (; has Stack IR ;) (param $0 f32) (result f32)
(f32.demote/f64
(call $legalimport$_fabsf
(f64.promote/f32
@@ -725,7 +468,7 @@
)
)
)
- (func $legalfunc$do_i64 (; 22 ;) (; has Stack IR ;) (result i64)
+ (func $legalfunc$do_i64 (; 20 ;) (; has Stack IR ;) (result i64)
(i64.or
(i64.extend_u/i32
(call $legalimport$do_i64)
@@ -738,10 +481,10 @@
)
)
)
- (func $getTempRet0 (; 23 ;) (; has Stack IR ;) (result i32)
+ (func $getTempRet0 (; 21 ;) (; has Stack IR ;) (result i32)
(get_global $tempRet0)
)
- (func $setTempRet0 (; 24 ;) (; has Stack IR ;) (param $0 i32)
+ (func $setTempRet0 (; 22 ;) (; has Stack IR ;) (param $0 i32)
(set_global $tempRet0
(get_local $0)
)
diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts
index 997f66614..484a69fa6 100644
--- a/test/wasm-only.fromasm.imprecise.no-opts
+++ b/test/wasm-only.fromasm.imprecise.no-opts
@@ -572,10 +572,18 @@
)
)
(func $illegalParam (; 11 ;) (param $a i32) (param $x i64) (param $b f64)
+ (i32.store
+ (i32.const 50)
+ (get_local $a)
+ )
(i64.store
(i32.const 100)
(get_local $x)
)
+ (f64.store
+ (i32.const 200)
+ (get_local $b)
+ )
(call $illegalParam
(i32.const 0)
(get_local $x)
diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts
index 3c717b31d..786bef708 100644
--- a/test/wasm-only.fromasm.no-opts
+++ b/test/wasm-only.fromasm.no-opts
@@ -737,10 +737,18 @@
)
)
(func $illegalParam (; 19 ;) (param $a i32) (param $x i64) (param $b f64)
+ (i32.store
+ (i32.const 50)
+ (get_local $a)
+ )
(i64.store
(i32.const 100)
(get_local $x)
)
+ (f64.store
+ (i32.const 200)
+ (get_local $b)
+ )
(call $illegalParam
(i32.const 0)
(get_local $x)