diff options
Diffstat (limited to 'src/passes/MemoryPacking.cpp')
-rw-r--r-- | src/passes/MemoryPacking.cpp | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp index f98c25096..0b24379e5 100644 --- a/src/passes/MemoryPacking.cpp +++ b/src/passes/MemoryPacking.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include "ir/manipulation.h" -#include "ir/utils.h" #include "pass.h" #include "wasm-binary.h" #include "wasm-builder.h" @@ -34,13 +32,11 @@ struct MemoryPacking : public Pass { 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->features.hasBulkMemory()) { - // Remove any references to active segments that might be invalidated. - optimizeTrappingBulkMemoryOps(runner, module); - // Conservatively refuse to change segments if any are passive to avoid - // invalidating segment indices or segment contents referenced from - // memory.init and data.drop instructions. - // TODO: optimize in the presence of memory.init and data.drop for (auto segment : module->memory.segments) { if (segment.isPassive) { return; @@ -124,38 +120,6 @@ struct MemoryPacking : public Pass { } module->memory.segments.swap(packed); } - - void optimizeTrappingBulkMemoryOps(PassRunner* runner, Module* module) { - struct Trapper : WalkerPass<PostWalker<Trapper>> { - bool changed; - void visitMemoryInit(MemoryInit* curr) { - if (!getModule()->memory.segments[curr->segment].isPassive) { - Builder builder(*getModule()); - replaceCurrent(builder.blockify(builder.makeDrop(curr->dest), - builder.makeDrop(curr->offset), - builder.makeDrop(curr->size), - builder.makeUnreachable())); - changed = true; - } - } - void visitDataDrop(DataDrop* curr) { - if (!getModule()->memory.segments[curr->segment].isPassive) { - ExpressionManipulator::unreachable(curr); - changed = true; - } - } - void walkFunction(Function* func) { - changed = false; - PostWalker<Trapper>::walkFunction(func); - if (changed) { - ReFinalize().walkFunctionInModule(func, getModule()); - } - } - bool isFunctionParallel() override { return true; } - Pass* create() override { return new Trapper; } - } trapper; - trapper.run(runner, module); - } }; Pass* createMemoryPackingPass() { return new MemoryPacking(); } |