Skip to content

Commit 1a77850

Browse files
committed
IRGen: Don't drop method descriptors for vtable-elided internal methods.
We still use the method descriptor for key path identity and other uses. Fixes rdar://problem/66280170.
1 parent 2680b0c commit 1a77850

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ namespace {
14921492
void addMethod(SILDeclRef fn) {
14931493
if (!VTable || methodRequiresReifiedVTableEntry(IGM, VTable, fn)) {
14941494
VTableEntries.push_back(fn);
1495-
} else if (hasPublicVisibility(fn.getLinkage(NotForDefinition))) {
1495+
} else {
14961496
// Emit a stub method descriptor and lookup function for nonoverridden
14971497
// methods so that resilient code sequences can still use them.
14981498
emitNonoverriddenMethod(fn);
@@ -1634,7 +1634,10 @@ namespace {
16341634
// method for external clients.
16351635

16361636
// Emit method dispatch thunk.
1637-
IGM.emitDispatchThunk(fn);
1637+
if (hasPublicVisibility(fn.getLinkage(NotForDefinition))) {
1638+
IGM.emitDispatchThunk(fn);
1639+
}
1640+
16381641
// Emit a freestanding method descriptor structure. This doesn't have to
16391642
// exist in the table in the class's context descriptor since it isn't
16401643
// in the vtable, but external clients need to be able to link against the

test/IRGen/vtable_non_overridden.sil

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ sil_vtable InternalA {
2424
#InternalA.bas : @InternalA_bas [nonoverridden]
2525
}
2626

27+
// -- we should still generate method descriptors for the elided methods
28+
// CHECK-LABEL: @"$s21vtable_non_overridden9InternalAC3fooyyFTq" =
29+
// CHECK-LABEL: @"$s21vtable_non_overridden9InternalAC3basyyFTq" =
30+
2731
// -- only overridden entries in internal method descriptor table
2832
// CHECK-LABEL: @"$s21vtable_non_overridden9InternalACMn" =
2933
// CHECK-SAME: i32 2, %swift.method_descriptor

0 commit comments

Comments
 (0)