@@ -469,85 +469,6 @@ struct GlobalLogic : public Logic {
469469 }
470470};
471471
472- // Optimize memory stores/loads.
473- struct MemoryLogic : public ComparingLogic {
474- MemoryLogic (Function* func, PassOptions& passOptions, Module& wasm)
475- : ComparingLogic(func, passOptions, wasm) {}
476-
477- bool isStore (Expression* curr) { return curr->is <Store>(); }
478-
479- bool isLoad (Expression* curr) { return curr->is <Load>(); }
480-
481- bool mayInteract (Expression* curr, const ShallowEffectAnalyzer& currEffects) {
482- return currEffects.readsMemory || currEffects.writesMemory ;
483- }
484-
485- bool isLoadFrom (Expression* curr,
486- const ShallowEffectAnalyzer& currEffects,
487- Expression* store_) {
488- if (curr->type == Type::unreachable) {
489- return false ;
490- }
491- if (auto * load = curr->dynCast <Load>()) {
492- auto * store = store_->cast <Store>();
493-
494- // Atomic stores are dangerous, since they have additional trapping
495- // behavior - they trap on unaligned addresses. For simplicity, only
496- // consider the case where atomicity is identical.
497- // TODO: use ignoreImplicitTraps
498- if (store->isAtomic () != load->isAtomic ()) {
499- return false ;
500- }
501-
502- // TODO: For now, only handle the obvious case where the operations are
503- // identical in size and offset.
504- return load->bytes == store->bytes &&
505- load->bytes == load->type .getByteSize () &&
506- load->offset == store->offset &&
507- localGraph.equalValues (load->ptr , store->ptr );
508- }
509- return false ;
510- }
511-
512- bool isTrample (Expression* curr,
513- const ShallowEffectAnalyzer& currEffects,
514- Expression* store_) {
515- if (auto * otherStore = curr->dynCast <Store>()) {
516- auto * store = store_->cast <Store>();
517-
518- // As in isLoadFrom, atomic stores are dangerous.
519- if (store->isAtomic () != otherStore->isAtomic ()) {
520- return false ;
521- }
522-
523- // TODO: Compare in detail. For now, handle the obvious case where the
524- // stores are identical in size, offset, etc., so that identical
525- // repeat stores are handled. (An example of a case we do not handle
526- // yet is a store of 1 byte that is trampled by a store of 2 bytes.)
527- return otherStore->bytes == store->bytes &&
528- otherStore->offset == store->offset &&
529- localGraph.equalValues (otherStore->ptr , store->ptr );
530- }
531- return false ;
532- }
533-
534- bool mayInteractWith (Expression* curr,
535- const ShallowEffectAnalyzer& currEffects,
536- Expression* store) {
537- // Anything we did not identify so far is dangerous.
538- //
539- // Among other things, this includes compare-and-swap, which does both a
540- // read and a write, which our infrastructure is not build to optimize.
541- return currEffects.readsMemory || currEffects.writesMemory ;
542- }
543-
544- Expression* replaceStoreWithDrops (Expression* store, Builder& builder) {
545- auto * castStore = store->cast <Store>();
546- return builder.makeSequence (builder.makeDrop (castStore->ptr ),
547- builder.makeDrop (castStore->value ));
548- }
549- };
550-
551472// Optimize GC data: StructGet/StructSet.
552473// TODO: Arrays.
553474struct GCLogic : public ComparingLogic {
@@ -663,9 +584,6 @@ struct LocalDeadStoreElimination
663584 // Optimize globals.
664585 DeadStoreCFG<GlobalLogic>(*getModule (), func, getPassOptions ()).optimize ();
665586
666- // Optimize memory.
667- DeadStoreCFG<MemoryLogic>(*getModule (), func, getPassOptions ()).optimize ();
668-
669587 // Optimize GC heap.
670588 if (getModule ()->features .hasGC ()) {
671589 DeadStoreCFG<GCLogic>(*getModule (), func, getPassOptions ()).optimize ();
0 commit comments