Skip to content

Commit bb9f5c0

Browse files
authored
---
yaml --- r: 277437 b: refs/heads/tensorflow-merge c: 9511f40 h: refs/heads/master i: 277435: 080c4f2
1 parent 74f0855 commit bb9f5c0

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-29-a: 1b087071edaea398480fb778e
11241124
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-30-a: 8bc9e108e1480d9217299984e428c601c7aaac75
11251125
refs/tags/swift-4.2.1-RELEASE: 02a6ca969ea1387475b6caeb69c31186df7d30b6
11261126
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-11-01-a: 3b0299288f8287094b9ef587f46df54f42a347af
1127-
refs/heads/tensorflow-merge: a3cb68e3a2f90cb1b04e988d1d1d1ef442eb1371
1127+
refs/heads/tensorflow-merge: 9511f404ceae43fdaa91263a396716a22b17f9e0
11281128
refs/heads/TensorFlowLite: b91446471276e37bbfe64767c875f3c7f7102954
11291129
refs/heads/ad-side-effects: 19e0c0de1f59b0929c381925df2e8c72cdf4a728
11301130
refs/heads/add-test-for-asan-compiler-crash: 3cdeecffb47bf28707b299fa2b5bdf0769a4a826

branches/tensorflow-merge/lib/SILOptimizer/Mandatory/Differentiation.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4604,7 +4604,7 @@ void AdjointEmitter::materializeAdjointIndirectHelper(
46044604

46054605
void AdjointEmitter::emitZeroIndirect(CanType type, SILValue bufferAccess,
46064606
SILLocation loc) {
4607-
// Lookup `AdditiveArithmetic.zero.getter`.
4607+
// Look up `AdditiveArithmetic.zero.getter`.
46084608
auto *additiveArithmeticProto =
46094609
getASTContext().getProtocol(KnownProtocolKind::AdditiveArithmetic);
46104610
auto initDeclLookup =
@@ -4615,20 +4615,21 @@ void AdjointEmitter::emitZeroIndirect(CanType type, SILValue bufferAccess,
46154615
SILDeclRef accessorDeclRef(accessorDecl, SILDeclRef::Kind::Func);
46164616
auto methodType =
46174617
getContext().getTypeConverter().getConstantType(accessorDeclRef);
4618-
// Lookup conformance to `AdditiveArithmetic`.
4618+
// Look up conformance to `AdditiveArithmetic`.
46194619
auto *swiftMod = getModule().getSwiftModule();
4620-
auto conf = swiftMod->lookupConformance(type, additiveArithmeticProto);
4621-
assert(conf.hasValue() && "No conformance to AdditiveArithmetic?");
4622-
ProtocolConformanceRef confRef(*conf);
4620+
auto confRef = swiftMod->lookupConformance(type, additiveArithmeticProto);
4621+
// TODO(TF-202): Diagnose no `AdditiveArithmetic` due to generic signature
4622+
// minimization bug.
4623+
assert(confRef.hasValue() && "Missing conformance to `AdditiveArithmetic`");
46234624
// %wm = witness_method ...
4624-
auto *getter = builder.createWitnessMethod(loc, type, confRef,
4625+
auto *getter = builder.createWitnessMethod(loc, type, *confRef,
46254626
accessorDeclRef, methodType);
46264627
// %metatype = metatype $T
46274628
auto metatypeType = CanMetatypeType::get(type, MetatypeRepresentation::Thick);
46284629
auto metatype = builder.createMetatype(
46294630
loc, SILType::getPrimitiveObjectType(metatypeType));
46304631
auto subMap = SubstitutionMap::getProtocolSubstitutions(
4631-
additiveArithmeticProto, type, confRef);
4632+
additiveArithmeticProto, type, *confRef);
46324633
builder.createApply(loc, getter, subMap, {bufferAccess, metatype},
46334634
/*isNonThrowing*/ false);
46344635
}
@@ -4838,14 +4839,18 @@ void AdjointEmitter::accumulateIndirect(
48384839
auto adjointParentModule = cotangentSpace->getNominal()
48394840
? cotangentSpace->getNominal()->getModuleContext()
48404841
: getModule().getSwiftModule();
4841-
auto confRef = *adjointParentModule->lookupConformance(adjointASTTy, proto);
4842+
auto confRef = adjointParentModule->lookupConformance(adjointASTTy, proto);
4843+
// TODO(TF-202): Diagnose no `AdditiveArithmetic` due to generic signature
4844+
// minimization bug.
4845+
assert(confRef.hasValue() && "Missing conformance to `AdditiveArithmetic`");
48424846
SILDeclRef declRef(combinerFuncDecl, SILDeclRef::Kind::Func);
48434847
auto silFnTy = getContext().getTypeConverter().getConstantType(declRef);
48444848
// %0 = witness_method @+
48454849
auto witnessMethod = builder.createWitnessMethod(loc, adjointASTTy,
4846-
confRef, declRef, silFnTy);
4847-
auto subMap =
4848-
SubstitutionMap::getProtocolSubstitutions(proto, adjointASTTy, confRef);
4850+
*confRef, declRef,
4851+
silFnTy);
4852+
auto subMap = SubstitutionMap::getProtocolSubstitutions(
4853+
proto, adjointASTTy, *confRef);
48494854
// %1 = metatype $T.Type
48504855
auto metatypeType =
48514856
CanMetatypeType::get(adjointASTTy, MetatypeRepresentation::Thick);
@@ -4891,14 +4896,15 @@ void AdjointEmitter::accumulateIndirect(SILValue lhsDestAccess,
48914896
auto *proto = getContext().getAdditiveArithmeticProtocol();
48924897
auto *accumulatorFuncDecl = getContext().getPlusEqualDecl();
48934898
// Call the combiner function and return.
4894-
auto confRef = *swiftMod->lookupConformance(astType, proto);
4899+
auto confRef = swiftMod->lookupConformance(astType, proto);
4900+
assert(confRef.hasValue() && "Missing conformance to `AdditiveArithmetic`");
48954901
SILDeclRef declRef(accumulatorFuncDecl, SILDeclRef::Kind::Func);
48964902
auto silFnTy = getContext().getTypeConverter().getConstantType(declRef);
48974903
// %0 = witness_method @+=
48984904
auto witnessMethod =
4899-
builder.createWitnessMethod(loc, astType, confRef, declRef, silFnTy);
4905+
builder.createWitnessMethod(loc, astType, *confRef, declRef, silFnTy);
49004906
auto subMap =
4901-
SubstitutionMap::getProtocolSubstitutions(proto, astType, confRef);
4907+
SubstitutionMap::getProtocolSubstitutions(proto, astType, *confRef);
49024908
// %1 = metatype $T.Type
49034909
auto metatypeType =
49044910
CanMetatypeType::get(astType, MetatypeRepresentation::Thick);

0 commit comments

Comments
 (0)