@@ -227,9 +227,6 @@ struct StringLowering : public StringGathering {
227
227
// Replace string.* etc. operations with imported ones.
228
228
replaceInstructions (module);
229
229
230
- // Replace ref.null types as needed.
231
- replaceNulls (module);
232
-
233
230
// ReFinalize to apply all the above changes.
234
231
ReFinalize ().run (getPassRunner (), module);
235
232
@@ -495,61 +492,6 @@ struct StringLowering : public StringGathering {
495
492
replacer.run (getPassRunner (), module);
496
493
replacer.walkModuleCode (module);
497
494
}
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
- }
553
495
};
554
496
555
497
Pass* createStringGatheringPass () { return new StringGathering (); }
0 commit comments