mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -519,23 +519,10 @@ class ElementUseCollector {
|
|||||||
const DIMemoryObjectInfo &TheMemory;
|
const DIMemoryObjectInfo &TheMemory;
|
||||||
DIElementUseInfo &UseInfo;
|
DIElementUseInfo &UseInfo;
|
||||||
|
|
||||||
/// This is true if definite initialization has finished processing assign
|
|
||||||
/// and other ambiguous instructions into init vs assign classes.
|
|
||||||
bool isDefiniteInitFinished;
|
|
||||||
|
|
||||||
/// IsSelfOfNonDelegatingInitializer - This is true if we're looking at the
|
/// IsSelfOfNonDelegatingInitializer - This is true if we're looking at the
|
||||||
/// top level of a 'self' variable in a non-delegating init method.
|
/// top level of a 'self' variable in a non-delegating init method.
|
||||||
bool IsSelfOfNonDelegatingInitializer;
|
bool IsSelfOfNonDelegatingInitializer;
|
||||||
|
|
||||||
/// How should address_to_pointer be handled?
|
|
||||||
///
|
|
||||||
/// In DefiniteInitialization it is considered as an inout parameter to get
|
|
||||||
/// diagnostics about passing a let variable to an inout mutable-pointer
|
|
||||||
/// argument.
|
|
||||||
/// In PredictableMemOpt it is considered as an escape point to be
|
|
||||||
/// conservative.
|
|
||||||
bool TreatAddressToPointerAsInout;
|
|
||||||
|
|
||||||
/// When walking the use list, if we index into a struct element, keep track
|
/// When walking the use list, if we index into a struct element, keep track
|
||||||
/// of this, so that any indexes into tuple subelements don't affect the
|
/// of this, so that any indexes into tuple subelements don't affect the
|
||||||
/// element we attribute an access to.
|
/// element we attribute an access to.
|
||||||
@@ -547,11 +534,9 @@ class ElementUseCollector {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ElementUseCollector(const DIMemoryObjectInfo &TheMemory,
|
ElementUseCollector(const DIMemoryObjectInfo &TheMemory,
|
||||||
DIElementUseInfo &UseInfo, bool isDefiniteInitFinished,
|
DIElementUseInfo &UseInfo)
|
||||||
bool TreatAddressToPointerAsInout)
|
|
||||||
: Module(TheMemory.MemoryInst->getModule()), TheMemory(TheMemory),
|
: Module(TheMemory.MemoryInst->getModule()), TheMemory(TheMemory),
|
||||||
UseInfo(UseInfo), isDefiniteInitFinished(isDefiniteInitFinished),
|
UseInfo(UseInfo) {}
|
||||||
TreatAddressToPointerAsInout(TreatAddressToPointerAsInout) {}
|
|
||||||
|
|
||||||
/// This is the main entry point for the use walker. It collects uses from
|
/// This is the main entry point for the use walker. It collects uses from
|
||||||
/// the address and the refcount result of the allocation.
|
/// the address and the refcount result of the allocation.
|
||||||
@@ -775,8 +760,6 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
|
|||||||
Kind = DIUseKind::PartialStore; \
|
Kind = DIUseKind::PartialStore; \
|
||||||
else if (SWI->isInitializationOfDest()) \
|
else if (SWI->isInitializationOfDest()) \
|
||||||
Kind = DIUseKind::Initialization; \
|
Kind = DIUseKind::Initialization; \
|
||||||
else if (isDefiniteInitFinished) \
|
|
||||||
Kind = DIUseKind::Assign; \
|
|
||||||
else \
|
else \
|
||||||
Kind = DIUseKind::InitOrAssign; \
|
Kind = DIUseKind::InitOrAssign; \
|
||||||
trackUse(DIMemoryUse(User, Kind, BaseEltNo, 1)); \
|
trackUse(DIMemoryUse(User, Kind, BaseEltNo, 1)); \
|
||||||
@@ -803,8 +786,6 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
|
|||||||
Kind = DIUseKind::PartialStore;
|
Kind = DIUseKind::PartialStore;
|
||||||
else if (CAI->isInitializationOfDest())
|
else if (CAI->isInitializationOfDest())
|
||||||
Kind = DIUseKind::Initialization;
|
Kind = DIUseKind::Initialization;
|
||||||
else if (isDefiniteInitFinished)
|
|
||||||
Kind = DIUseKind::Assign;
|
|
||||||
else
|
else
|
||||||
Kind = DIUseKind::InitOrAssign;
|
Kind = DIUseKind::InitOrAssign;
|
||||||
|
|
||||||
@@ -900,7 +881,7 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
|
|||||||
llvm_unreachable("bad parameter convention");
|
llvm_unreachable("bad parameter convention");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isa<AddressToPointerInst>(User) && TreatAddressToPointerAsInout) {
|
if (isa<AddressToPointerInst>(User)) {
|
||||||
// address_to_pointer is a mutable escape, which we model as an inout use.
|
// address_to_pointer is a mutable escape, which we model as an inout use.
|
||||||
addElementUses(BaseEltNo, PointeeType, User,
|
addElementUses(BaseEltNo, PointeeType, User,
|
||||||
DIUseKind::InOutArgument);
|
DIUseKind::InOutArgument);
|
||||||
@@ -1830,12 +1811,11 @@ static bool shouldPerformClassInitSelf(const DIMemoryObjectInfo &MemoryInfo) {
|
|||||||
MemoryInfo.isDerivedClassSelfOnly();
|
MemoryInfo.isDerivedClassSelfOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// collectDIElementUsesFrom - Analyze all uses of the specified allocation
|
/// Analyze all uses of the specified allocation instruction (alloc_box,
|
||||||
/// instruction (alloc_box, alloc_stack or mark_uninitialized), classifying them
|
/// alloc_stack or mark_uninitialized), classifying them and storing the
|
||||||
/// and storing the information found into the Uses and Releases lists.
|
/// information found into the Uses and Releases lists.
|
||||||
void swift::ownership::collectDIElementUsesFrom(
|
void swift::ownership::collectDIElementUsesFrom(
|
||||||
const DIMemoryObjectInfo &MemoryInfo, DIElementUseInfo &UseInfo,
|
const DIMemoryObjectInfo &MemoryInfo, DIElementUseInfo &UseInfo) {
|
||||||
bool isDIFinished, bool TreatAddressToPointerAsInout) {
|
|
||||||
|
|
||||||
if (shouldPerformClassInitSelf(MemoryInfo)) {
|
if (shouldPerformClassInitSelf(MemoryInfo)) {
|
||||||
ClassInitElementUseCollector UseCollector(MemoryInfo, UseInfo);
|
ClassInitElementUseCollector UseCollector(MemoryInfo, UseInfo);
|
||||||
@@ -1852,7 +1832,5 @@ void swift::ownership::collectDIElementUsesFrom(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementUseCollector(MemoryInfo, UseInfo, isDIFinished,
|
ElementUseCollector(MemoryInfo, UseInfo).collectFrom();
|
||||||
TreatAddressToPointerAsInout)
|
|
||||||
.collectFrom();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,9 +306,7 @@ struct DIElementUseInfo {
|
|||||||
/// instruction (alloc_box, alloc_stack or mark_uninitialized), classifying them
|
/// instruction (alloc_box, alloc_stack or mark_uninitialized), classifying them
|
||||||
/// and storing the information found into the Uses and Releases lists.
|
/// and storing the information found into the Uses and Releases lists.
|
||||||
void collectDIElementUsesFrom(const DIMemoryObjectInfo &MemoryInfo,
|
void collectDIElementUsesFrom(const DIMemoryObjectInfo &MemoryInfo,
|
||||||
DIElementUseInfo &UseInfo,
|
DIElementUseInfo &UseInfo);
|
||||||
bool isDefiniteInitFinished,
|
|
||||||
bool TreatAddressToPointerAsInout);
|
|
||||||
|
|
||||||
} // end namespace ownership
|
} // end namespace ownership
|
||||||
} // end namespace swift
|
} // end namespace swift
|
||||||
|
|||||||
@@ -2888,8 +2888,7 @@ static void processMemoryObject(MarkUninitializedInst *I) {
|
|||||||
DIElementUseInfo UseInfo;
|
DIElementUseInfo UseInfo;
|
||||||
|
|
||||||
// Walk the use list of the pointer, collecting them into the Uses array.
|
// Walk the use list of the pointer, collecting them into the Uses array.
|
||||||
collectDIElementUsesFrom(MemInfo, UseInfo, false,
|
collectDIElementUsesFrom(MemInfo, UseInfo);
|
||||||
/*TreatAddressToPointerAsInout*/ true);
|
|
||||||
|
|
||||||
LifetimeChecker(MemInfo, UseInfo).doIt();
|
LifetimeChecker(MemInfo, UseInfo).doIt();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user