Skip to content

[pmo] Eliminate PMOUseKind::PartialStore. #21972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,11 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {

// Coming out of SILGen, we assume that raw stores are initializations,
// unless they have trivial type (which we classify as InitOrAssign).
PMOUseKind Kind;
if (InStructSubElement)
Kind = PMOUseKind::PartialStore;
else if (PointeeType.isTrivial(User->getModule()))
Kind = PMOUseKind::InitOrAssign;
else
Kind = PMOUseKind::Initialization;

auto Kind = ([&]() -> PMOUseKind {
if (PointeeType.isTrivial(User->getModule()))
return PMOUseKind::InitOrAssign;
return PMOUseKind::Initialization;
})();
Uses.emplace_back(User, Kind);
continue;
}
Expand All @@ -270,9 +267,7 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
if (auto *SI = dyn_cast<Store##Name##Inst>(User)) { \
if (UI->getOperandNumber() == 1) { \
PMOUseKind Kind; \
if (InStructSubElement) \
Kind = PMOUseKind::PartialStore; \
else if (SI->isInitializationOfDest()) \
if (SI->isInitializationOfDest()) \
Kind = PMOUseKind::Initialization; \
else \
Kind = PMOUseKind::Assign; \
Expand All @@ -294,16 +289,15 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
// the destination, then this is an unknown assignment. Note that we'll
// revisit this instruction and add it to Uses twice if it is both a load
// and store to the same aggregate.
PMOUseKind Kind;
if (UI->getOperandNumber() == 0)
Kind = PMOUseKind::Load;
else if (InStructSubElement)
Kind = PMOUseKind::PartialStore;
else if (CAI->isInitializationOfDest())
Kind = PMOUseKind::Initialization;
else
Kind = PMOUseKind::Assign;

//
// Inline constructor.
auto Kind = ([&]() -> PMOUseKind {
if (UI->getOperandNumber() == CopyAddrInst::Src)
return PMOUseKind::Load;
if (CAI->isInitializationOfDest())
return PMOUseKind::Initialization;
return PMOUseKind::Assign;
})();
Uses.emplace_back(User, Kind);
continue;
}
Expand Down
3 changes: 0 additions & 3 deletions lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ enum PMOUseKind {
/// value.
Assign,

/// The instruction is a store to a member of a larger struct value.
PartialStore,

/// An indirect 'inout' parameter of an Apply instruction.
InOutUse,

Expand Down
3 changes: 1 addition & 2 deletions lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ void AvailableValueDataflowContext::explodeCopyAddr(CopyAddrInst *CAI) {
assert((LoadUse.isValid() || StoreUse.isValid()) &&
"we should have a load or a store, possibly both");
assert(StoreUse.isInvalid() || StoreUse.Kind == Assign ||
StoreUse.Kind == PartialStore || StoreUse.Kind == Initialization);
StoreUse.Kind == Initialization);

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

switch (u.Kind) {
case PMOUseKind::Assign:
case PMOUseKind::PartialStore:
case PMOUseKind::InitOrAssign:
break; // These don't prevent removal.
case PMOUseKind::Initialization:
Expand Down