Skip to content

Commit 2cf6d02

Browse files
committed
[di] Now that DI and PMO are split, debride some dead code.
Specifically isDefiniteInitFinished is always set to false and TreatAddressToPointerAsInout is set to true when ever DI is run, so this patch just constant propagates those values and then DCEs as appropriate.
1 parent 74120f3 commit 2cf6d02

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -519,23 +519,10 @@ class ElementUseCollector {
519519
const DIMemoryObjectInfo &TheMemory;
520520
DIElementUseInfo &UseInfo;
521521

522-
/// This is true if definite initialization has finished processing assign
523-
/// and other ambiguous instructions into init vs assign classes.
524-
bool isDefiniteInitFinished;
525-
526522
/// IsSelfOfNonDelegatingInitializer - This is true if we're looking at the
527523
/// top level of a 'self' variable in a non-delegating init method.
528524
bool IsSelfOfNonDelegatingInitializer;
529525

530-
/// How should address_to_pointer be handled?
531-
///
532-
/// In DefiniteInitialization it is considered as an inout parameter to get
533-
/// diagnostics about passing a let variable to an inout mutable-pointer
534-
/// argument.
535-
/// In PredictableMemOpt it is considered as an escape point to be
536-
/// conservative.
537-
bool TreatAddressToPointerAsInout;
538-
539526
/// When walking the use list, if we index into a struct element, keep track
540527
/// of this, so that any indexes into tuple subelements don't affect the
541528
/// element we attribute an access to.
@@ -547,11 +534,9 @@ class ElementUseCollector {
547534

548535
public:
549536
ElementUseCollector(const DIMemoryObjectInfo &TheMemory,
550-
DIElementUseInfo &UseInfo, bool isDefiniteInitFinished,
551-
bool TreatAddressToPointerAsInout)
537+
DIElementUseInfo &UseInfo)
552538
: Module(TheMemory.MemoryInst->getModule()), TheMemory(TheMemory),
553-
UseInfo(UseInfo), isDefiniteInitFinished(isDefiniteInitFinished),
554-
TreatAddressToPointerAsInout(TreatAddressToPointerAsInout) {}
539+
UseInfo(UseInfo) {}
555540

556541
/// This is the main entry point for the use walker. It collects uses from
557542
/// the address and the refcount result of the allocation.
@@ -775,8 +760,6 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
775760
Kind = DIUseKind::PartialStore; \
776761
else if (SWI->isInitializationOfDest()) \
777762
Kind = DIUseKind::Initialization; \
778-
else if (isDefiniteInitFinished) \
779-
Kind = DIUseKind::Assign; \
780763
else \
781764
Kind = DIUseKind::InitOrAssign; \
782765
trackUse(DIMemoryUse(User, Kind, BaseEltNo, 1)); \
@@ -803,8 +786,6 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
803786
Kind = DIUseKind::PartialStore;
804787
else if (CAI->isInitializationOfDest())
805788
Kind = DIUseKind::Initialization;
806-
else if (isDefiniteInitFinished)
807-
Kind = DIUseKind::Assign;
808789
else
809790
Kind = DIUseKind::InitOrAssign;
810791

@@ -900,7 +881,7 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
900881
llvm_unreachable("bad parameter convention");
901882
}
902883

903-
if (isa<AddressToPointerInst>(User) && TreatAddressToPointerAsInout) {
884+
if (isa<AddressToPointerInst>(User)) {
904885
// address_to_pointer is a mutable escape, which we model as an inout use.
905886
addElementUses(BaseEltNo, PointeeType, User,
906887
DIUseKind::InOutArgument);
@@ -1830,12 +1811,11 @@ static bool shouldPerformClassInitSelf(const DIMemoryObjectInfo &MemoryInfo) {
18301811
MemoryInfo.isDerivedClassSelfOnly();
18311812
}
18321813

1833-
/// collectDIElementUsesFrom - Analyze all uses of the specified allocation
1834-
/// instruction (alloc_box, alloc_stack or mark_uninitialized), classifying them
1835-
/// and storing the information found into the Uses and Releases lists.
1814+
/// Analyze all uses of the specified allocation instruction (alloc_box,
1815+
/// alloc_stack or mark_uninitialized), classifying them and storing the
1816+
/// information found into the Uses and Releases lists.
18361817
void swift::ownership::collectDIElementUsesFrom(
1837-
const DIMemoryObjectInfo &MemoryInfo, DIElementUseInfo &UseInfo,
1838-
bool isDIFinished, bool TreatAddressToPointerAsInout) {
1818+
const DIMemoryObjectInfo &MemoryInfo, DIElementUseInfo &UseInfo) {
18391819

18401820
if (shouldPerformClassInitSelf(MemoryInfo)) {
18411821
ClassInitElementUseCollector UseCollector(MemoryInfo, UseInfo);
@@ -1852,7 +1832,5 @@ void swift::ownership::collectDIElementUsesFrom(
18521832
return;
18531833
}
18541834

1855-
ElementUseCollector(MemoryInfo, UseInfo, isDIFinished,
1856-
TreatAddressToPointerAsInout)
1857-
.collectFrom();
1835+
ElementUseCollector(MemoryInfo, UseInfo).collectFrom();
18581836
}

lib/SILOptimizer/Mandatory/DIMemoryUseCollector.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@ struct DIElementUseInfo {
306306
/// instruction (alloc_box, alloc_stack or mark_uninitialized), classifying them
307307
/// and storing the information found into the Uses and Releases lists.
308308
void collectDIElementUsesFrom(const DIMemoryObjectInfo &MemoryInfo,
309-
DIElementUseInfo &UseInfo,
310-
bool isDefiniteInitFinished,
311-
bool TreatAddressToPointerAsInout);
309+
DIElementUseInfo &UseInfo);
312310

313311
} // end namespace ownership
314312
} // end namespace swift

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,8 +2888,7 @@ static void processMemoryObject(MarkUninitializedInst *I) {
28882888
DIElementUseInfo UseInfo;
28892889

28902890
// Walk the use list of the pointer, collecting them into the Uses array.
2891-
collectDIElementUsesFrom(MemInfo, UseInfo, false,
2892-
/*TreatAddressToPointerAsInout*/ true);
2891+
collectDIElementUsesFrom(MemInfo, UseInfo);
28932892

28942893
LifetimeChecker(MemInfo, UseInfo).doIt();
28952894
}

0 commit comments

Comments
 (0)