@@ -2056,8 +2056,8 @@ void PullbackCloner::Implementation::accumulateAdjointForOptional(
2056
2056
// Find `Optional<T.TangentVector>.some` EnumElementDecl.
2057
2057
auto someEltDecl = builder.getASTContext ().getOptionalSomeDecl ();
2058
2058
2059
- // Initialize a `Optional<T.TangentVector>` buffer from `wrappedAdjoint`as the
2060
- // input for `Optional<T>.TangentVector.init`.
2059
+ // Initialize an `Optional<T.TangentVector>` buffer from `wrappedAdjoint` as
2060
+ // the input for `Optional<T>.TangentVector.init`.
2061
2061
auto *optArgBuf = builder.createAllocStack (pbLoc, optionalOfWrappedTanType);
2062
2062
if (optionalOfWrappedTanType.isLoadableOrOpaque (builder.getFunction ())) {
2063
2063
// %enum = enum $Optional<T.TangentVector>, #Optional.some!enumelt,
@@ -2066,7 +2066,7 @@ void PullbackCloner::Implementation::accumulateAdjointForOptional(
2066
2066
optionalOfWrappedTanType);
2067
2067
// store %enum to %optArgBuf
2068
2068
builder.emitStoreValueOperation (pbLoc, enumInst, optArgBuf,
2069
- StoreOwnershipQualifier::Trivial );
2069
+ StoreOwnershipQualifier::Init );
2070
2070
} else {
2071
2071
// %enumAddr = init_enum_data_addr %optArgBuf $Optional<T.TangentVector>,
2072
2072
// #Optional.some!enumelt
@@ -2279,14 +2279,15 @@ void PullbackCloner::Implementation::visitSILBasicBlock(SILBasicBlock *bb) {
2279
2279
for (auto pair : incomingValues) {
2280
2280
auto *predBB = std::get<0 >(pair);
2281
2281
auto incomingValue = std::get<1 >(pair);
2282
- blockTemporaries[getPullbackBlock (predBB)].insert (concreteBBArgAdjCopy);
2283
2282
// Handle `switch_enum` on `Optional`.
2284
2283
auto termInst = bbArg->getSingleTerminator ();
2285
- if (isSwitchEnumInstOnOptional (termInst))
2284
+ if (isSwitchEnumInstOnOptional (termInst)) {
2286
2285
accumulateAdjointForOptional (bb, incomingValue, concreteBBArgAdjCopy);
2287
- else
2286
+ } else {
2287
+ blockTemporaries[getPullbackBlock (predBB)].insert (concreteBBArgAdjCopy);
2288
2288
setAdjointValue (predBB, incomingValue,
2289
2289
makeConcreteAdjointValue (concreteBBArgAdjCopy));
2290
+ }
2290
2291
}
2291
2292
break ;
2292
2293
}
0 commit comments