Skip to content

Commit d2bff92

Browse files
committed
IRGen: Don't emit method descriptors for derivative functions.
The symbol mangling for the descriptors doesn't incorporate the derivative information, leading to symbol collisions.
1 parent 1a77850 commit d2bff92

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/swift/IRGen/Linking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ class LinkEntity {
575575
static bool isValidResilientMethodRef(SILDeclRef declRef) {
576576
if (declRef.isForeign)
577577
return false;
578-
578+
579579
auto *decl = declRef.getDecl();
580580
return (isa<ClassDecl>(decl->getDeclContext()) ||
581581
isa<ProtocolDecl>(decl->getDeclContext()));

lib/IRGen/GenMeta.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,8 +1609,9 @@ namespace {
16091609
}
16101610

16111611
void emitMethodDescriptor(SILDeclRef fn) {
1612+
16121613
// Define the method descriptor to point to the current position in the
1613-
// nominal type descriptor.
1614+
// nominal type descriptor, if it has a well-defined symbol name.
16141615
IGM.defineMethodDescriptor(fn, Type,
16151616
B.getAddrOfCurrentPosition(IGM.MethodDescriptorStructTy));
16161617

@@ -1628,7 +1629,12 @@ namespace {
16281629
}
16291630

16301631
void emitNonoverriddenMethod(SILDeclRef fn) {
1631-
HasNonoverriddenMethods = true;
1632+
// TODO: Derivative functions do not distinguish themselves in the mangled
1633+
// names of method descriptor symbols yet, causing symbol name collisions.
1634+
if (fn.derivativeFunctionIdentifier)
1635+
return;
1636+
1637+
HasNonoverriddenMethods = true;
16321638
// Although this method is non-overridden and therefore left out of the
16331639
// vtable, we still need to maintain the ABI of a potentially-overridden
16341640
// method for external clients.

0 commit comments

Comments
 (0)