diff --git a/src/passes/StringLowering.cpp b/src/passes/StringLowering.cpp index 84dfb7cb049..993b8de6f87 100644 --- a/src/passes/StringLowering.cpp +++ b/src/passes/StringLowering.cpp @@ -227,9 +227,6 @@ struct StringLowering : public StringGathering { // Replace string.* etc. operations with imported ones. replaceInstructions(module); - // Replace ref.null types as needed. - replaceNulls(module); - // ReFinalize to apply all the above changes. ReFinalize().run(getPassRunner(), module); @@ -495,61 +492,6 @@ struct StringLowering : public StringGathering { replacer.run(getPassRunner(), module); replacer.walkModuleCode(module); } - - // A ref.null of none needs to be noext if it is going to a location of type - // stringref. - void replaceNulls(Module* module) { - // Use SubtypingDiscoverer to find when a ref.null of none flows into a - // place that has been changed from stringref to externref. - struct NullFixer - : public WalkerPass< - ControlFlowWalker>> { - // Hooks for SubtypingDiscoverer. - void noteSubtype(Type, Type) { - // Nothing to do for pure types. - } - void noteSubtype(HeapType, HeapType) { - // Nothing to do for pure types. - } - void noteSubtype(Type, Expression*) { - // Nothing to do for a subtype of an expression. - } - void noteSubtype(Expression* a, Type b) { - // This is the case we care about: if |a| is a null that must be a - // subtype of ext then we fix that up. - if (!b.isRef()) { - return; - } - HeapType top = b.getHeapType().getTop(); - if (top.isMaybeShared(HeapType::ext)) { - if (auto* null = a->dynCast()) { - null->finalize(HeapTypes::noext.getBasic(top.getShared())); - } - } - } - void noteSubtype(Expression* a, Expression* b) { - // Only the type matters of the place we assign to. - noteSubtype(a, b->type); - } - void noteNonFlowSubtype(Expression* a, Type b) { - // Flow or non-flow is the same for us. - noteSubtype(a, b); - } - void noteCast(HeapType, HeapType) { - // Casts do not concern us. - } - void noteCast(Expression*, Type) { - // Casts do not concern us. - } - void noteCast(Expression*, Expression*) { - // Casts do not concern us. - } - }; - - NullFixer fixer; - fixer.run(getPassRunner(), module); - fixer.walkModuleCode(module); - } }; Pass* createStringGatheringPass() { return new StringGathering(); }