Skip to content

Commit 0c4917c

Browse files
committed
[NFC] OSSACompleteLifetime: Extracted method.
In preparation to expand it.
1 parent 09efe03 commit 0c4917c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

include/swift/SIL/OSSALifetimeCompletion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class OSSALifetimeCompletion {
134134

135135
protected:
136136
bool analyzeAndUpdateLifetime(SILValue value, Boundary boundary);
137+
bool analyzeAndUpdateLifetime(ScopedAddressValue value, Boundary boundary);
137138
};
138139

139140
//===----------------------------------------------------------------------===//

lib/SIL/Utils/OSSALifetimeCompletion.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,22 @@ static bool endLifetimeAtBoundary(SILValue value,
439439
return changed;
440440
}
441441

442+
bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(
443+
ScopedAddressValue scopedAddress, Boundary boundary) {
444+
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
445+
SSAPrunedLiveness liveness(scopedAddress->getFunction(), &discoveredBlocks);
446+
scopedAddress.computeTransitiveLiveness(liveness);
447+
return endLifetimeAtBoundary(scopedAddress.value, liveness, boundary,
448+
deadEndBlocks);
449+
}
450+
442451
/// End the lifetime of \p value at unreachable instructions.
443452
///
444453
/// Returns true if any new instructions were created to complete the lifetime.
445454
bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value,
446455
Boundary boundary) {
447456
if (auto scopedAddress = ScopedAddressValue(value)) {
448-
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
449-
SSAPrunedLiveness liveness(value->getFunction(), &discoveredBlocks);
450-
scopedAddress.computeTransitiveLiveness(liveness);
451-
return endLifetimeAtBoundary(value, liveness, boundary, deadEndBlocks);
457+
return analyzeAndUpdateLifetime(scopedAddress, boundary);
452458
}
453459

454460
// Called for inner borrows, inner adjacent reborrows, inner reborrows, and

0 commit comments

Comments
 (0)