Skip to content

Commit 73aabff

Browse files
committed
IRGen: lazily emit shared witness tables
This avoids emitting synthesized witness tables if they are not needed.
1 parent 6ba5ebd commit 73aabff

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/IRGen/IRGenModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,12 @@ bool IRGenerator::canEmitWitnessTableLazily(SILWitnessTable *wt) {
711711
if (Opts.UseJIT)
712712
return false;
713713

714+
// Regardless of the access level, if the witness table is shared it means
715+
// we can safely not emit it. Every other module which needs it will generate
716+
// its own shared copy of it.
717+
if (wt->getLinkage() == SILLinkage::Shared)
718+
return true;
719+
714720
NominalTypeDecl *ConformingTy =
715721
wt->getConformance()->getType()->getNominalOrBoundGenericNominal();
716722

test/IRGen/objc_ns_enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import gizmo
1212
// CHECK: @"$sSo16NSRuncingOptionsVN" = linkonce_odr hidden constant
1313
// CHECK-SAME: @"$sBi{{[0-9]+}}_WV"
1414
// CHECK: @"$sSo16NSRuncingOptionsVSQSCMc" = linkonce_odr hidden constant %swift.protocol_conformance_descriptor { {{.*}}@"$sSo16NSRuncingOptionsVSQSCWa
15-
// CHECK: @"$sSo28NeverActuallyMentionedByNameVSQSCWp" = linkonce_odr hidden constant
15+
// CHECK-NOT: @"$sSo28NeverActuallyMentionedByNameVSQSCWp" = linkonce_odr hidden constant
1616

1717
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} i32 @main
1818
// CHECK: call swiftcc %swift.metadata_response @"$sSo16NSRuncingOptionsVMa"(i64 0)

0 commit comments

Comments
 (0)