Skip to content

Commit b5ccc4d

Browse files
authored
[AutoDiff] NFC: gardening. (#31668)
Run clang-format on all differentiation SILOptimizer files. Remove dead commented code.
1 parent a5bdbd9 commit b5ccc4d

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

include/swift/SILOptimizer/Differentiation/Common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,16 @@ inline void createEntryArguments(SILFunction *f) {
211211
decl->setSpecifier(ParamDecl::Specifier::Default);
212212
entry->createFunctionArgument(type, decl);
213213
};
214-
// f->getLoweredFunctionType()->remap
215214
for (auto indResTy :
216215
conv.getIndirectSILResultTypes(f->getTypeExpansionContext())) {
217216
if (indResTy.hasArchetype())
218217
indResTy = indResTy.mapTypeOutOfContext();
219218
createFunctionArgument(f->mapTypeIntoContext(indResTy).getAddressType());
220-
// createFunctionArgument(indResTy.getAddressType());
221219
}
222220
for (auto paramTy : conv.getParameterSILTypes(f->getTypeExpansionContext())) {
223221
if (paramTy.hasArchetype())
224222
paramTy = paramTy.mapTypeOutOfContext();
225223
createFunctionArgument(f->mapTypeIntoContext(paramTy));
226-
// createFunctionArgument(paramTy);
227224
}
228225
}
229226

include/swift/SILOptimizer/Differentiation/PullbackEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#ifndef SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_PULLBACKEMITTER_H
1919
#define SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_PULLBACKEMITTER_H
2020

21+
#include "swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h"
2122
#include "swift/SILOptimizer/Differentiation/AdjointValue.h"
2223
#include "swift/SILOptimizer/Differentiation/DifferentiationInvoker.h"
2324
#include "swift/SILOptimizer/Differentiation/LinearMapInfo.h"
24-
#include "swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h"
2525

2626
#include "swift/SIL/TypeSubstCloner.h"
2727
#include "llvm/ADT/DenseMap.h"

include/swift/SILOptimizer/Differentiation/VJPEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#ifndef SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_VJPEMITTER_H
1919
#define SWIFT_SILOPTIMIZER_UTILS_DIFFERENTIATION_VJPEMITTER_H
2020

21+
#include "swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h"
2122
#include "swift/SILOptimizer/Differentiation/DifferentiationInvoker.h"
2223
#include "swift/SILOptimizer/Differentiation/LinearMapInfo.h"
23-
#include "swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h"
2424

2525
#include "swift/SIL/TypeSubstCloner.h"
2626
#include "llvm/ADT/DenseMap.h"

lib/SILOptimizer/Differentiation/LinearMapInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ LinearMapInfo::createBranchingTraceDecl(SILBasicBlock *originalBB,
126126
auto originalFnTy = original->getLoweredFunctionType();
127127
auto numResults = originalFnTy->getNumResults() +
128128
originalFnTy->getNumIndirectMutatingParameters();
129-
auto *resultIndices = IndexSubset::get(
130-
original->getASTContext(), numResults, indices.source);
129+
auto *resultIndices =
130+
IndexSubset::get(original->getASTContext(), numResults, indices.source);
131131
auto *parameterIndices = indices.parameters;
132132
AutoDiffConfig config(parameterIndices, resultIndices, genericSig);
133133
auto enumName = mangler.mangleAutoDiffGeneratedDeclaration(
@@ -199,8 +199,8 @@ LinearMapInfo::createLinearMapStruct(SILBasicBlock *originalBB,
199199
auto originalFnTy = original->getLoweredFunctionType();
200200
auto numResults = originalFnTy->getNumResults() +
201201
originalFnTy->getNumIndirectMutatingParameters();
202-
auto *resultIndices = IndexSubset::get(
203-
original->getASTContext(), numResults, indices.source);
202+
auto *resultIndices =
203+
IndexSubset::get(original->getASTContext(), numResults, indices.source);
204204
auto *parameterIndices = indices.parameters;
205205
AutoDiffConfig config(parameterIndices, resultIndices, genericSig);
206206
auto structName = mangler.mangleAutoDiffGeneratedDeclaration(

lib/SILOptimizer/Differentiation/PullbackEmitter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ void PullbackEmitter::cleanUpTemporariesForBlock(SILBasicBlock *bb,
151151
const Lowering::TypeLowering &PullbackEmitter::getTypeLowering(Type type) {
152152
auto pbGenSig =
153153
getPullback().getLoweredFunctionType()->getSubstGenericSignature();
154-
Lowering::AbstractionPattern pattern(
155-
pbGenSig, type->getCanonicalType(pbGenSig));
154+
Lowering::AbstractionPattern pattern(pbGenSig,
155+
type->getCanonicalType(pbGenSig));
156156
return getPullback().getTypeLowering(pattern, type);
157157
}
158158

@@ -2083,8 +2083,8 @@ void PullbackEmitter::accumulateIndirect(SILValue lhsDestAccess,
20832083
auto type = lhsDestAccess->getType();
20842084
auto astType = type.getASTType();
20852085
auto *swiftMod = getModule().getSwiftModule();
2086-
auto tangentSpace = astType->getAutoDiffTangentSpace(
2087-
LookUpConformanceInModule(swiftMod));
2086+
auto tangentSpace =
2087+
astType->getAutoDiffTangentSpace(LookUpConformanceInModule(swiftMod));
20882088
assert(tangentSpace && "No tangent space for this type");
20892089
switch (tangentSpace->getKind()) {
20902090
case TangentSpace::Kind::TangentVector: {

lib/SILOptimizer/Differentiation/VJPEmitter.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ SILFunction *VJPEmitter::createEmptyPullback() {
174174
SILParameterInfo inoutParamTanParam(
175175
origResult.getInterfaceType()
176176
->getAutoDiffTangentSpace(lookupConformance)
177-
->getType()->getCanonicalType(witnessCanGenSig),
177+
->getType()
178+
->getCanonicalType(witnessCanGenSig),
178179
inoutParamTanConvention);
179180
pbParams.push_back(inoutParamTanParam);
180181
} else {
@@ -184,15 +185,17 @@ SILFunction *VJPEmitter::createEmptyPullback() {
184185
pbParams.push_back(getTangentParameterInfoForOriginalResult(
185186
origResult.getInterfaceType()
186187
->getAutoDiffTangentSpace(lookupConformance)
187-
->getType()->getCanonicalType(witnessCanGenSig),
188+
->getType()
189+
->getCanonicalType(witnessCanGenSig),
188190
origResult.getConvention()));
189191
}
190192

191193
// Accept a pullback struct in the pullback parameter list. This is the
192194
// returned pullback's closure context.
193195
auto *origExit = &*original->findReturnBB();
194196
auto *pbStruct = pullbackInfo.getLinearMapStruct(origExit);
195-
auto pbStructType = pbStruct->getDeclaredInterfaceType()->getCanonicalType(witnessCanGenSig);
197+
auto pbStructType =
198+
pbStruct->getDeclaredInterfaceType()->getCanonicalType(witnessCanGenSig);
196199
pbParams.push_back({pbStructType, ParameterConvention::Direct_Owned});
197200

198201
// Add pullback results for the requested wrt parameters.
@@ -205,7 +208,8 @@ SILFunction *VJPEmitter::createEmptyPullback() {
205208
adjResults.push_back(getTangentResultInfoForOriginalParameter(
206209
origParam.getInterfaceType()
207210
->getAutoDiffTangentSpace(lookupConformance)
208-
->getType()->getCanonicalType(witnessCanGenSig),
211+
->getType()
212+
->getCanonicalType(witnessCanGenSig),
209213
origParam.getConvention()));
210214
}
211215

@@ -275,8 +279,8 @@ void VJPEmitter::visitSILInstruction(SILInstruction *inst) {
275279

276280
SILType VJPEmitter::getLoweredType(Type type) {
277281
auto vjpGenSig = vjp->getLoweredFunctionType()->getSubstGenericSignature();
278-
Lowering::AbstractionPattern pattern(
279-
vjpGenSig, type->getCanonicalType(vjpGenSig));
282+
Lowering::AbstractionPattern pattern(vjpGenSig,
283+
type->getCanonicalType(vjpGenSig));
280284
return vjp->getLoweredType(pattern, type);
281285
}
282286

@@ -490,9 +494,8 @@ void VJPEmitter::visitSwitchEnumInstBase(SwitchEnumInstBase *sei) {
490494
newDefaultBB, caseBBs);
491495
break;
492496
case SILInstructionKind::SwitchEnumAddrInst:
493-
getBuilder().createSwitchEnumAddr(sei->getLoc(),
494-
getOpValue(sei->getOperand()),
495-
newDefaultBB, caseBBs);
497+
getBuilder().createSwitchEnumAddr(
498+
sei->getLoc(), getOpValue(sei->getOperand()), newDefaultBB, caseBBs);
496499
break;
497500
default:
498501
llvm_unreachable("Expected `switch_enum` or `switch_enum_addr`");

0 commit comments

Comments
 (0)