Skip to content

Commit 196559e

Browse files
committed
DI: Only use collectClassInitSelfUses() for class initializers, not class-constrained protocol extensions
1 parent 224aabf commit 196559e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/SILOptimizer/Mandatory/DIMemoryUseCollectorOwnership.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ void DelegatingInitElementUseCollector::collectClassInitSelfUses() {
14861486

14871487
// For class initializers, the assign into the self box may be
14881488
// captured as SelfInit or SuperInit elsewhere.
1489-
if (TheMemory.isClassInitSelf() && isa<AssignInst>(User) &&
1489+
if (isa<AssignInst>(User) &&
14901490
Op->getOperandNumber() == 1) {
14911491
// If the source of the assignment is an application of a C
14921492
// function, there is no metatype argument, so treat the
@@ -1541,13 +1541,8 @@ void DelegatingInitElementUseCollector::collectClassInitSelfUses() {
15411541
UseInfo.trackUse(DIMemoryUse(User, DIUseKind::Escape, 0, 1));
15421542
}
15431543

1544-
if (TheMemory.isClassInitSelf()) {
1545-
assert(StoresOfArgumentToSelf == 1 &&
1546-
"The 'self' argument should have been stored into the box exactly once");
1547-
} else {
1548-
assert(StoresOfArgumentToSelf == 0 &&
1549-
"Initializing constructor for class-constrained protocol extension?");
1550-
}
1544+
assert(StoresOfArgumentToSelf == 1 &&
1545+
"The 'self' argument should have been stored into the box exactly once");
15511546

15521547
// The MUI must be used on an alloc_box or alloc_stack instruction. If we have
15531548
// an alloc_stack, there is nothing further to do.
@@ -1719,7 +1714,7 @@ void swift::ownership::collectDIElementUsesFrom(
17191714
// collector.
17201715
if (MemoryInfo.isDelegatingInit()) {
17211716
DelegatingInitElementUseCollector UseCollector(MemoryInfo, UseInfo);
1722-
if (MemoryInfo.getType()->hasReferenceSemantics()) {
1717+
if (MemoryInfo.isClassInitSelf()) {
17231718
UseCollector.collectClassInitSelfUses();
17241719
} else {
17251720
UseCollector.collectValueTypeInitSelfUses();

0 commit comments

Comments
 (0)