Skip to content

Commit 74120f3

Browse files
committed
[di] Remove dead code.
Since collectUses in DI land always asserts that we are processing a pointer, this code for sure has never been called (since it works with destructures), meaning that the code must be dead.
1 parent 746b58e commit 74120f3

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ static SILValue scalarizeLoad(LoadInst *LI,
512512

513513
namespace {
514514

515+
/// Gathers information about a specific address and its uses to determine
516+
/// definite initialization.
515517
class ElementUseCollector {
516518
SILModule &Module;
517519
const DIMemoryObjectInfo &TheMemory;
@@ -587,8 +589,6 @@ class ElementUseCollector {
587589
void addElementUses(unsigned BaseEltNo, SILType UseTy, SILInstruction *User,
588590
DIUseKind Kind);
589591
void collectTupleElementUses(TupleElementAddrInst *TEAI, unsigned BaseEltNo);
590-
void collectDestructureTupleResultUses(DestructureTupleResult *DTR,
591-
unsigned BaseEltNo);
592592
void collectStructElementUses(StructElementAddrInst *SEAI,
593593
unsigned BaseEltNo);
594594
};
@@ -640,34 +640,6 @@ void ElementUseCollector::collectTupleElementUses(TupleElementAddrInst *TEAI,
640640
collectUses(TEAI, BaseEltNo);
641641
}
642642

643-
/// Given a destructure_tuple, compute the new BaseEltNo implicit in the
644-
/// selected member, and recursively add uses of the instruction.
645-
void ElementUseCollector::collectDestructureTupleResultUses(
646-
DestructureTupleResult *DTR, unsigned BaseEltNo) {
647-
648-
// If we're walking into a tuple within a struct or enum, don't adjust the
649-
// BaseElt. The uses hanging off the tuple_element_addr are going to be
650-
// counted as uses of the struct or enum itself.
651-
if (InStructSubElement || InEnumSubElement)
652-
return collectUses(DTR, BaseEltNo);
653-
654-
assert(!IsSelfOfNonDelegatingInitializer && "self doesn't have tuple type");
655-
656-
// tuple_element_addr P, 42 indexes into the current tuple element.
657-
// Recursively process its uses with the adjusted element number.
658-
unsigned FieldNo = DTR->getIndex();
659-
auto T = DTR->getParent()->getOperand()->getType();
660-
if (T.is<TupleType>()) {
661-
for (unsigned i = 0; i != FieldNo; ++i) {
662-
SILType EltTy = T.getTupleElementType(i);
663-
BaseEltNo += getElementCountRec(TypeExpansionContext(*DTR->getFunction()),
664-
Module, EltTy, false);
665-
}
666-
}
667-
668-
collectUses(DTR, BaseEltNo);
669-
}
670-
671643
void ElementUseCollector::collectStructElementUses(StructElementAddrInst *SEAI,
672644
unsigned BaseEltNo) {
673645
// Generally, we set the "InStructSubElement" flag and recursively process
@@ -733,15 +705,15 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
733705
continue;
734706
}
735707

736-
// Look through begin_access and begin_borrow
737-
if (isa<BeginAccessInst>(User) || isa<BeginBorrowInst>(User)) {
708+
// Look through begin_access.
709+
if (isa<BeginAccessInst>(User)) {
738710
auto begin = cast<SingleValueInstruction>(User);
739711
collectUses(begin, BaseEltNo);
740712
continue;
741713
}
742714

743-
// Ignore end_access and end_borrow.
744-
if (isa<EndAccessInst>(User) || isa<EndBorrowInst>(User)) {
715+
// Ignore end_access.
716+
if (isa<EndAccessInst>(User)) {
745717
continue;
746718
}
747719

@@ -1114,9 +1086,6 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
11141086
collectTupleElementUses(TEAI, BaseEltNo);
11151087
continue;
11161088
}
1117-
1118-
auto *DTRI = cast<DestructureTupleResult>(EltPtr);
1119-
collectDestructureTupleResultUses(DTRI, BaseEltNo);
11201089
}
11211090
}
11221091
}

0 commit comments

Comments
 (0)