Skip to content

Commit f2e8e0a

Browse files
authored
Merge pull request swiftlang#12493 from swiftix/sil-serialization-before-optimizations5
Enable serialization of witness tables by default
2 parents f2cbe01 + 35a624b commit f2e8e0a

File tree

69 files changed

+90
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+90
-131
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ function(_compile_swift_files
256256
"-Xfrontend" "${GROUP_INFO_JSON_FILE}")
257257
if (NOT SWIFT_STDLIB_ENABLE_RESILIENCE)
258258
if (SWIFT_STDLIB_SIL_SERIALIZE_ALL)
259-
list(APPEND swift_flags "-Xfrontend" "-sil-serialize-witness-tables"
260-
"-Xfrontend" "-sil-serialize-vtables")
259+
list(APPEND swift_flags "-Xfrontend" "-sil-serialize-vtables")
261260
endif()
262261
endif()
263262
endif()

include/swift/AST/SILOptions.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ class SILOptions {
150150
/// \brief Enable large loadable types IRGen pass.
151151
bool EnableLargeLoadableTypes = true;
152152

153-
/// If set, SIL witness tables will be serialized.
154-
///
155-
/// It is supposed to be used only for compiling overlays.
156-
/// User code should never be compiled with this flag set.
157-
bool SILSerializeWitnessTables = false;
158-
159153
/// If set, SIL vtables will be serialized.
160154
///
161155
/// It is supposed to be used only for compiling overlays.

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ def sil_merge_partial_modules : Flag<["-"], "sil-merge-partial-modules">,
372372
def sil_link_all : Flag<["-"], "sil-link-all">,
373373
HelpText<"Link all SIL functions">;
374374

375-
def sil_serialize_witness_tables : Flag<["-"], "sil-serialize-witness-tables">,
376-
HelpText<"Serialize eligible SIL witness tables">;
377-
378375
def sil_serialize_vtables : Flag<["-"], "sil-serialize-vtables">,
379376
HelpText<"Serialize eligible SIL vtables">;
380377

include/swift/SIL/SILWitnessTable.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
273273

274274
// Whether a conformance should be serialized.
275275
static bool conformanceIsSerialized(ProtocolConformance *conformance,
276-
ResilienceStrategy strategy,
277-
bool silSerializeWitnessTables);
276+
ResilienceStrategy strategy);
278277

279278
/// Print the witness table.
280279
void print(llvm::raw_ostream &OS, bool Verbose = false) const;

include/swift/TBDGen/TBDGen.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ class FileUnit;
2424
class ModuleDecl;
2525

2626
void enumeratePublicSymbols(FileUnit *module, llvm::StringSet<> &symbols,
27-
bool hasMultipleIRGenThreads,
28-
bool silSerializeWitnessTables);
27+
bool hasMultipleIRGenThreads);
2928
void enumeratePublicSymbols(ModuleDecl *module, llvm::StringSet<> &symbols,
30-
bool hasMultipleIRGenThreads,
31-
bool silSerializeWitnessTables);
29+
bool hasMultipleIRGenThreads);
3230

3331
void writeTBDFile(ModuleDecl *M, llvm::raw_ostream &os,
34-
bool hasMultipleIRGenThreads, bool silSerializeWitnessTables,
32+
bool hasMultipleIRGenThreads,
3533
llvm::StringRef installName);
3634

3735
} // end namespace swift

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
12081208
if (Args.hasArg(OPT_sil_merge_partial_modules))
12091209
Opts.MergePartialModules = true;
12101210

1211-
Opts.SILSerializeWitnessTables |=
1212-
Args.hasArg(OPT_sil_serialize_witness_tables);
12131211
Opts.SILSerializeVTables |=
12141212
Args.hasArg(OPT_sil_serialize_vtables);
12151213

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ static bool performCompile(CompilerInstance &Instance,
756756
: opts.TBDInstallName;
757757

758758
if (writeTBD(Instance.getMainModule(), hasMultipleIRGenThreads,
759-
silOpts.SILSerializeWitnessTables, opts.TBDPath, installName))
759+
opts.TBDPath, installName))
760760
return true;
761761
}
762762

@@ -1064,11 +1064,11 @@ static bool performCompile(CompilerInstance &Instance,
10641064
bool error;
10651065
if (PrimarySourceFile)
10661066
error = validateTBD(PrimarySourceFile, *IRModule, hasMultipleIRGenThreads,
1067-
silOpts.SILSerializeWitnessTables, allSymbols);
1067+
allSymbols);
10681068
else
10691069
error = validateTBD(Instance.getMainModule(), *IRModule,
10701070
hasMultipleIRGenThreads,
1071-
silOpts.SILSerializeWitnessTables, allSymbols);
1071+
allSymbols);
10721072
if (error)
10731073
return true;
10741074

lib/FrontendTool/TBD.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static std::vector<StringRef> sortSymbols(llvm::StringSet<> &symbols) {
3939
}
4040

4141
bool swift::writeTBD(ModuleDecl *M, bool hasMultipleIRGenThreads,
42-
bool silSerializeWitnessTables, StringRef OutputFilename,
42+
StringRef OutputFilename,
4343
StringRef installName) {
4444
std::error_code EC;
4545
llvm::raw_fd_ostream OS(OutputFilename, EC, llvm::sys::fs::F_None);
@@ -49,8 +49,7 @@ bool swift::writeTBD(ModuleDecl *M, bool hasMultipleIRGenThreads,
4949
return true;
5050
}
5151

52-
writeTBDFile(M, OS, hasMultipleIRGenThreads, silSerializeWitnessTables,
53-
installName);
52+
writeTBDFile(M, OS, hasMultipleIRGenThreads, installName);
5453

5554
return false;
5655
}
@@ -120,23 +119,19 @@ static bool validateSymbolSet(DiagnosticEngine &diags,
120119

121120
bool swift::validateTBD(ModuleDecl *M, llvm::Module &IRModule,
122121
bool hasMultipleIRGenThreads,
123-
bool silSerializeWitnessTables,
124122
bool diagnoseExtraSymbolsInTBD) {
125123
llvm::StringSet<> symbols;
126-
enumeratePublicSymbols(M, symbols, hasMultipleIRGenThreads,
127-
silSerializeWitnessTables);
124+
enumeratePublicSymbols(M, symbols, hasMultipleIRGenThreads);
128125

129126
return validateSymbolSet(M->getASTContext().Diags, symbols, IRModule,
130127
diagnoseExtraSymbolsInTBD);
131128
}
132129

133130
bool swift::validateTBD(FileUnit *file, llvm::Module &IRModule,
134131
bool hasMultipleIRGenThreads,
135-
bool silSerializeWitnessTables,
136132
bool diagnoseExtraSymbolsInTBD) {
137133
llvm::StringSet<> symbols;
138-
enumeratePublicSymbols(file, symbols, hasMultipleIRGenThreads,
139-
silSerializeWitnessTables);
134+
enumeratePublicSymbols(file, symbols, hasMultipleIRGenThreads);
140135

141136
return validateSymbolSet(file->getParentModule()->getASTContext().Diags,
142137
symbols, IRModule, diagnoseExtraSymbolsInTBD);

lib/FrontendTool/TBD.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ class FileUnit;
2525
class FrontendOptions;
2626

2727
bool writeTBD(ModuleDecl *M, bool hasMultipleIRGenThreads,
28-
bool silSerializeWitnessTables, llvm::StringRef OutputFilename,
28+
llvm::StringRef OutputFilename,
2929
llvm::StringRef installName);
3030
bool inputFileKindCanHaveTBDValidated(InputFileKind kind);
3131
bool validateTBD(ModuleDecl *M, llvm::Module &IRModule,
32-
bool hasMultipleIRGenThreads, bool silSerializeWitnessTables,
32+
bool hasMultipleIRGenThreads,
3333
bool diagnoseExtraSymbolsInTBD);
3434
bool validateTBD(FileUnit *M, llvm::Module &IRModule,
35-
bool hasMultipleIRGenThreads, bool silSerializeWitnessTables,
35+
bool hasMultipleIRGenThreads,
3636
bool diagnoseExtraSymbolsInTBD);
3737
}
3838

lib/SIL/SILWitnessTable.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ Identifier SILWitnessTable::getIdentifier() const {
159159
}
160160

161161
bool SILWitnessTable::conformanceIsSerialized(ProtocolConformance *conformance,
162-
ResilienceStrategy strategy,
163-
bool silSerializeWitnessTables) {
162+
ResilienceStrategy strategy) {
164163
// Serialize witness tables for conformances synthesized by
165164
// the ClangImporter.
166165
if (isa<ClangModuleUnit>(conformance->getDeclContext()->getModuleScopeContext()))
@@ -174,6 +173,5 @@ bool SILWitnessTable::conformanceIsSerialized(ProtocolConformance *conformance,
174173
auto protocolIsPublic =
175174
conformance->getProtocol()->getEffectiveAccess() >= AccessLevel::Public;
176175
auto typeIsPublic = nominal->getEffectiveAccess() >= AccessLevel::Public;
177-
return (moduleIsResilient || silSerializeWitnessTables) &&
178-
nominal->hasFixedLayout() && protocolIsPublic && typeIsPublic;
176+
return nominal->hasFixedLayout() && protocolIsPublic && typeIsPublic;
179177
}

0 commit comments

Comments
 (0)