diff options
author | Alon Zakai <azakai@google.com> | 2020-07-28 11:08:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 11:08:17 -0700 |
commit | 63d60fef3b07a343e21fb4bb8227c4e674633704 (patch) | |
tree | 38237feec2af4db045d387adbc03931239f5ec63 /src/ir | |
parent | 26f240c72dd62ed8a39f7466df99e51ec34487aa (diff) | |
download | binaryen-63d60fef3b07a343e21fb4bb8227c4e674633704.tar.gz binaryen-63d60fef3b07a343e21fb4bb8227c4e674633704.tar.bz2 binaryen-63d60fef3b07a343e21fb4bb8227c4e674633704.zip |
Fix the side effects of data.drop (#2996)
We marked it as readsMemory so that it could be reordered with various
things, except for memory.init. However, the fuzzer found that's not quite
right, as it has a global side effect - memory.inits that run later can notice
that. So it can't be reordered with anything that might affect global side
effects from happening, as in the testcase added here (an instruction that
may trap cannot be reordered with a data.drop, as it may prevent the
data.drop from happening and changing global state).
There may be a way to optimize this more carefully that would allow more
optimizations, but as this is a rare instruction I'm not sure it's worth more
work.
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/effects.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index f6c87a4e5..9d6e90936 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -392,8 +392,10 @@ struct EffectAnalyzer } } void visitDataDrop(DataDrop* curr) { - // prevent reordering with memory.init - readsMemory = true; + // data.drop does not actually write memory, but it does alter the size of + // a segment, which can be noticeable later by memory.init, so we need to + // mark it as having a global side effect of some kind. + writesMemory = true; if (!ignoreImplicitTraps) { implicitTrap = true; } |