Skip to content

Commit 48c048f

Browse files
committed
[AutoDiff] Fix PullbackCloner tangent value category mismatch issues.
Fix SIL pullback function type calculation: remap original `unowned` results to the correct pullback parameter convention depending on the `TangentVector` type lowering. Make `PullbackCloner` visitors for the following instructions check and handle tangent value categories: `struct`, `struct_extract`, `tuple`, `destructure_tuple`. Add differentiation tests for `Optional` struct and class stored properties, exercising the instruction visitors above. Resolves SR-13430.
1 parent 8102d91 commit 48c048f

File tree

5 files changed

+463
-126
lines changed

5 files changed

+463
-126
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ static CanSILFunctionType getAutoDiffPullbackType(
538538
TC.getTypeLowering(pattern, tanType, TypeExpansionContext::minimal());
539539
ParameterConvention conv;
540540
switch (origResConv) {
541+
case ResultConvention::Unowned:
542+
case ResultConvention::UnownedInnerPointer:
541543
case ResultConvention::Owned:
542544
case ResultConvention::Autoreleased:
543545
if (tl.isAddressOnly()) {
@@ -547,10 +549,6 @@ static CanSILFunctionType getAutoDiffPullbackType(
547549
: ParameterConvention::Direct_Guaranteed;
548550
}
549551
break;
550-
case ResultConvention::Unowned:
551-
case ResultConvention::UnownedInnerPointer:
552-
conv = ParameterConvention::Direct_Unowned;
553-
break;
554552
case ResultConvention::Indirect:
555553
conv = ParameterConvention::Indirect_In_Guaranteed;
556554
break;

0 commit comments

Comments
 (0)