Skip to content

Commit 36203de

Browse files
committed
[NFC] OSSACompleteLifetime: Extracted function.
In preparation for adding a second caller.
1 parent c47c8ea commit 36203de

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

lib/SIL/Utils/OSSALifetimeCompletion.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ static bool endLifetimeAtAvailabilityBoundary(SILValue value,
419419
return changed;
420420
}
421421

422+
static bool endLifetimeAtBoundary(SILValue value,
423+
SSAPrunedLiveness const &liveness,
424+
OSSALifetimeCompletion::Boundary boundary,
425+
DeadEndBlocks &deadEndBlocks);
426+
422427
/// End the lifetime of \p value at unreachable instructions.
423428
///
424429
/// Returns true if any new instructions were created to complete the lifetime.
@@ -431,23 +436,29 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value,
431436
};
432437
InteriorLiveness liveness(value);
433438
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+
}
434447

448+
static bool endLifetimeAtBoundary(SILValue value,
449+
SSAPrunedLiveness const &liveness,
450+
OSSALifetimeCompletion::Boundary boundary,
451+
DeadEndBlocks &deadEndBlocks) {
435452
bool changed = false;
436453
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);
440456
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);
444460
break;
445461
}
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());
451462
return changed;
452463
}
453464

0 commit comments

Comments
 (0)