Skip to content

Commit ae64ff5

Browse files
committed
Rename PrunedLiveness.clear() to invalidate()
Because SILBitfield cannot be cleared.
1 parent 15796e3 commit ae64ff5

9 files changed

+25
-23
lines changed

include/swift/SIL/PrunedLiveness.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ class PrunedLiveness {
488488
return liveBlocks.empty();
489489
}
490490

491-
void clear() {
492-
liveBlocks.clear();
491+
void invalidate() {
492+
liveBlocks.invalidate();
493493
users.clear();
494494
}
495495

@@ -752,10 +752,10 @@ class SSAPrunedLiveness : public PrunedLiveRange<SSAPrunedLiveness> {
752752

753753
SILValue getDef() const { return def; }
754754

755-
void clear() {
755+
void invalidate() {
756756
def = SILValue();
757757
defInst = nullptr;
758-
PrunedLiveRange::clear();
758+
PrunedLiveRange::invalidate();
759759
}
760760

761761
void initializeDef(SILValue def) {
@@ -820,8 +820,10 @@ class MultiDefPrunedLiveness : public PrunedLiveRange<MultiDefPrunedLiveness> {
820820
: PrunedLiveRange(function, discoveredBlocks), defs(function),
821821
defBlocks(function) {}
822822

823-
void clear() {
824-
llvm_unreachable("multi-def liveness cannot be reused");
823+
void invalidate() {
824+
defs.invalidate();
825+
defBlocks.invalidate();
826+
PrunedLiveRange::invalidate();
825827
}
826828

827829
void initializeDef(SILInstruction *defInst) {
@@ -895,8 +897,8 @@ class DiagnosticPrunedLiveness : public SSAPrunedLiveness {
895897
: SSAPrunedLiveness(function, discoveredBlocks),
896898
nonLifetimeEndingUsesInLiveOut(nonLifetimeEndingUsesInLiveOut) {}
897899

898-
void clear() {
899-
SSAPrunedLiveness::clear();
900+
void invalidate() {
901+
SSAPrunedLiveness::invalidate();
900902
if (nonLifetimeEndingUsesInLiveOut)
901903
nonLifetimeEndingUsesInLiveOut->clear();
902904
}

include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ class CanonicalizeOSSALifetime final {
302302
liveness.initializeDef(def);
303303
}
304304

305-
void clearLiveness() {
305+
void invalidateLiveness() {
306306
consumingBlocks.clear();
307307
debugValues.clear();
308-
liveness.clear();
308+
liveness.invalidate();
309309
discoveredBlocks.clear();
310310
}
311311

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ class GuaranteedOwnershipExtension {
115115
: deleter(deleter), deBlocks(deBlocks),
116116
guaranteedLiveness(function), ownedLifetime(function) {}
117117

118-
void clear() {
119-
guaranteedLiveness.clear();
120-
ownedLifetime.clear();
118+
void invalidate() {
119+
guaranteedLiveness.invalidate();
120+
ownedLifetime.invalidate();
121121
ownedConsumeBlocks.clear();
122122
beginBorrow = nullptr;
123123
}

lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct CheckerLivenessInfo {
7878

7979
void clear() {
8080
defUseWorklist.clear();
81-
liveness.clear();
81+
liveness.invalidate();
8282
consumingUse.clear();
8383
interiorPointerTransitiveUses.clear();
8484
nonLifetimeEndingUsesInLiveOut.clear();

lib/SILOptimizer/Mandatory/DiagnoseLifetimeIssues.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static bool isOutOfLifetime(SILInstruction *inst, SSAPrunedLiveness &liveness) {
326326
/// Reports a warning if the stored object \p storedObj is never loaded within
327327
/// the lifetime of the stored object.
328328
void DiagnoseLifetimeIssues::reportDeadStore(SILInstruction *allocationInst) {
329-
liveness.clear();
329+
liveness.invalidate();
330330
weakStores.clear();
331331

332332
SILValue storedDef = cast<SingleValueInstruction>(allocationInst);

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ struct GatherUsesVisitor : public AccessUseVisitor {
12921292

12931293
/// Returns true if we emitted an error.
12941294
bool checkForExclusivityHazards(LoadInst *li) {
1295-
SWIFT_DEFER { liveness.clear(); };
1295+
SWIFT_DEFER { liveness.invalidate(); };
12961296

12971297
LLVM_DEBUG(llvm::dbgs() << "Checking for exclusivity hazards for: " << *li);
12981298

lib/SILOptimizer/Mandatory/MoveOnlyBorrowToDestructureUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ void Implementation::cleanup() {
15161516
if (result->getType().isTrivial(*fn))
15171517
continue;
15181518
SWIFT_DEFER {
1519-
liveness.clear();
1519+
liveness.invalidate();
15201520
discoveredBlocks.clear();
15211521
boundary.clear();
15221522
};
@@ -1534,7 +1534,7 @@ void Implementation::cleanup() {
15341534
continue;
15351535

15361536
SWIFT_DEFER {
1537-
liveness.clear();
1537+
liveness.invalidate();
15381538
discoveredBlocks.clear();
15391539
boundary.clear();
15401540
};
@@ -1888,7 +1888,7 @@ bool BorrowToDestructureTransform::transform() {
18881888
// If we have a copyable type, we need to insert compensating
18891889
// destroys.
18901890
SWIFT_DEFER {
1891-
liveness.clear();
1891+
liveness.invalidate();
18921892
discoveredBlocks.clear();
18931893
boundary.clear();
18941894
};

lib/SILOptimizer/Utils/CanonicalizeBorrowScope.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ bool CanonicalizeBorrowScope::canonicalizeFunctionArgument(
822822

823823
LLVM_DEBUG(llvm::dbgs() << "*** Canonicalize Borrow: " << borrowedValue);
824824

825-
SWIFT_DEFER { liveness.clear(); };
825+
SWIFT_DEFER { liveness.invalidate(); };
826826

827827
RewriteInnerBorrowUses innerRewriter(*this);
828828
beginVisitBorrowScopeUses(); // reset the def/use worklist
@@ -841,7 +841,7 @@ canonicalizeBorrowScope(BorrowedValue borrowedValue) {
841841

842842
initBorrow(borrowedValue);
843843

844-
SWIFT_DEFER { liveness.clear(); };
844+
SWIFT_DEFER { liveness.invalidate(); };
845845

846846
if (!computeBorrowLiveness())
847847
return false;

lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ bool CanonicalizeOSSALifetime::computeLiveness(SILValue def) {
10171017
// Step 1: compute liveness
10181018
if (!computeCanonicalLiveness()) {
10191019
LLVM_DEBUG(llvm::errs() << "Failed to compute canonical liveness?!\n");
1020-
clearLiveness();
1020+
invalidateLiveness();
10211021
return false;
10221022
}
10231023
if (accessBlockAnalysis) {
@@ -1051,7 +1051,7 @@ void CanonicalizeOSSALifetime::rewriteLifetimes() {
10511051
// Step 6: rewrite copies and delete extra destroys
10521052
rewriteCopies();
10531053

1054-
clearLiveness();
1054+
invalidateLiveness();
10551055
consumes.clear();
10561056
}
10571057

0 commit comments

Comments
 (0)