@@ -480,16 +480,12 @@ SILBuilder::emitDestroyValue(SILLocation Loc, SILValue Operand) {
480
480
481
481
SILValue SILBuilder::emitThickToObjCMetatype (SILLocation Loc, SILValue Op,
482
482
SILType Ty) {
483
- // If the operand is an otherwise-unused 'metatype' instruction in the
484
- // same basic block, zap it and create a 'metatype' instruction that
485
- // directly produces an Objective-C metatype .
483
+ // If the operand is a 'metatype' instruction accessing a known static type's
484
+ // metadata, create a 'metatype' instruction that
485
+ // directly produces the Objective-C class object representation instead .
486
486
if (auto metatypeInst = dyn_cast<MetatypeInst>(Op)) {
487
- if (metatypeInst->use_empty () &&
488
- metatypeInst->getParent () == getInsertionBB ()) {
489
- auto origLoc = metatypeInst->getLoc ();
490
- metatypeInst->eraseFromParent ();
491
- return createMetatype (origLoc, Ty);
492
- }
487
+ auto origLoc = metatypeInst->getLoc ();
488
+ return createMetatype (origLoc, Ty);
493
489
}
494
490
495
491
// Just create the thick_to_objc_metatype instruction.
@@ -498,16 +494,12 @@ SILValue SILBuilder::emitThickToObjCMetatype(SILLocation Loc, SILValue Op,
498
494
499
495
SILValue SILBuilder::emitObjCToThickMetatype (SILLocation Loc, SILValue Op,
500
496
SILType Ty) {
501
- // If the operand is an otherwise-unused 'metatype' instruction in the
502
- // same basic block, zap it and create a 'metatype' instruction that
503
- // directly produces a thick metatype .
497
+ // If the operand is a 'metatype' instruction accessing a known static type's
498
+ // metadata, create a 'metatype' instruction that directly produces the
499
+ // Swift metatype representation instead .
504
500
if (auto metatypeInst = dyn_cast<MetatypeInst>(Op)) {
505
- if (metatypeInst->use_empty () &&
506
- metatypeInst->getParent () == getInsertionBB ()) {
507
- auto origLoc = metatypeInst->getLoc ();
508
- metatypeInst->eraseFromParent ();
509
- return createMetatype (origLoc, Ty);
510
- }
501
+ auto origLoc = metatypeInst->getLoc ();
502
+ return createMetatype (origLoc, Ty);
511
503
}
512
504
513
505
// Just create the objc_to_thick_metatype instruction.
0 commit comments