Skip to content

Commit 1625a44

Browse files
committed
[SIL-opaque] [NFC] clang-format AddressLowering.cpp
1 parent 3ec96fa commit 1625a44

File tree

1 file changed

+49
-53
lines changed

1 file changed

+49
-53
lines changed

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,8 @@ bool OpaqueStorageAllocation::findProjectionIntoUseImpl(
10891089
return false;
10901090
}
10911091

1092-
bool OpaqueStorageAllocation::
1093-
checkStorageDominates(AllocStackInst *allocInst,
1094-
ArrayRef<SILValue> incomingValues) {
1092+
bool OpaqueStorageAllocation::checkStorageDominates(
1093+
AllocStackInst *allocInst, ArrayRef<SILValue> incomingValues) {
10951094

10961095
for (SILValue incomingValue : incomingValues) {
10971096
if (auto *defInst = incomingValue->getDefiningInstruction()) {
@@ -1102,8 +1101,8 @@ checkStorageDominates(AllocStackInst *allocInst,
11021101
// Handle both phis and terminator results.
11031102
auto *bbArg = cast<SILPhiArgument>(incomingValue);
11041103
// 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())) {
11071106
return false;
11081107
}
11091108
}
@@ -1157,9 +1156,8 @@ void OpaqueStorageAllocation::removeAllocation(SILValue value) {
11571156
// Any value that may be used by a return instruction must be deallocated
11581157
// immediately before the return. This allows the return to be rewritten by
11591158
// 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 &&
11631161
"creating storage for a guaranteed value implies a copy");
11641162

11651163
// Instructions that produce an opened type never reach here because they
@@ -1354,7 +1352,7 @@ SILValue AddressMaterialization::recursivelyMaterializeStorage(
13541352
SILValue useVal = useStorage.value;
13551353
if (auto *defInst = useVal->getDefiningInstruction()) {
13561354
Operand *useOper =
1357-
&defInst->getAllOperands()[storage.projectedOperandNum];
1355+
&defInst->getAllOperands()[storage.projectedOperandNum];
13581356
return recordAddress(
13591357
materializeProjectionIntoUse(useOper, intoPhiOperand));
13601358
}
@@ -1368,8 +1366,8 @@ SILValue AddressMaterialization::recursivelyMaterializeStorage(
13681366
pass.valueStorageMap.getProjectedStorage(storage).storage,
13691367
/*intoPhiOperand*/ true));
13701368
}
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");
13731371
return storage.storageAddress;
13741372
}
13751373

@@ -1468,9 +1466,9 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
14681466
auto canTy = initExistentialValue->getFormalConcreteType();
14691467
auto opaque = Lowering::AbstractionPattern::getOpaque();
14701468
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());
14741472
}
14751473
case SILInstructionKind::StructInst: {
14761474
auto *structInst = cast<StructInst>(user);
@@ -1480,8 +1478,8 @@ AddressMaterialization::materializeProjectionIntoUse(Operand *operand,
14801478

14811479
SILValue structAddr = materializeComposingUser(structInst, intoPhiOperand);
14821480
return B.createStructElementAddr(
1483-
pass.genLoc(), structAddr, *fieldIter,
1484-
operand->get()->getType().getAddressType());
1481+
pass.genLoc(), structAddr, *fieldIter,
1482+
operand->get()->getType().getAddressType());
14851483
}
14861484
case SILInstructionKind::TupleInst: {
14871485
auto *tupleInst = cast<TupleInst>(user);
@@ -1584,8 +1582,8 @@ void PhiRewriter::materializeOperand(PhiOperand phiOper) {
15841582
auto &operStorage =
15851583
pass.valueStorageMap.getStorage(phiOper.getOperand()->get());
15861584
if (operStorage.isPhiProjection()) {
1587-
if (operStorage.projectedStorageID
1588-
== pass.valueStorageMap.getOrdinal(phiOper.getValue())) {
1585+
if (operStorage.projectedStorageID ==
1586+
pass.valueStorageMap.getOrdinal(phiOper.getValue())) {
15891587
// This operand was coalesced with this particular phi. No move needed.
15901588
return;
15911589
}
@@ -1646,8 +1644,8 @@ PhiRewriter::MovePosition PhiRewriter::findPhiMovePosition(PhiOperand phiOper) {
16461644
if (!phiMove || !phiMoves.contains(phiMove))
16471645
break;
16481646

1649-
if (!foundEarliestInsertPoint
1650-
&& getAccessBase(phiMove->getSrc()) == phiBaseAddress) {
1647+
if (!foundEarliestInsertPoint &&
1648+
getAccessBase(phiMove->getSrc()) == phiBaseAddress) {
16511649
// Anti-dependence from the phi move to the phi value. Do not move into
16521650
// the phi storage before this point.
16531651
foundEarliestInsertPoint = true;
@@ -1698,8 +1696,8 @@ bool CallArgRewriter::rewriteArguments() {
16981696
bool changed = false;
16991697

17001698
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");
17031701

17041702
for (unsigned argIdx = apply.getCalleeArgIndexOfFirstAppliedArg(),
17051703
endArgIdx = argIdx + apply.getNumArguments();
@@ -1968,8 +1966,8 @@ void ApplyRewriter::makeIndirectArgs(MutableArrayRef<SILValue> newCallArgs) {
19681966
loweredCalleeConv.getSILArgIndexOfFirstIndirectResult();
19691967

19701968
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");
19731971

19741972
if (loweredCalleeConv.isSILIndirect(resultInfo)) {
19751973
SILValue indirectResultAddr = materializeIndirectResultAddress(
@@ -2048,8 +2046,8 @@ void ApplyRewriter::rewriteApply(ArrayRef<SILValue> newCallArgs) {
20482046
auto *oldCall = cast<ApplyInst>(apply.getInstruction());
20492047

20502048
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());
20532051

20542052
this->apply = FullApplySite(newCall);
20552053

@@ -2134,9 +2132,8 @@ void ApplyRewriter::rewriteTryApply(ArrayRef<SILValue> newCallArgs) {
21342132

21352133
auto replaceTermResult = [&](SILValue newResultVal) {
21362134
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;
21402137

21412138
resultArg->replaceAllUsesWith(newResultVal);
21422139
assert(resultArg->getIndex() == 0);
@@ -2209,8 +2206,8 @@ void ApplyRewriter::replaceDirectResults(DestructureTupleInst *oldDestructure) {
22092206
unsigned newDirectResultIdx = 0;
22102207

22112208
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");
22142211

22152212
if (loweredCalleeConv.isSILIndirect(resultInfo)) {
22162213
if (result->getType().isAddressOnly(*pass.function)) {
@@ -2283,8 +2280,8 @@ void ReturnRewriter::rewriteReturn(ReturnInst *returnInst) {
22832280

22842281
// Find the point before allocated storage has been deallocated.
22852282
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) {
22882285
if (!isa<DeallocStackInst>(*std::prev(insertPt)))
22892286
break;
22902287
}
@@ -2308,23 +2305,22 @@ void ReturnRewriter::rewriteReturn(ReturnInst *returnInst) {
23082305
pass.loweredFnConv.getSILArgIndexOfFirstIndirectResult();
23092306

23102307
// 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());
23282324
assert(newResultArgIdx == pass.loweredFnConv.getSILArgIndexOfFirstParam());
23292325

23302326
// Generate a new return_inst for the new direct results.
@@ -2335,9 +2331,9 @@ void ReturnRewriter::rewriteReturn(ReturnInst *returnInst) {
23352331
} else if (newDirectResults.size() == 1) {
23362332
newReturnVal = newDirectResults[0];
23372333
} 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);
23412337
}
23422338
// Rewrite the returned value.
23432339
SILValue origFullResult = returnInst->getOperand();

0 commit comments

Comments
 (0)