Skip to content

Commit e10363f

Browse files
authored
Merge pull request #21972 from gottesmm/pr-71d5041af2ad9fad51fd0dd67665159359329972
2 parents fce2c19 + 9e25cc5 commit e10363f

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,11 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
254254

255255
// Coming out of SILGen, we assume that raw stores are initializations,
256256
// unless they have trivial type (which we classify as InitOrAssign).
257-
PMOUseKind Kind;
258-
if (InStructSubElement)
259-
Kind = PMOUseKind::PartialStore;
260-
else if (PointeeType.isTrivial(User->getModule()))
261-
Kind = PMOUseKind::InitOrAssign;
262-
else
263-
Kind = PMOUseKind::Initialization;
264-
257+
auto Kind = ([&]() -> PMOUseKind {
258+
if (PointeeType.isTrivial(User->getModule()))
259+
return PMOUseKind::InitOrAssign;
260+
return PMOUseKind::Initialization;
261+
})();
265262
Uses.emplace_back(User, Kind);
266263
continue;
267264
}
@@ -270,9 +267,7 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
270267
if (auto *SI = dyn_cast<Store##Name##Inst>(User)) { \
271268
if (UI->getOperandNumber() == 1) { \
272269
PMOUseKind Kind; \
273-
if (InStructSubElement) \
274-
Kind = PMOUseKind::PartialStore; \
275-
else if (SI->isInitializationOfDest()) \
270+
if (SI->isInitializationOfDest()) \
276271
Kind = PMOUseKind::Initialization; \
277272
else \
278273
Kind = PMOUseKind::Assign; \
@@ -294,16 +289,15 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
294289
// the destination, then this is an unknown assignment. Note that we'll
295290
// revisit this instruction and add it to Uses twice if it is both a load
296291
// and store to the same aggregate.
297-
PMOUseKind Kind;
298-
if (UI->getOperandNumber() == 0)
299-
Kind = PMOUseKind::Load;
300-
else if (InStructSubElement)
301-
Kind = PMOUseKind::PartialStore;
302-
else if (CAI->isInitializationOfDest())
303-
Kind = PMOUseKind::Initialization;
304-
else
305-
Kind = PMOUseKind::Assign;
306-
292+
//
293+
// Inline constructor.
294+
auto Kind = ([&]() -> PMOUseKind {
295+
if (UI->getOperandNumber() == CopyAddrInst::Src)
296+
return PMOUseKind::Load;
297+
if (CAI->isInitializationOfDest())
298+
return PMOUseKind::Initialization;
299+
return PMOUseKind::Assign;
300+
})();
307301
Uses.emplace_back(User, Kind);
308302
continue;
309303
}

lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ enum PMOUseKind {
116116
/// value.
117117
Assign,
118118

119-
/// The instruction is a store to a member of a larger struct value.
120-
PartialStore,
121-
122119
/// An indirect 'inout' parameter of an Apply instruction.
123120
InOutUse,
124121

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ void AvailableValueDataflowContext::explodeCopyAddr(CopyAddrInst *CAI) {
911911
assert((LoadUse.isValid() || StoreUse.isValid()) &&
912912
"we should have a load or a store, possibly both");
913913
assert(StoreUse.isInvalid() || StoreUse.Kind == Assign ||
914-
StoreUse.Kind == PartialStore || StoreUse.Kind == Initialization);
914+
StoreUse.Kind == Initialization);
915915

916916
// Now that we've emitted a bunch of instructions, including a load and store
917917
// but also including other stuff, update the internal state of
@@ -1286,7 +1286,6 @@ bool AllocOptimize::tryToRemoveDeadAllocation() {
12861286

12871287
switch (u.Kind) {
12881288
case PMOUseKind::Assign:
1289-
case PMOUseKind::PartialStore:
12901289
case PMOUseKind::InitOrAssign:
12911290
break; // These don't prevent removal.
12921291
case PMOUseKind::Initialization:

0 commit comments

Comments
 (0)