Skip to content

Commit 080c4f2

Browse files
authored
---
yaml --- r: 277435 b: refs/heads/tensorflow-merge c: ee1742e h: refs/heads/master i: 277433: fa337a8 277431: ed9605f
1 parent bc90764 commit 080c4f2

File tree

7 files changed

+901
-245
lines changed

7 files changed

+901
-245
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: 3fd7afd6279c5b11b1faa33ca42adb58d2b09463
1127+
refs/heads/tensorflow-merge: ee1742e556e5e7835562a307220477561eefb659
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/SIL/SILFunctionType.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,29 @@ CanSILFunctionType SILFunctionType::getAutoDiffAssociatedFunctionType(
255255
ArrayRef<SILResultInfo> newResults,
256256
GenericSignature *genericSignature)
257257
-> CanSILFunctionType {
258-
return SILFunctionType::get(genericSignature
259-
? genericSignature
260-
: base->getGenericSignature(),
258+
if (!genericSignature)
259+
genericSignature = base->getGenericSignature();
260+
// If generic signature is specified, use it to canonical result types.
261+
// This is important for consistent typing for types like:
262+
// <T : Differentiable, T == T.CotangentVector> (...) ->
263+
// (@out T.CotangentVector)
264+
// Which should be canonicalized to:
265+
// <T : Differentiable, T == T.CotangentVector> (...) ->
266+
// (@out T)
267+
ArrayRef<SILResultInfo> results =
268+
genericSignature
269+
? map<SmallVector<SILResultInfo, 4>>(
270+
newResults, [&](SILResultInfo resInfo) {
271+
return resInfo.getWithType(
272+
resInfo.getType()->getCanonicalType(genericSignature));
273+
})
274+
: newResults;
275+
return SILFunctionType::get(genericSignature,
261276
base->getExtInfo(),
262277
base->getCoroutineKind(),
263278
base->getCalleeConvention(),
264279
base->getParameters(), base->getYields(),
265-
newResults, base->getOptionalErrorResult(), ctx,
280+
results, base->getOptionalErrorResult(), ctx,
266281
base->getWitnessMethodConformanceOrNone());
267282
};
268283

@@ -328,17 +343,14 @@ CanSILFunctionType SILFunctionType::getAutoDiffAssociatedFunctionType(
328343
results.push_back({closureType, ResultConvention::Owned});
329344
CanSILFunctionType associatedFunction =
330345
withNewResults(curryLevels.back(), results,
331-
curryLevels.size() == 1 ? whereClauseGenSig : nullptr);
346+
whereClauseGenSig);
332347

333348
auto curryLevelsWithoutLast =
334349
ArrayRef<SILFunctionType *>(curryLevels).drop_back(1);
335-
for (auto pair : enumerate(reversed(curryLevelsWithoutLast))) {
336-
unsigned i = pair.index();
337-
auto *curryLevel = pair.value();
350+
for (auto *curryLevel : reversed(curryLevelsWithoutLast))
338351
associatedFunction = withNewResults(
339352
curryLevel, {{associatedFunction, ResultConvention::Owned}},
340-
i == curryLevelsWithoutLast.size() - 1 ? whereClauseGenSig : nullptr);
341-
}
353+
whereClauseGenSig);
342354
return associatedFunction;
343355
}
344356

0 commit comments

Comments
 (0)