Skip to content

[pmo] Use SILBuilder::emitDestructureOperation to destructure values … #21877

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
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
16 changes: 3 additions & 13 deletions lib/SILOptimizer/Mandatory/PMOMemoryUseCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ getScalarizedElementAddresses(SILValue Pointer, SILBuilder &B, SILLocation Loc,
}
}

/// Given an RValue of aggregate type, compute the values of the elements by
/// emitting a series of tuple_element instructions.
static void getScalarizedElements(SILValue V,
SmallVectorImpl<SILValue> &ElementVals,
SILLocation Loc, SILBuilder &B) {
TupleType *TT = V->getType().castTo<TupleType>();
for (auto Index : indices(TT->getElements())) {
ElementVals.push_back(B.emitTupleExtract(Loc, V, Index));
}
}

/// Scalarize a load down to its subelements. If NewLoads is specified, this
/// can return the newly generated sub-element loads.
static SILValue scalarizeLoad(LoadInst *LI,
Expand Down Expand Up @@ -442,8 +431,9 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
// Scalarize StoreInst
if (auto *SI = dyn_cast<StoreInst>(User)) {
SILBuilderWithScope B(User, SI);
getScalarizedElements(SI->getOperand(0), ElementTmps, SI->getLoc(), B);

B.emitDestructureValueOperation(
SI->getLoc(), SI->getSrc(),
[&](unsigned index, SILValue v) { ElementTmps.push_back(v); });
for (unsigned i = 0, e = ElementAddrs.size(); i != e; ++i)
B.createTrivialStoreOr(SI->getLoc(), ElementTmps[i], ElementAddrs[i],
SI->getOwnershipQualifier(),
Expand Down