Skip to content

Commit 9d80f60

Browse files
committed
DI: Use new 'self initialized' analysis in LifetimeChecker::handleSelfInitUse()
1 parent 4c9d736 commit 9d80f60

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,13 +1697,9 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
16971697
auto *Inst = InstInfo.Inst;
16981698

16991699
assert(TheMemory.isAnyInitSelf());
1700+
assert(!TheMemory.isClassInitSelf() || TheMemory.isNonRootClassSelf());
17001701
assert(TheMemory.getType()->hasReferenceSemantics());
17011702

1702-
if (getSelfConsumedAtInst(Inst) != DIKind::No) {
1703-
emitSelfConsumedDiagnostic(Inst);
1704-
return;
1705-
}
1706-
17071703
// Determine the liveness states of the memory object, including the
17081704
// self/super.init state.
17091705
AvailabilitySet Liveness = getLivenessAtInst(Inst, 0, TheMemory.NumElements);
@@ -1716,6 +1712,11 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
17161712
case DIKind::Yes:
17171713
case DIKind::Partial:
17181714
// This is bad, only one super.init call is allowed.
1715+
if (getSelfInitializedAtInst(Inst) != DIKind::Yes) {
1716+
emitSelfConsumedDiagnostic(Inst);
1717+
return;
1718+
}
1719+
17191720
if (shouldEmitError(Inst))
17201721
diagnose(Module, Inst->getLoc(), diag::selfinit_multiple_times,
17211722
TheMemory.isDelegatingInit());

0 commit comments

Comments
 (0)