@@ -419,6 +419,11 @@ static bool endLifetimeAtAvailabilityBoundary(SILValue value,
419
419
return changed;
420
420
}
421
421
422
+ static bool endLifetimeAtBoundary (SILValue value,
423
+ SSAPrunedLiveness const &liveness,
424
+ OSSALifetimeCompletion::Boundary boundary,
425
+ DeadEndBlocks &deadEndBlocks);
426
+
422
427
// / End the lifetime of \p value at unreachable instructions.
423
428
// /
424
429
// / Returns true if any new instructions were created to complete the lifetime.
@@ -431,23 +436,29 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value,
431
436
};
432
437
InteriorLiveness liveness (value);
433
438
liveness.compute (domInfo, handleInnerScope);
439
+ // TODO: Rebuild outer adjacent phis on demand (SILGen does not currently
440
+ // produce guaranteed phis). See FindEnclosingDefs &
441
+ // findSuccessorDefsFromPredDefs. If no enclosing phi is found, we can create
442
+ // it here and use updateSSA to recursively populate phis.
443
+ assert (liveness.getUnenclosedPhis ().empty ());
444
+ return endLifetimeAtBoundary (value, liveness.getLiveness (), boundary,
445
+ deadEndBlocks);
446
+ }
434
447
448
+ static bool endLifetimeAtBoundary (SILValue value,
449
+ SSAPrunedLiveness const &liveness,
450
+ OSSALifetimeCompletion::Boundary boundary,
451
+ DeadEndBlocks &deadEndBlocks) {
435
452
bool changed = false ;
436
453
switch (boundary) {
437
- case Boundary::Liveness:
438
- changed |= endLifetimeAtLivenessBoundary (value, liveness.getLiveness (),
439
- deadEndBlocks);
454
+ case OSSALifetimeCompletion::Boundary::Liveness:
455
+ changed |= endLifetimeAtLivenessBoundary (value, liveness, deadEndBlocks);
440
456
break ;
441
- case Boundary::Availability:
442
- changed |= endLifetimeAtAvailabilityBoundary (value, liveness. getLiveness (),
443
- deadEndBlocks);
457
+ case OSSALifetimeCompletion:: Boundary::Availability:
458
+ changed |=
459
+ endLifetimeAtAvailabilityBoundary (value, liveness, deadEndBlocks);
444
460
break ;
445
461
}
446
- // TODO: Rebuild outer adjacent phis on demand (SILGen does not currently
447
- // produce guaranteed phis). See FindEnclosingDefs &
448
- // findSuccessorDefsFromPredDefs. If no enclosing phi is found, we can create
449
- // it here and use updateSSA to recursively populate phis.
450
- assert (liveness.getUnenclosedPhis ().empty ());
451
462
return changed;
452
463
}
453
464
0 commit comments