Skip to content

Commit e89fd0e

Browse files
authored
[NFC] Remove StringLowering::replaceNulls (#7607)
Now that `string` is a subtype of `extern`, the null type for strings and externrefs is the same, so we no longer need to fix up nulls in StringLowering. Unblocks #7601.
1 parent 5816d69 commit e89fd0e

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

src/passes/StringLowering.cpp

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ struct StringLowering : public StringGathering {
227227
// Replace string.* etc. operations with imported ones.
228228
replaceInstructions(module);
229229

230-
// Replace ref.null types as needed.
231-
replaceNulls(module);
232-
233230
// ReFinalize to apply all the above changes.
234231
ReFinalize().run(getPassRunner(), module);
235232

@@ -495,61 +492,6 @@ struct StringLowering : public StringGathering {
495492
replacer.run(getPassRunner(), module);
496493
replacer.walkModuleCode(module);
497494
}
498-
499-
// A ref.null of none needs to be noext if it is going to a location of type
500-
// stringref.
501-
void replaceNulls(Module* module) {
502-
// Use SubtypingDiscoverer to find when a ref.null of none flows into a
503-
// place that has been changed from stringref to externref.
504-
struct NullFixer
505-
: public WalkerPass<
506-
ControlFlowWalker<NullFixer, SubtypingDiscoverer<NullFixer>>> {
507-
// Hooks for SubtypingDiscoverer.
508-
void noteSubtype(Type, Type) {
509-
// Nothing to do for pure types.
510-
}
511-
void noteSubtype(HeapType, HeapType) {
512-
// Nothing to do for pure types.
513-
}
514-
void noteSubtype(Type, Expression*) {
515-
// Nothing to do for a subtype of an expression.
516-
}
517-
void noteSubtype(Expression* a, Type b) {
518-
// This is the case we care about: if |a| is a null that must be a
519-
// subtype of ext then we fix that up.
520-
if (!b.isRef()) {
521-
return;
522-
}
523-
HeapType top = b.getHeapType().getTop();
524-
if (top.isMaybeShared(HeapType::ext)) {
525-
if (auto* null = a->dynCast<RefNull>()) {
526-
null->finalize(HeapTypes::noext.getBasic(top.getShared()));
527-
}
528-
}
529-
}
530-
void noteSubtype(Expression* a, Expression* b) {
531-
// Only the type matters of the place we assign to.
532-
noteSubtype(a, b->type);
533-
}
534-
void noteNonFlowSubtype(Expression* a, Type b) {
535-
// Flow or non-flow is the same for us.
536-
noteSubtype(a, b);
537-
}
538-
void noteCast(HeapType, HeapType) {
539-
// Casts do not concern us.
540-
}
541-
void noteCast(Expression*, Type) {
542-
// Casts do not concern us.
543-
}
544-
void noteCast(Expression*, Expression*) {
545-
// Casts do not concern us.
546-
}
547-
};
548-
549-
NullFixer fixer;
550-
fixer.run(getPassRunner(), module);
551-
fixer.walkModuleCode(module);
552-
}
553495
};
554496

555497
Pass* createStringGatheringPass() { return new StringGathering(); }

0 commit comments

Comments
 (0)