From f82e708ee048d5a17d9cf04d205985b32719276e Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 3 Jul 2019 15:00:44 -0700 Subject: Loosen conditions on MemoryPacking (#2205) Allow MemoryPacking to run when there are no passive segments, even if bulk memory is enabled. --- src/passes/MemoryPacking.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp index 99eb2e285..0b24379e5 100644 --- a/src/passes/MemoryPacking.cpp +++ b/src/passes/MemoryPacking.cpp @@ -28,12 +28,20 @@ struct MemoryPacking : public Pass { bool modifiesBinaryenIR() override { return false; } void run(PassRunner* runner, Module* module) override { - // Conservatively refuse to change segments if bulk memory is enabled to - // avoid invalidating segment indices or segment contents referenced from + if (!module->memory.exists) { + return; + } + + // Conservatively refuse to change segments if any are passive to avoid + // invalidating segment indices or segment contents referenced from // memory.init instructions. // TODO: optimize in the presence of memory.init instructions - if (!module->memory.exists || module->features.hasBulkMemory()) { - return; + if (module->features.hasBulkMemory()) { + for (auto segment : module->memory.segments) { + if (segment.isPassive) { + return; + } + } } std::vector packed; -- cgit v1.2.3