diff options
-rw-r--r-- | src/asm2wasm.h | 1 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm.imprecise.no-opts | 225 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm.no-opts | 225 | ||||
-rw-r--r-- | test/unit.fromasm | 18 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 18 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise.no-opts | 37 | ||||
-rw-r--r-- | test/unit.fromasm.no-opts | 37 |
7 files changed, 431 insertions, 130 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 321d5275e..abe6e2f25 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -787,6 +787,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { PassRunner passRunner(&wasm); passRunner.add<FinalizeCalls>(this); passRunner.add<AutoDrop>(); + if (optimize) passRunner.add("vacuum"); // autodrop can add some garbage passRunner.run(); // apply memory growth, if relevant diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts index 4e174f6ee..010c02ffd 100644 --- a/test/emcc_hello_world.fromasm.imprecise.no-opts +++ b/test/emcc_hello_world.fromasm.imprecise.no-opts @@ -30274,8 +30274,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $h) + (block + (set_global $tempRet0 + (get_local $h) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $l) ) @@ -30304,8 +30309,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $h) + (block + (set_global $tempRet0 + (get_local $h) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $l) ) @@ -30875,29 +30885,34 @@ ) (return (block - (set_global $tempRet0 - (i32.add + (block + (set_global $tempRet0 (i32.add - (i32.shr_u - (get_local $$8) - (i32.const 16) - ) - (i32.mul - (get_local $$11) - (get_local $$6) - ) - ) - (i32.shr_u (i32.add - (i32.and + (i32.shr_u (get_local $$8) - (i32.const 65535) + (i32.const 16) + ) + (i32.mul + (get_local $$11) + (get_local $$6) ) - (get_local $$12) ) - (i32.const 16) + (i32.shr_u + (i32.add + (i32.and + (get_local $$8) + (i32.const 65535) + ) + (get_local $$12) + ) + (i32.const 16) + ) ) ) + (drop + (get_global $tempRet0) + ) ) (i32.or (i32.const 0) @@ -31273,8 +31288,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$10$1) + (block + (set_global $tempRet0 + (get_local $$10$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$10$0) ) @@ -31309,23 +31329,28 @@ ) (return (block - (set_global $tempRet0 - (i32.or - (i32.add + (block + (set_global $tempRet0 + (i32.or (i32.add - (i32.mul - (get_local $$b$1) - (get_local $$x_sroa_0_0_extract_trunc) + (i32.add + (i32.mul + (get_local $$b$1) + (get_local $$x_sroa_0_0_extract_trunc) + ) + (get_local $$2) ) - (get_local $$2) + (get_local $$1$1) + ) + (i32.and + (get_local $$1$1) + (i32.const 0) ) - (get_local $$1$1) - ) - (i32.and - (get_local $$1$1) - (i32.const 0) ) ) + (drop + (get_global $tempRet0) + ) ) (i32.or (i32.const 0) @@ -31381,13 +31406,18 @@ ) (return (block - (set_global $tempRet0 - (i32.load - (i32.add - (get_local $$rem) - (i32.const 4) + (block + (set_global $tempRet0 + (i32.load + (i32.add + (get_local $$rem) + (i32.const 4) + ) ) ) + (drop + (get_global $tempRet0) + ) ) (i32.load (get_local $$rem) @@ -31526,8 +31556,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31547,8 +31582,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31580,8 +31620,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31639,8 +31684,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31686,8 +31736,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31756,8 +31811,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31842,8 +31902,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31881,8 +31946,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31987,8 +32057,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32026,8 +32101,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32227,8 +32307,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32266,8 +32351,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32622,8 +32712,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts index 41db5a7a1..a5f8ac376 100644 --- a/test/emcc_hello_world.fromasm.no-opts +++ b/test/emcc_hello_world.fromasm.no-opts @@ -30280,8 +30280,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $h) + (block + (set_global $tempRet0 + (get_local $h) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $l) ) @@ -30310,8 +30315,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $h) + (block + (set_global $tempRet0 + (get_local $h) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $l) ) @@ -30881,29 +30891,34 @@ ) (return (block - (set_global $tempRet0 - (i32.add + (block + (set_global $tempRet0 (i32.add - (i32.shr_u - (get_local $$8) - (i32.const 16) - ) - (i32.mul - (get_local $$11) - (get_local $$6) - ) - ) - (i32.shr_u (i32.add - (i32.and + (i32.shr_u (get_local $$8) - (i32.const 65535) + (i32.const 16) + ) + (i32.mul + (get_local $$11) + (get_local $$6) ) - (get_local $$12) ) - (i32.const 16) + (i32.shr_u + (i32.add + (i32.and + (get_local $$8) + (i32.const 65535) + ) + (get_local $$12) + ) + (i32.const 16) + ) ) ) + (drop + (get_global $tempRet0) + ) ) (i32.or (i32.const 0) @@ -31279,8 +31294,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$10$1) + (block + (set_global $tempRet0 + (get_local $$10$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$10$0) ) @@ -31315,23 +31335,28 @@ ) (return (block - (set_global $tempRet0 - (i32.or - (i32.add + (block + (set_global $tempRet0 + (i32.or (i32.add - (i32.mul - (get_local $$b$1) - (get_local $$x_sroa_0_0_extract_trunc) + (i32.add + (i32.mul + (get_local $$b$1) + (get_local $$x_sroa_0_0_extract_trunc) + ) + (get_local $$2) ) - (get_local $$2) + (get_local $$1$1) + ) + (i32.and + (get_local $$1$1) + (i32.const 0) ) - (get_local $$1$1) - ) - (i32.and - (get_local $$1$1) - (i32.const 0) ) ) + (drop + (get_global $tempRet0) + ) ) (i32.or (i32.const 0) @@ -31387,13 +31412,18 @@ ) (return (block - (set_global $tempRet0 - (i32.load - (i32.add - (get_local $$rem) - (i32.const 4) + (block + (set_global $tempRet0 + (i32.load + (i32.add + (get_local $$rem) + (i32.const 4) + ) ) ) + (drop + (get_global $tempRet0) + ) ) (i32.load (get_local $$rem) @@ -31532,8 +31562,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31553,8 +31588,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31586,8 +31626,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31645,8 +31690,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31692,8 +31742,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31762,8 +31817,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31848,8 +31908,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31887,8 +31952,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -31993,8 +32063,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32032,8 +32107,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32233,8 +32313,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32272,8 +32357,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) @@ -32628,8 +32718,13 @@ ) (return (block - (set_global $tempRet0 - (get_local $$_0$1) + (block + (set_global $tempRet0 + (get_local $$_0$1) + ) + (drop + (get_global $tempRet0) + ) ) (get_local $$_0$0) ) diff --git a/test/unit.fromasm b/test/unit.fromasm index daaf1359d..31c1d5b3d 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -519,4 +519,22 @@ ) (call $phi) ) + (func $useSetGlobal (result i32) + (set_global $Int + (i32.const 10) + ) + (set_global $Int + (i32.const 20) + ) + (set_global $Int + (i32.const 30) + ) + (get_global $Int) + ) + (func $usesSetGlobal2 (result i32) + (set_global $Int + (i32.const 40) + ) + (i32.const 50) + ) ) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index b2c79ff79..2e9ea8243 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -501,4 +501,22 @@ ) (call $phi) ) + (func $useSetGlobal (result i32) + (set_global $Int + (i32.const 10) + ) + (set_global $Int + (i32.const 20) + ) + (set_global $Int + (i32.const 30) + ) + (get_global $Int) + ) + (func $usesSetGlobal2 (result i32) + (set_global $Int + (i32.const 40) + ) + (i32.const 50) + ) ) diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts index f8f028164..bec8a4f58 100644 --- a/test/unit.fromasm.imprecise.no-opts +++ b/test/unit.fromasm.imprecise.no-opts @@ -870,6 +870,43 @@ (call $phi) ) ) + (func $useSetGlobal (result i32) + (local $x i32) + (set_local $x + (block + (set_global $Int + (i32.const 10) + ) + (get_global $Int) + ) + ) + (set_global $Int + (i32.const 20) + ) + (return + (block + (set_global $Int + (i32.const 30) + ) + (get_global $Int) + ) + ) + ) + (func $usesSetGlobal2 (result i32) + (return + (block + (block + (set_global $Int + (i32.const 40) + ) + (drop + (get_global $Int) + ) + ) + (i32.const 50) + ) + ) + ) (func $z (nop) ) diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts index 650f20c51..936601995 100644 --- a/test/unit.fromasm.no-opts +++ b/test/unit.fromasm.no-opts @@ -876,6 +876,43 @@ (call $phi) ) ) + (func $useSetGlobal (result i32) + (local $x i32) + (set_local $x + (block + (set_global $Int + (i32.const 10) + ) + (get_global $Int) + ) + ) + (set_global $Int + (i32.const 20) + ) + (return + (block + (set_global $Int + (i32.const 30) + ) + (get_global $Int) + ) + ) + ) + (func $usesSetGlobal2 (result i32) + (return + (block + (block + (set_global $Int + (i32.const 40) + ) + (drop + (get_global $Int) + ) + ) + (i32.const 50) + ) + ) + ) (func $z (nop) ) |