diff --git a/include/swift/SIL/SILDeclRef.h b/include/swift/SIL/SILDeclRef.h index 1cb4c2d5b1b38..542435e3ef3ec 100644 --- a/include/swift/SIL/SILDeclRef.h +++ b/include/swift/SIL/SILDeclRef.h @@ -397,6 +397,16 @@ struct SILDeclRef { bool canBeDynamicReplacement() const; + bool isAutoDiffDerivativeFunction() const { + return derivativeFunctionIdentifier != nullptr; + } + + AutoDiffDerivativeFunctionIdentifier * + getAutoDiffDerivativeFunctionIdentifier() const { + assert(isAutoDiffDerivativeFunction()); + return derivativeFunctionIdentifier; + } + private: friend struct llvm::DenseMapInfo; /// Produces a SILDeclRef from an opaque value. diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp index 827f5991da022..a4db214165cee 100644 --- a/lib/IRGen/GenMeta.cpp +++ b/lib/IRGen/GenMeta.cpp @@ -739,6 +739,9 @@ namespace { isa(func.getDecl()) ? SILDeclRef::Kind::Allocator : SILDeclRef::Kind::Func); + if (entry.getFunction().isAutoDiffDerivativeFunction()) + declRef = declRef.asAutoDiffDerivativeFunction( + entry.getFunction().getAutoDiffDerivativeFunctionIdentifier()); addDiscriminator(flags, schema, declRef); }