Skip to content

Commit b77170a

Browse files
author
Marc Rasi
committed
add comment
1 parent 0ad68b2 commit b77170a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/SIL/IR/SILFunctionType.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ getAutoDiffDifferentialType(SILFunctionType *originalFnTy,
305305
IndexSubset *parameterIndices, unsigned resultIndex,
306306
LookupConformanceFn lookupConformance,
307307
TypeConverter &TC) {
308+
// Given the tangent type and the corresponding original parameter's
309+
// convention, returns the tangent parameter's convention.
308310
auto getTangentParameterConvention =
309311
[&](CanType tanType,
310312
ParameterConvention origParamConv) -> ParameterConvention {
@@ -314,6 +316,8 @@ getAutoDiffDifferentialType(SILFunctionType *originalFnTy,
314316
tanType);
315317
auto &tl =
316318
TC.getTypeLowering(pattern, tanType, TypeExpansionContext::minimal());
319+
// When the tangent type is address only, we must ensure that the tangent
320+
// parameter's convention is indirect.
317321
if (tl.isAddressOnly() && !isIndirectFormalParameter(origParamConv)) {
318322
switch (origParamConv) {
319323
case ParameterConvention::Direct_Guaranteed:
@@ -328,6 +332,8 @@ getAutoDiffDifferentialType(SILFunctionType *originalFnTy,
328332
return origParamConv;
329333
};
330334

335+
// Given the tangent type and the corresponding original result's convention,
336+
// returns the tangent result's convention.
331337
auto getTangentResultConvention =
332338
[&](CanType tanType,
333339
ResultConvention origResConv) -> ResultConvention {
@@ -337,6 +343,8 @@ getAutoDiffDifferentialType(SILFunctionType *originalFnTy,
337343
tanType);
338344
auto &tl =
339345
TC.getTypeLowering(pattern, tanType, TypeExpansionContext::minimal());
346+
// When the tangent type is address only, we must ensure that the tangent
347+
// result's convention is indirect.
340348
if (tl.isAddressOnly() && !isIndirectFormalResult(origResConv)) {
341349
switch (origResConv) {
342350
case ResultConvention::Owned:

0 commit comments

Comments
 (0)