diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-12 18:55:36 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-12 18:58:01 -0800 |
commit | 125256db5c00421c00ef2afbb0e909a81ab3d1d1 (patch) | |
tree | 361147c46856c1792f627e12089bcd79004ab836 /tools | |
parent | 07ac727a607703a2688cbc58e560f6d3d70e3874 (diff) |
do not try to eliminate phi variables, which are unsafe to be removed and the llvm optimizer will remove anyhow if unused
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 8 | ||||
-rw-r--r-- | tools/eliminator/eliminator-test.js | 12 | ||||
-rw-r--r-- | tools/js-optimizer.js | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index ede34103..01f092d5 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -6132,4 +6132,12 @@ function _mallocNoU($bytes) { return $mem_0; return null; } +function phi() { + if (wat()) { + var $10 = 1; + } else { + var $10 = (_init_mparams() | 0) != 0; + } + var $10; +} diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index e44f28ad..8b376305 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -8828,5 +8828,15 @@ function _mallocNoU($bytes) { return $mem_0; return null; } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU"] +function phi() { + if (wat()) { + var $10 = 1; + } else { + var $7=_init_mparams(); + var $8=(($7)|0)!=0; + var $10 = $8; + } + var $10; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 29aecdcf..62161738 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1464,7 +1464,7 @@ function eliminate(ast, memSafe) { for (var name in locals) { if (definitions[name] == 1 && uses[name] == 1) { potentials[name] = 1; - } else if (uses[name] == 0) { + } else if (uses[name] == 0 && (!definitions[name] || definitions[name] <= 1)) { // no uses, no def or 1 def (cannot operate on phis, and the llvm optimizer will remove unneeded phis anyhow) var hasSideEffects = false; if (values[name]) { traverse(values[name], function(node, type) { |