@@ -59,17 +59,6 @@ getScalarizedElementAddresses(SILValue Pointer, SILBuilder &B, SILLocation Loc,
59
59
}
60
60
}
61
61
62
- // / Given an RValue of aggregate type, compute the values of the elements by
63
- // / emitting a series of tuple_element instructions.
64
- static void getScalarizedElements (SILValue V,
65
- SmallVectorImpl<SILValue> &ElementVals,
66
- SILLocation Loc, SILBuilder &B) {
67
- TupleType *TT = V->getType ().castTo <TupleType>();
68
- for (auto Index : indices (TT->getElements ())) {
69
- ElementVals.push_back (B.emitTupleExtract (Loc, V, Index));
70
- }
71
- }
72
-
73
62
// / Scalarize a load down to its subelements. If NewLoads is specified, this
74
63
// / can return the newly generated sub-element loads.
75
64
static SILValue scalarizeLoad (LoadInst *LI,
@@ -442,8 +431,9 @@ bool ElementUseCollector::collectUses(SILValue Pointer) {
442
431
// Scalarize StoreInst
443
432
if (auto *SI = dyn_cast<StoreInst>(User)) {
444
433
SILBuilderWithScope B (User, SI);
445
- getScalarizedElements (SI->getOperand (0 ), ElementTmps, SI->getLoc (), B);
446
-
434
+ B.emitDestructureValueOperation (
435
+ SI->getLoc (), SI->getSrc (),
436
+ [&](unsigned index, SILValue v) { ElementTmps.push_back (v); });
447
437
for (unsigned i = 0 , e = ElementAddrs.size (); i != e; ++i)
448
438
B.createTrivialStoreOr (SI->getLoc (), ElementTmps[i], ElementAddrs[i],
449
439
SI->getOwnershipQualifier (),
0 commit comments