summaryrefslogtreecommitdiff
path: root/test/wasm2js/br.2asm.js
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-10-26 18:43:29 -0700
committerGitHub <noreply@github.com>2020-10-26 18:43:29 -0700
commitf3125579cca998300c230232ed4ded4fe0aaa34c (patch)
treeaeceb7770b47fe8d5eef0f38e26fa540b67db482 /test/wasm2js/br.2asm.js
parent514a6c5eb339b67db852643405428f3add7d0e39 (diff)
downloadbinaryen-f3125579cca998300c230232ed4ded4fe0aaa34c.tar.gz
binaryen-f3125579cca998300c230232ed4ded4fe0aaa34c.tar.bz2
binaryen-f3125579cca998300c230232ed4ded4fe0aaa34c.zip
Rewrite DCE pass (#3274)
The DCE pass is one of the oldest in binaryen, and had quite a lot of cruft from the changes in unreachability and other stuff in wasm and binaryen's history. This PR rewrites it from scratch, making it about 1/3 the size. I noticed this when looking for places to use code autogeneration. The old version had annoying boilerplate, while the new one avoids any need for it. There may be noticeable differences, as the old pass did more than it needed to. It overlapped with remove-unused-names for some reason I don't remember. The new pass leaves that to the other pass to do. I added another run of remove-unused-names to avoid noticeable differences in optimized builds, but you can see differences in the testcases that only run DCE by itself. (The test differences in this PR are mostly whitespace.) (The overlap is that if a block ended up not needed, that is, all branches to it were removed, the old DCE would remove the block.) This pass is about 15% faster than the old version. However, when adding another run of remove-unused-names the difference basically vanishes, so this isn't a speedup.
Diffstat (limited to 'test/wasm2js/br.2asm.js')
-rw-r--r--test/wasm2js/br.2asm.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/test/wasm2js/br.2asm.js b/test/wasm2js/br.2asm.js
index 73484e457..c60de9fc2 100644
--- a/test/wasm2js/br.2asm.js
+++ b/test/wasm2js/br.2asm.js
@@ -106,8 +106,10 @@ function asmFunc(global, env) {
function $13() {
var $0 = 0, $1_1 = 0, $3_1 = 0;
block : {
- $0 = 3;
- break block;
+ loop_in : while (1) {
+ $0 = 3;
+ break block;
+ };
}
return $0 | 0;
}
@@ -115,9 +117,11 @@ function asmFunc(global, env) {
function $14() {
var $0 = 0, $1_1 = 0, $3_1 = 0;
block : {
- dummy();
- $0 = 4;
- break block;
+ loop_in : while (1) {
+ dummy();
+ $0 = 4;
+ break block;
+ };
}
return $0 | 0;
}
@@ -125,9 +129,11 @@ function asmFunc(global, env) {
function $15() {
var $0 = 0;
block : {
- dummy();
- $0 = 5;
- break block;
+ loop_in : while (1) {
+ dummy();
+ $0 = 5;
+ break block;
+ };
}
return $0 | 0;
}