Skip to content

Commit 9639e00

Browse files
committed
Teach TBD that in fragile resilient protocol mode the protocol table is visible
1 parent b35be13 commit 9639e00

File tree

7 files changed

+14
-4
lines changed

7 files changed

+14
-4
lines changed

include/swift/IRGen/TBDGen.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ struct TBDGenOptions {
4747
/// Whether LLVM IR Witness Method Elimination is enabled.
4848
bool WitnessMethodElimination = false;
4949

50+
/// Whether resilient protocols should be emitted fragile.
51+
bool FragileResilientProtocols = false;
52+
5053
/// The install_name to use in the TBD file.
5154
std::string InstallName;
5255

@@ -78,6 +81,7 @@ struct TBDGenOptions {
7881
lhs.PublicOrPackageSymbolsOnly == rhs.PublicOrPackageSymbolsOnly &&
7982
lhs.VirtualFunctionElimination == rhs.VirtualFunctionElimination &&
8083
lhs.WitnessMethodElimination == rhs.WitnessMethodElimination &&
84+
lhs.FragileResilientProtocols == rhs.FragileResilientProtocols &&
8185
lhs.InstallName == rhs.InstallName &&
8286
lhs.ModuleLinkName == rhs.ModuleLinkName &&
8387
lhs.CurrentVersion == rhs.CurrentVersion &&
@@ -95,7 +99,7 @@ struct TBDGenOptions {
9599
return hash_combine(
96100
opts.HasMultipleIGMs, opts.IsInstallAPI, opts.LinkerDirectivesOnly,
97101
opts.PublicOrPackageSymbolsOnly, opts.VirtualFunctionElimination,
98-
opts.WitnessMethodElimination,
102+
opts.WitnessMethodElimination, opts.FragileResilientProtocols,
99103
opts.InstallName, opts.ModuleLinkName,
100104
opts.CurrentVersion, opts.CompatibilityVersion,
101105
opts.ModuleInstallNameMapPath,

include/swift/SIL/SILSymbolVisitor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ struct SILSymbolVisitorOptions {
3939

4040
/// Whether LLVM IR Witness Method Elimination is enabled.
4141
bool WitnessMethodElimination = false;
42+
43+
/// Whether resilient protocols should be emitted fragile.
44+
bool FragileResilientProtocols = false;
4245
};
4346

4447
/// Context for `SILSymbolVisitor` symbol enumeration.

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,8 @@ static bool ParseTBDGenArgs(TBDGenOptions &Opts, ArgList &Args,
25212521

25222522
Opts.VirtualFunctionElimination = Args.hasArg(OPT_enable_llvm_vfe);
25232523
Opts.WitnessMethodElimination = Args.hasArg(OPT_enable_llvm_wme);
2524+
Opts.FragileResilientProtocols =
2525+
Args.hasArg(OPT_enable_fragile_resilient_protocol_witnesses);
25242526

25252527
if (const Arg *A = Args.getLastArg(OPT_tbd_compatibility_version)) {
25262528
Opts.CompatibilityVersion = A->getValue();

lib/IRGen/TBDGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ void TBDGenVisitor::visit(const TBDGenDescriptor &desc) {
511511
opts.PublicOrPackageSymbolsOnly = Opts.PublicOrPackageSymbolsOnly;
512512
opts.WitnessMethodElimination = Opts.WitnessMethodElimination;
513513
opts.VirtualFunctionElimination = Opts.VirtualFunctionElimination;
514+
opts.FragileResilientProtocols = Opts.FragileResilientProtocols;
514515

515516
auto silVisitorCtx = SILSymbolVisitorContext(SwiftModule, opts);
516517
auto visitorCtx = IRSymbolVisitorContext{UniversalLinkInfo, silVisitorCtx};

lib/SIL/IR/SILSymbolVisitor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
269269
// We cannot emit the witness table symbol if the protocol is imported
270270
// from another module and it's resilient, because initialization of that
271271
// protocol is necessary in this case
272-
if (!rootConformance->getProtocol()->isResilient(
272+
if (Ctx.getOpts().FragileResilientProtocols ||
273+
!rootConformance->getProtocol()->isResilient(
273274
IDC->getAsGenericContext()->getParentModule(),
274275
ResilienceExpansion::Maximal))
275276
Visitor.addProtocolWitnessTable(rootConformance);

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ function(_compile_swift_files
627627
endif()
628628

629629
if (SWIFT_STDLIB_USE_FRAGILE_RESILIENT_PROTOCOL_WITNESS_TABLES)
630-
list(APPEND swift_flags "-Xfrontend" "-validate-tbd-against-ir=none")
631630
list(APPEND swift_flags "-Xfrontend" "-enable-fragile-relative-protocol-tables")
632631
list(APPEND swift_flags "-enable-library-evolution")
633632
endif()

test/lit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ if run_vendor == 'apple':
11871187
swift_execution_tests_extra_flags += ' -Xfrontend -enable-relative-protocol-witness-tables -Xfrontend -swift-async-frame-pointer=never'
11881188

11891189
if config.swift_stdlib_use_use_fragile_resilient_protocol_witness_tables:
1190-
swift_execution_tests_extra_flags += ' -Xfrontend -validate-tbd-against-ir=none -Xfrontend -enable-fragile-relative-protocol-tables'
1190+
swift_execution_tests_extra_flags += ' -Xfrontend -enable-fragile-relative-protocol-tables'
11911191

11921192
# Build a resource dir for freestanding tests.
11931193
new_resource_dir = os.path.join(config.test_exec_root, "resource_dir")

0 commit comments

Comments
 (0)