Skip to content

Commit b6ce719

Browse files
authored
---
yaml --- r: 340969 b: refs/heads/rxwei-patch-1 c: d788bba h: refs/heads/master i: 340967: 2aedf0e
1 parent 7d68093 commit b6ce719

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: b4483dac64121a60ee46a8f28f3c29ddf1c1abf5
1018+
refs/heads/rxwei-patch-1: d788bba41ec71f7d42bf61d1f080c5e79a211172
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/lib/Serialization/Serialization.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,24 @@ bool Serializer::isDeclXRef(const Decl *D) const {
20402040
// Special-case for SIL generic parameter decls, which don't have a real
20412041
// DeclContext.
20422042
if (!isa<FileUnit>(topLevel)) {
2043-
assert(isa<GenericTypeParamDecl>(D) && "unexpected decl kind");
2043+
// SWIFT_ENABLE_TENSORFLOW
2044+
// FIXME(TF-623): Find a robust way to special-casing structs/enums
2045+
// synthesized during SIL differentiation transform.
2046+
auto isDifferentiationDataStructure = [](const Decl *D) {
2047+
auto *valueDecl = dyn_cast<ValueDecl>(D);
2048+
if (!valueDecl)
2049+
return false;
2050+
if (auto *structDecl =
2051+
valueDecl->getInterfaceType()->getStructOrBoundGenericStruct())
2052+
return structDecl->getNameStr().contains("__PB__");
2053+
if (auto *enumDecl =
2054+
valueDecl->getInterfaceType()->getEnumOrBoundGenericEnum())
2055+
return enumDecl->getNameStr().contains("__Pred__");
2056+
return false;
2057+
};
2058+
assert(
2059+
(isa<GenericTypeParamDecl>(D) || isDifferentiationDataStructure(D)) &&
2060+
"unexpected decl kind");
20442061
return false;
20452062
}
20462063
return true;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend -emit-sib -primary-file %s
2+
3+
// Test AST serialization of differentiation generated structs/enums.
4+
@differentiable
5+
func TF_623(_ x: Float) -> Float {
6+
if x > 0 {}
7+
return x
8+
}

0 commit comments

Comments
 (0)