@@ -123,12 +123,7 @@ static void extendLifetimeToEndOfFunction(SILFunction &Fn,
123
123
auto OptionalEscapingClosureTy = SILType::getOptionalType (EscapingClosureTy);
124
124
auto loc = RegularLocation::getAutoGeneratedLocation ();
125
125
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 ();
132
127
133
128
// If our Cvt is in the initial block, we do not need to use the SSA updater
134
129
// since we know Cvt can not be in a loop and must dominate all exits
@@ -417,14 +412,7 @@ static bool tryExtendLifetimeToLastUse(
417
412
// Insert a copy at the convert_escape_to_noescape [not_guaranteed] and
418
413
// change the instruction to the guaranteed form.
419
414
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 ();
428
416
429
417
SILBuilderWithScope B2 (Cvt);
430
418
auto ClosureCopy = B2.createCopyValue (loc, EscapingClosure);
@@ -510,14 +498,7 @@ static bool trySwitchEnumPeephole(ConvertEscapeToNoEscapeInst *Cvt) {
510
498
if (!onlyDestroy)
511
499
return false ;
512
500
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 ();
521
502
522
503
// Extend the lifetime.
523
504
SILBuilderWithScope B (SwitchEnum1);
0 commit comments