From 63d60fef3b07a343e21fb4bb8227c4e674633704 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 28 Jul 2020 11:08:17 -0700 Subject: 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. --- src/ir/effects.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3