diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-01-26 11:04:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-26 11:04:47 -0800 |
commit | 8bcdfb20d73c931529a458fb0dd3078724c38315 (patch) | |
tree | 571916c0b08e22582f2079b5623cd5477c365977 /src/passes/CodePushing.cpp | |
parent | 21eb2c7cba6af6e01219f1f3b06e82dfcf2788e8 (diff) | |
download | binaryen-8bcdfb20d73c931529a458fb0dd3078724c38315.tar.gz binaryen-8bcdfb20d73c931529a458fb0dd3078724c38315.tar.bz2 binaryen-8bcdfb20d73c931529a458fb0dd3078724c38315.zip |
code-pushing fix: we cannot push a set_local with side effects, as it may not execute any more (#890)
Diffstat (limited to 'src/passes/CodePushing.cpp')
-rw-r--r-- | src/passes/CodePushing.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp index 397a20bab..f4beff1a8 100644 --- a/src/passes/CodePushing.cpp +++ b/src/passes/CodePushing.cpp @@ -115,7 +115,14 @@ private: auto* set = curr->dynCast<SetLocal>(); if (!set) return nullptr; auto index = set->index; - return analyzer.isSFA(index) && numGetsSoFar[index] == analyzer.getNumGets(index) ? set : nullptr; + // to be pushable, this must be SFA and the right # of gets, + // but also have no side effects, as it may not execute if pushed. + if (analyzer.isSFA(index) && + numGetsSoFar[index] == analyzer.getNumGets(index) && + !EffectAnalyzer(set->value).hasSideEffects()) { + return set; + } + return nullptr; } // Push past conditional control flow. |