summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-05-17 19:11:02 -0700
committerGitHub <noreply@github.com>2019-05-17 19:11:02 -0700
commitd6a6188493031c5f6bbe2ca49860c9d9df962752 (patch)
treee66a654222799cac1186572edd29f49e7359e747 /src
parentf4fd88496db1a217954abc0509393c9523c3c1d3 (diff)
downloadbinaryen-d6a6188493031c5f6bbe2ca49860c9d9df962752.tar.gz
binaryen-d6a6188493031c5f6bbe2ca49860c9d9df962752.tar.bz2
binaryen-d6a6188493031c5f6bbe2ca49860c9d9df962752.zip
Fix a vacuum bug with loads changing the type (#2124)
This happened on wasm2js, where implicit traps are off by default, and this bug is specific to that (less-tested) mode.
Diffstat (limited to 'src')
-rw-r--r--src/passes/Vacuum.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp
index 43a5f8a09..0e01c0370 100644
--- a/src/passes/Vacuum.cpp
+++ b/src/passes/Vacuum.cpp
@@ -96,9 +96,12 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> {
// it is ok to remove a load if the result is not used, and it has no
// side effects (the load itself may trap, if we are not ignoring such
// things)
+ auto* load = curr->cast<Load>();
if (!resultUsed &&
!EffectAnalyzer(getPassOptions(), curr).hasSideEffects()) {
- return curr->cast<Load>()->ptr;
+ if (!typeMatters || load->ptr->type == type) {
+ return load->ptr;
+ }
}
return curr;
}