From abf65bb14332a0955511ef1cca24a0a1647bee96 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Mon, 15 Jun 2020 15:16:06 -0700 Subject: [PATCH] IRGen: Use the right descriminator for AutoDiffDerivativeFunctions Fixes the failure in AutoDiff/validation-test/forward_mode.swift on arm64e. rdar://64192250 --- include/swift/SIL/SILDeclRef.h | 10 ++++++++++ lib/IRGen/GenMeta.cpp | 3 +++ 2 files changed, 13 insertions(+) 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); }