Skip to content

Commit ecaf9af

Browse files
Merge pull request #32396 from aschwaighofer/irgen_fix_discriminator_auto_diff_deriv
IRGen: Use the right descriminator for AutoDiffDerivativeFunctions
2 parents 9617cfe + abf65bb commit ecaf9af

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/swift/SIL/SILDeclRef.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,16 @@ struct SILDeclRef {
397397

398398
bool canBeDynamicReplacement() const;
399399

400+
bool isAutoDiffDerivativeFunction() const {
401+
return derivativeFunctionIdentifier != nullptr;
402+
}
403+
404+
AutoDiffDerivativeFunctionIdentifier *
405+
getAutoDiffDerivativeFunctionIdentifier() const {
406+
assert(isAutoDiffDerivativeFunction());
407+
return derivativeFunctionIdentifier;
408+
}
409+
400410
private:
401411
friend struct llvm::DenseMapInfo<swift::SILDeclRef>;
402412
/// Produces a SILDeclRef from an opaque value.

lib/IRGen/GenMeta.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ namespace {
739739
isa<ConstructorDecl>(func.getDecl())
740740
? SILDeclRef::Kind::Allocator
741741
: SILDeclRef::Kind::Func);
742+
if (entry.getFunction().isAutoDiffDerivativeFunction())
743+
declRef = declRef.asAutoDiffDerivativeFunction(
744+
entry.getFunction().getAutoDiffDerivativeFunctionIdentifier());
742745
addDiscriminator(flags, schema, declRef);
743746
}
744747

0 commit comments

Comments
 (0)