Skip to content

Commit 9004e87

Browse files
committed
[pmo] Remove untested code around load_weak, store_weak, load_unowned, store_unowned.
I am removing these for the following reasons: * PMO does not have any tests for these code paths. (1). * PMO does not try to promote these loads (it explicitly pattern matches load, copy_addr) or get available values from these (it explicitly pattern matches store or explodes a copy_addr to get the copy_addr's stores). This means that removing this code will not effect our constant propagation diagnostics. So, removing this untested code path at worst could cause us to no longer eliminate some dead objects that we otherwise would be able to eliminate at -Onone (low-priority). (2). ---- (1). I believe that the lack of PMO tests is due to this being a vestigal remnant of DI code in PMO. My suspicion arises since: * The code was added when the two passes were both sharing the same use collector and auxillary data structures. Since then I have changed DI/PMO to each have their own copies. * DI has a bunch of tests that verify behavior around these instructions. (2). I expect the number of actually removed allocations that are no longer removed should be small since we do not promote loads from such allocations and PMO will not eliminate an allocation that has any loads.
1 parent 528fe6a commit 9004e87

File tree

2 files changed

+0
-26
lines changed

2 files changed

+0
-26
lines changed

lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,6 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
238238
continue;
239239
}
240240

241-
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
242-
if (isa<Load##Name##Inst>(User)) { \
243-
Uses.emplace_back(User, PMOUseKind::Load); \
244-
continue; \
245-
}
246-
#include "swift/AST/ReferenceStorage.def"
247-
248241
// Stores *to* the allocation are writes.
249242
if (isa<StoreInst>(User) && UI->getOperandNumber() == 1) {
250243
if (PointeeType.is<TupleType>()) {
@@ -263,20 +256,6 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
263256
continue;
264257
}
265258

266-
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
267-
if (auto *SI = dyn_cast<Store##Name##Inst>(User)) { \
268-
if (UI->getOperandNumber() == 1) { \
269-
PMOUseKind Kind; \
270-
if (SI->isInitializationOfDest()) \
271-
Kind = PMOUseKind::Initialization; \
272-
else \
273-
Kind = PMOUseKind::Assign; \
274-
Uses.emplace_back(User, Kind); \
275-
continue; \
276-
} \
277-
}
278-
#include "swift/AST/ReferenceStorage.def"
279-
280259
if (auto *CAI = dyn_cast<CopyAddrInst>(User)) {
281260
// If this is a copy of a tuple, we should scalarize it so that we don't
282261
// have an access that crosses elements.

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -948,11 +948,6 @@ void AvailableValueDataflowContext::explodeCopyAddr(CopyAddrInst *CAI) {
948948
}
949949
continue;
950950

951-
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
952-
case SILInstructionKind::Name##RetainInst: \
953-
case SILInstructionKind::Name##ReleaseInst: \
954-
case SILInstructionKind::StrongRetain##Name##Inst:
955-
#include "swift/AST/ReferenceStorage.def"
956951
case SILInstructionKind::RetainValueInst:
957952
case SILInstructionKind::StrongRetainInst:
958953
case SILInstructionKind::StrongReleaseInst:

0 commit comments

Comments
 (0)