Skip to content

Commit afca04d

Browse files
committed
[OwnedLifetimeCan] Fix clearing.
Just clear all structures in a single method which is called wherever clearing is done. Fixes a failure to clear discoveredBlocks under certain circumstances.
1 parent f312541 commit afca04d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,7 @@ class CanonicalizeOSSALifetime final {
342342
void initializeLiveness(SILValue def,
343343
ArrayRef<SILInstruction *> lexicalLifetimeEnds) {
344344
assert(consumingBlocks.empty() && debugValues.empty());
345-
// Clear the cached analysis pointer just in case the client invalidates the
346-
// analysis, freeing its memory.
347-
accessBlocks = nullptr;
348-
consumes.clear();
349-
destroys.clear();
345+
clear();
350346

351347
currentDef = def;
352348
currentLexicalLifetimeEnds = lexicalLifetimeEnds;
@@ -358,9 +354,18 @@ class CanonicalizeOSSALifetime final {
358354
}
359355

360356
void clear() {
357+
// Clear the access blocks analysis pointer in case the client invalidates
358+
// the analysis. If the client did, the analysis will be recomputed in
359+
// extendLivenessThroughOverlappingAccess; if it didn't, the analysis
360+
// pointer will just be set back to its old value when the analysis' cache
361+
// is consulted in extendLivenessThroughOverlappingAccess.
362+
accessBlocks = nullptr;
363+
361364
consumingBlocks.clear();
362365
debugValues.clear();
363366
discoveredBlocks.clear();
367+
consumes.clear();
368+
destroys.clear();
364369
}
365370

366371
/// Top-Level API: rewrites copies and destroys within \p def's extended

lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,6 @@ void CanonicalizeOSSALifetime::rewriteLifetimes() {
12411241
rewriteCopies();
12421242

12431243
clear();
1244-
consumes.clear();
12451244
}
12461245

12471246
/// Canonicalize a single extended owned lifetime.

0 commit comments

Comments
 (0)