@@ -123,12 +123,7 @@ static void extendLifetimeToEndOfFunction(SILFunction &Fn,
123123 auto OptionalEscapingClosureTy = SILType::getOptionalType (EscapingClosureTy);
124124 auto loc = RegularLocation::getAutoGeneratedLocation ();
125125
126- SILBuilderWithScope B (Cvt);
127- auto NewCvt = B.createConvertEscapeToNoEscape (
128- Cvt->getLoc (), Cvt->getOperand (), Cvt->getType (), true );
129- Cvt->replaceAllUsesWith (NewCvt);
130- Cvt->eraseFromParent ();
131- Cvt = NewCvt;
126+ Cvt->setLifetimeGuaranteed ();
132127
133128 // If our Cvt is in the initial block, we do not need to use the SSA updater
134129 // since we know Cvt can not be in a loop and must dominate all exits
@@ -417,14 +412,7 @@ static bool tryExtendLifetimeToLastUse(
417412 // Insert a copy at the convert_escape_to_noescape [not_guaranteed] and
418413 // change the instruction to the guaranteed form.
419414 auto EscapingClosure = Cvt->getOperand ();
420- {
421- SILBuilderWithScope B (Cvt);
422- auto NewCvt = B.createConvertEscapeToNoEscape (
423- Cvt->getLoc (), Cvt->getOperand (), Cvt->getType (), true );
424- Cvt->replaceAllUsesWith (NewCvt);
425- Cvt->eraseFromParent ();
426- Cvt = NewCvt;
427- }
415+ Cvt->setLifetimeGuaranteed ();
428416
429417 SILBuilderWithScope B2 (Cvt);
430418 auto ClosureCopy = B2.createCopyValue (loc, EscapingClosure);
@@ -510,14 +498,7 @@ static bool trySwitchEnumPeephole(ConvertEscapeToNoEscapeInst *Cvt) {
510498 if (!onlyDestroy)
511499 return false ;
512500
513- // Replace the convert_escape_to_noescape instruction.
514- {
515- SILBuilderWithScope B (Cvt);
516- auto NewCvt = B.createConvertEscapeToNoEscape (
517- Cvt->getLoc (), Cvt->getOperand (), Cvt->getType (), true );
518- Cvt->replaceAllUsesWith (NewCvt);
519- Cvt->eraseFromParent ();
520- }
501+ Cvt->setLifetimeGuaranteed ();
521502
522503 // Extend the lifetime.
523504 SILBuilderWithScope B (SwitchEnum1);
0 commit comments