Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/SILOptimizer/Differentiation/PullbackCloner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2056,8 +2056,8 @@ void PullbackCloner::Implementation::accumulateAdjointForOptional(
// Find `Optional<T.TangentVector>.some` EnumElementDecl.
auto someEltDecl = builder.getASTContext().getOptionalSomeDecl();

// Initialize a `Optional<T.TangentVector>` buffer from `wrappedAdjoint`as the
// input for `Optional<T>.TangentVector.init`.
// Initialize an `Optional<T.TangentVector>` buffer from `wrappedAdjoint` as
// the input for `Optional<T>.TangentVector.init`.
auto *optArgBuf = builder.createAllocStack(pbLoc, optionalOfWrappedTanType);
if (optionalOfWrappedTanType.isLoadableOrOpaque(builder.getFunction())) {
// %enum = enum $Optional<T.TangentVector>, #Optional.some!enumelt,
Expand All @@ -2066,7 +2066,7 @@ void PullbackCloner::Implementation::accumulateAdjointForOptional(
optionalOfWrappedTanType);
// store %enum to %optArgBuf
builder.emitStoreValueOperation(pbLoc, enumInst, optArgBuf,
StoreOwnershipQualifier::Trivial);
StoreOwnershipQualifier::Init);
} else {
// %enumAddr = init_enum_data_addr %optArgBuf $Optional<T.TangentVector>,
// #Optional.some!enumelt
Expand Down Expand Up @@ -2279,14 +2279,15 @@ void PullbackCloner::Implementation::visitSILBasicBlock(SILBasicBlock *bb) {
for (auto pair : incomingValues) {
auto *predBB = std::get<0>(pair);
auto incomingValue = std::get<1>(pair);
blockTemporaries[getPullbackBlock(predBB)].insert(concreteBBArgAdjCopy);
// Handle `switch_enum` on `Optional`.
auto termInst = bbArg->getSingleTerminator();
if (isSwitchEnumInstOnOptional(termInst))
if (isSwitchEnumInstOnOptional(termInst)) {
accumulateAdjointForOptional(bb, incomingValue, concreteBBArgAdjCopy);
else
} else {
blockTemporaries[getPullbackBlock(predBB)].insert(concreteBBArgAdjCopy);
setAdjointValue(predBB, incomingValue,
makeConcreteAdjointValue(concreteBBArgAdjCopy));
}
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/DifferentiationUnittest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_swift_target_library(swiftDifferentiationUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
# This file should be listed first. Module name is inferred from the filename.
DifferentiationUnittest.swift
GYB_SOURCES DifferentiationUnittest.swift.gyb

SWIFT_MODULE_DEPENDS _Differentiation StdlibUnittest
INSTALL_IN_COMPONENT stdlib-experimental
Expand Down
Loading