diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-06-01 12:33:55 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-06-01 12:33:55 -0700 |
commit | db2ae40be2c52c0821da355285384aa0db8fc948 (patch) | |
tree | 219196901187a754333cb076ce786a5bea653371 /test | |
parent | 208959079a9c4b97a2457e8d6b11c5bc295c0754 (diff) | |
download | binaryen-db2ae40be2c52c0821da355285384aa0db8fc948.tar.gz binaryen-db2ae40be2c52c0821da355285384aa0db8fc948.tar.bz2 binaryen-db2ae40be2c52c0821da355285384aa0db8fc948.zip |
if we use the zero-init value of a local, we cannot coalesce it with a param (#556)
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/coalesce-locals-learning.txt | 3 | ||||
-rw-r--r-- | test/passes/coalesce-locals.txt | 3 | ||||
-rw-r--r-- | test/unit.asm.js | 13 | ||||
-rw-r--r-- | test/unit.fromasm | 28 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 28 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise.no-opts | 28 | ||||
-rw-r--r-- | test/unit.fromasm.no-opts | 28 |
7 files changed, 129 insertions, 2 deletions
diff --git a/test/passes/coalesce-locals-learning.txt b/test/passes/coalesce-locals-learning.txt index 14091cb98..aa3c8c9c0 100644 --- a/test/passes/coalesce-locals-learning.txt +++ b/test/passes/coalesce-locals-learning.txt @@ -318,9 +318,10 @@ (func $params (param $0 i32) (param $1 f32) (local $2 i32) (local $3 i32) - (get_local $0) + (local $4 i32) (get_local $2) (get_local $3) + (get_local $4) ) (func $interfere-in-dead (local $0 i32) diff --git a/test/passes/coalesce-locals.txt b/test/passes/coalesce-locals.txt index 3c1632f68..d0edbd71d 100644 --- a/test/passes/coalesce-locals.txt +++ b/test/passes/coalesce-locals.txt @@ -318,9 +318,10 @@ (func $params (param $0 i32) (param $1 f32) (local $2 i32) (local $3 i32) - (get_local $0) + (local $4 i32) (get_local $2) (get_local $3) + (get_local $4) ) (func $interfere-in-dead (local $0 i32) diff --git a/test/unit.asm.js b/test/unit.asm.js index 5b958a111..2f307e085 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -234,6 +234,19 @@ function asm(global, env, buffer) { -3.14159; } + function zeroInit(x) { + x = x | 0; + var y = 0; // reusing this with x is dangerous - x has a value, and y needs to start at 0! + if (lb(0) | 0) { + if (lb(1) | 0) y = 3; + } else { + y = 3; + } + if ((y | 0) == 3) { + lb(2) | 0; + } + } + function z() { } function w() { diff --git a/test/unit.fromasm b/test/unit.fromasm index 7ee15cd05..3fb76981d 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -425,4 +425,32 @@ ) (i32.const 0) ) + (func $zeroInit (param $0 i32) + (local $1 i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $1 + (i32.const 3) + ) + ) + (set_local $1 + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $1) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) ) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 293fc490a..a4716941d 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -417,4 +417,32 @@ ) (i32.const 0) ) + (func $zeroInit (param $0 i32) + (local $1 i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $1 + (i32.const 3) + ) + ) + (set_local $1 + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $1) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) ) diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts index 2f7665622..c3da01359 100644 --- a/test/unit.fromasm.imprecise.no-opts +++ b/test/unit.fromasm.imprecise.no-opts @@ -693,6 +693,34 @@ (func $exportMe (f64.const -3.14159) ) + (func $zeroInit (param $x i32) + (local $y i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $y + (i32.const 3) + ) + ) + (set_local $y + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $y) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) (func $z (nop) ) diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts index 19c13f29f..92d2d2add 100644 --- a/test/unit.fromasm.no-opts +++ b/test/unit.fromasm.no-opts @@ -697,6 +697,34 @@ (func $exportMe (f64.const -3.14159) ) + (func $zeroInit (param $x i32) + (local $y i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $y + (i32.const 3) + ) + ) + (set_local $y + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $y) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) (func $z (nop) ) |