@@ -1089,9 +1089,8 @@ bool OpaqueStorageAllocation::findProjectionIntoUseImpl(
1089
1089
return false ;
1090
1090
}
1091
1091
1092
- bool OpaqueStorageAllocation::
1093
- checkStorageDominates (AllocStackInst *allocInst,
1094
- ArrayRef<SILValue> incomingValues) {
1092
+ bool OpaqueStorageAllocation::checkStorageDominates (
1093
+ AllocStackInst *allocInst, ArrayRef<SILValue> incomingValues) {
1095
1094
1096
1095
for (SILValue incomingValue : incomingValues) {
1097
1096
if (auto *defInst = incomingValue->getDefiningInstruction ()) {
@@ -1102,8 +1101,8 @@ checkStorageDominates(AllocStackInst *allocInst,
1102
1101
// Handle both phis and terminator results.
1103
1102
auto *bbArg = cast<SILPhiArgument>(incomingValue);
1104
1103
// The storage block must strictly dominate the phi.
1105
- if (!pass.domInfo ->properlyDominates (
1106
- allocInst-> getParent (), bbArg->getParent ())) {
1104
+ if (!pass.domInfo ->properlyDominates (allocInst-> getParent (),
1105
+ bbArg->getParent ())) {
1107
1106
return false ;
1108
1107
}
1109
1108
}
@@ -1157,9 +1156,8 @@ void OpaqueStorageAllocation::removeAllocation(SILValue value) {
1157
1156
// Any value that may be used by a return instruction must be deallocated
1158
1157
// immediately before the return. This allows the return to be rewritten by
1159
1158
// loading from storage.
1160
- AllocStackInst *OpaqueStorageAllocation::
1161
- createStackAllocation (SILValue value) {
1162
- assert (value.getOwnershipKind () != OwnershipKind::Guaranteed &&
1159
+ AllocStackInst *OpaqueStorageAllocation::createStackAllocation (SILValue value) {
1160
+ assert (value.getOwnershipKind () != OwnershipKind::Guaranteed &&
1163
1161
" creating storage for a guaranteed value implies a copy" );
1164
1162
1165
1163
// Instructions that produce an opened type never reach here because they
@@ -1354,7 +1352,7 @@ SILValue AddressMaterialization::recursivelyMaterializeStorage(
1354
1352
SILValue useVal = useStorage.value ;
1355
1353
if (auto *defInst = useVal->getDefiningInstruction ()) {
1356
1354
Operand *useOper =
1357
- &defInst->getAllOperands ()[storage.projectedOperandNum ];
1355
+ &defInst->getAllOperands ()[storage.projectedOperandNum ];
1358
1356
return recordAddress (
1359
1357
materializeProjectionIntoUse (useOper, intoPhiOperand));
1360
1358
}
@@ -1368,8 +1366,8 @@ SILValue AddressMaterialization::recursivelyMaterializeStorage(
1368
1366
pass.valueStorageMap .getProjectedStorage (storage).storage ,
1369
1367
/* intoPhiOperand*/ true ));
1370
1368
}
1371
- assert (!storage.isProjection ()
1372
- && " a composing user may not also be a def projection" );
1369
+ assert (!storage.isProjection () &&
1370
+ " a composing user may not also be a def projection" );
1373
1371
return storage.storageAddress ;
1374
1372
}
1375
1373
@@ -1468,9 +1466,9 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
1468
1466
auto canTy = initExistentialValue->getFormalConcreteType ();
1469
1467
auto opaque = Lowering::AbstractionPattern::getOpaque ();
1470
1468
auto &concreteTL = pass.function ->getTypeLowering (opaque, canTy);
1471
- return B.createInitExistentialAddr (
1472
- pass. genLoc (), containerAddr, canTy ,
1473
- concreteTL. getLoweredType (), initExistentialValue->getConformances ());
1469
+ return B.createInitExistentialAddr (pass. genLoc (), containerAddr, canTy,
1470
+ concreteTL. getLoweredType () ,
1471
+ initExistentialValue->getConformances ());
1474
1472
}
1475
1473
case SILInstructionKind::StructInst: {
1476
1474
auto *structInst = cast<StructInst>(user);
@@ -1480,8 +1478,8 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
1480
1478
1481
1479
SILValue structAddr = materializeComposingUser (structInst, intoPhiOperand);
1482
1480
return B.createStructElementAddr (
1483
- pass.genLoc (), structAddr, *fieldIter,
1484
- operand->get ()->getType ().getAddressType ());
1481
+ pass.genLoc (), structAddr, *fieldIter,
1482
+ operand->get ()->getType ().getAddressType ());
1485
1483
}
1486
1484
case SILInstructionKind::TupleInst: {
1487
1485
auto *tupleInst = cast<TupleInst>(user);
@@ -1584,8 +1582,8 @@ void PhiRewriter::materializeOperand(PhiOperand phiOper) {
1584
1582
auto &operStorage =
1585
1583
pass.valueStorageMap .getStorage (phiOper.getOperand ()->get ());
1586
1584
if (operStorage.isPhiProjection ()) {
1587
- if (operStorage.projectedStorageID
1588
- == pass.valueStorageMap .getOrdinal (phiOper.getValue ())) {
1585
+ if (operStorage.projectedStorageID ==
1586
+ pass.valueStorageMap .getOrdinal (phiOper.getValue ())) {
1589
1587
// This operand was coalesced with this particular phi. No move needed.
1590
1588
return ;
1591
1589
}
@@ -1646,8 +1644,8 @@ PhiRewriter::MovePosition PhiRewriter::findPhiMovePosition(PhiOperand phiOper) {
1646
1644
if (!phiMove || !phiMoves.contains (phiMove))
1647
1645
break ;
1648
1646
1649
- if (!foundEarliestInsertPoint
1650
- && getAccessBase (phiMove->getSrc ()) == phiBaseAddress) {
1647
+ if (!foundEarliestInsertPoint &&
1648
+ getAccessBase (phiMove->getSrc ()) == phiBaseAddress) {
1651
1649
// Anti-dependence from the phi move to the phi value. Do not move into
1652
1650
// the phi storage before this point.
1653
1651
foundEarliestInsertPoint = true ;
@@ -1698,8 +1696,8 @@ bool CallArgRewriter::rewriteArguments() {
1698
1696
bool changed = false ;
1699
1697
1700
1698
auto origConv = apply.getSubstCalleeConv ();
1701
- assert (apply.getNumArguments () == origConv.getNumParameters ()
1702
- && " results should not yet be rewritten" );
1699
+ assert (apply.getNumArguments () == origConv.getNumParameters () &&
1700
+ " results should not yet be rewritten" );
1703
1701
1704
1702
for (unsigned argIdx = apply.getCalleeArgIndexOfFirstAppliedArg (),
1705
1703
endArgIdx = argIdx + apply.getNumArguments ();
@@ -1968,8 +1966,8 @@ void ApplyRewriter::makeIndirectArgs(MutableArrayRef<SILValue> newCallArgs) {
1968
1966
loweredCalleeConv.getSILArgIndexOfFirstIndirectResult ();
1969
1967
1970
1968
auto visitCallResult = [&](SILValue result, SILResultInfo resultInfo) {
1971
- assert (!opaqueCalleeConv.isSILIndirect (resultInfo)
1972
- && " canonical call results are always direct" );
1969
+ assert (!opaqueCalleeConv.isSILIndirect (resultInfo) &&
1970
+ " canonical call results are always direct" );
1973
1971
1974
1972
if (loweredCalleeConv.isSILIndirect (resultInfo)) {
1975
1973
SILValue indirectResultAddr = materializeIndirectResultAddress (
@@ -2048,8 +2046,8 @@ void ApplyRewriter::rewriteApply(ArrayRef<SILValue> newCallArgs) {
2048
2046
auto *oldCall = cast<ApplyInst>(apply.getInstruction ());
2049
2047
2050
2048
auto *newCall = argBuilder.createApply (
2051
- callLoc, apply.getCallee (), apply.getSubstitutionMap (), newCallArgs,
2052
- oldCall->getApplyOptions (), oldCall->getSpecializationInfo ());
2049
+ callLoc, apply.getCallee (), apply.getSubstitutionMap (), newCallArgs,
2050
+ oldCall->getApplyOptions (), oldCall->getSpecializationInfo ());
2053
2051
2054
2052
this ->apply = FullApplySite (newCall);
2055
2053
@@ -2134,9 +2132,8 @@ void ApplyRewriter::rewriteTryApply(ArrayRef<SILValue> newCallArgs) {
2134
2132
2135
2133
auto replaceTermResult = [&](SILValue newResultVal) {
2136
2134
SILType resultTy = loweredCalleeConv.getSILResultType (typeCtx);
2137
- auto ownership = resultTy.isTrivial (*pass.function )
2138
- ? OwnershipKind::None
2139
- : OwnershipKind::Owned;
2135
+ auto ownership = resultTy.isTrivial (*pass.function ) ? OwnershipKind::None
2136
+ : OwnershipKind::Owned;
2140
2137
2141
2138
resultArg->replaceAllUsesWith (newResultVal);
2142
2139
assert (resultArg->getIndex () == 0 );
@@ -2209,8 +2206,8 @@ void ApplyRewriter::replaceDirectResults(DestructureTupleInst *oldDestructure) {
2209
2206
unsigned newDirectResultIdx = 0 ;
2210
2207
2211
2208
auto visitOldCallResult = [&](SILValue result, SILResultInfo resultInfo) {
2212
- assert (!opaqueCalleeConv.isSILIndirect (resultInfo)
2213
- && " canonical call results are always direct" );
2209
+ assert (!opaqueCalleeConv.isSILIndirect (resultInfo) &&
2210
+ " canonical call results are always direct" );
2214
2211
2215
2212
if (loweredCalleeConv.isSILIndirect (resultInfo)) {
2216
2213
if (result->getType ().isAddressOnly (*pass.function )) {
@@ -2283,8 +2280,8 @@ void ReturnRewriter::rewriteReturn(ReturnInst *returnInst) {
2283
2280
2284
2281
// Find the point before allocated storage has been deallocated.
2285
2282
auto insertPt = SILBasicBlock::iterator (returnInst);
2286
- for (auto bbStart = returnInst->getParent ()->begin ();
2287
- insertPt != bbStart; --insertPt) {
2283
+ for (auto bbStart = returnInst->getParent ()->begin (); insertPt != bbStart;
2284
+ --insertPt) {
2288
2285
if (!isa<DeallocStackInst>(*std::prev (insertPt)))
2289
2286
break ;
2290
2287
}
@@ -2308,23 +2305,22 @@ void ReturnRewriter::rewriteReturn(ReturnInst *returnInst) {
2308
2305
pass.loweredFnConv .getSILArgIndexOfFirstIndirectResult ();
2309
2306
2310
2307
// Initialize the indirect result arguments and populate newDirectResults.
2311
- for_each (
2312
- pass.function ->getLoweredFunctionType ()->getResults (), oldResults,
2313
- [&](SILResultInfo resultInfo, SILValue oldResult) {
2314
- // Assume that all original results are direct in SIL.
2315
- assert (!opaqueFnConv.isSILIndirect (resultInfo));
2316
- if (!pass.loweredFnConv .isSILIndirect (resultInfo)) {
2317
- newDirectResults.push_back (oldResult);
2318
- return ;
2319
- }
2320
- SILArgument *newResultArg =
2321
- pass.function ->getArgument (newResultArgIdx);
2322
- rewriteElement (oldResult, newResultArg, returnBuilder);
2323
- ++newResultArgIdx;
2324
- });
2325
-
2326
- assert (newDirectResults.size ()
2327
- == pass.loweredFnConv .getNumDirectSILResults ());
2308
+ for_each (pass.function ->getLoweredFunctionType ()->getResults (), oldResults,
2309
+ [&](SILResultInfo resultInfo, SILValue oldResult) {
2310
+ // Assume that all original results are direct in SIL.
2311
+ assert (!opaqueFnConv.isSILIndirect (resultInfo));
2312
+ if (!pass.loweredFnConv .isSILIndirect (resultInfo)) {
2313
+ newDirectResults.push_back (oldResult);
2314
+ return ;
2315
+ }
2316
+ SILArgument *newResultArg =
2317
+ pass.function ->getArgument (newResultArgIdx);
2318
+ rewriteElement (oldResult, newResultArg, returnBuilder);
2319
+ ++newResultArgIdx;
2320
+ });
2321
+
2322
+ assert (newDirectResults.size () ==
2323
+ pass.loweredFnConv .getNumDirectSILResults ());
2328
2324
assert (newResultArgIdx == pass.loweredFnConv .getSILArgIndexOfFirstParam ());
2329
2325
2330
2326
// Generate a new return_inst for the new direct results.
@@ -2335,9 +2331,9 @@ void ReturnRewriter::rewriteReturn(ReturnInst *returnInst) {
2335
2331
} else if (newDirectResults.size () == 1 ) {
2336
2332
newReturnVal = newDirectResults[0 ];
2337
2333
} else {
2338
- newReturnVal = returnBuilder.createTuple (pass. genLoc (),
2339
- pass.loweredFnConv .getSILResultType (typeCtx),
2340
- newDirectResults);
2334
+ newReturnVal = returnBuilder.createTuple (
2335
+ pass. genLoc (), pass.loweredFnConv .getSILResultType (typeCtx),
2336
+ newDirectResults);
2341
2337
}
2342
2338
// Rewrite the returned value.
2343
2339
SILValue origFullResult = returnInst->getOperand ();
0 commit comments