Skip to content

Commit 5b632bd

Browse files
authored
Merge pull request #69110 from tshortli/rename-experimental-serialize-external-decls
Frontend: Introduce -experimental-skip-non-exportable-decls
2 parents 0d926e6 + f131c8a commit 5b632bd

File tree

10 files changed

+21
-18
lines changed

10 files changed

+21
-18
lines changed

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,12 @@ class SILOptions {
183183
/// when possible.
184184
bool EnablePackMetadataStackPromotion = true;
185185

186-
// The kind of function bodies to skip emitting.
186+
/// The kind of function bodies to skip emitting.
187187
FunctionBodySkipping SkipFunctionBodies = FunctionBodySkipping::None;
188188

189+
/// Whether to skip declarations that are internal to the module.
190+
bool SkipNonExportableDecls = false;
191+
189192
/// Optimization mode being used.
190193
OptimizationMode OptMode = OptimizationMode::NotSet;
191194

include/swift/Frontend/FrontendOptions.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,8 @@ class FrontendOptions {
324324
/// times) when compiling a module interface?
325325
bool SerializeModuleInterfaceDependencyHashes = false;
326326

327-
/// Should we only serialize decls that may be referenced externally in the
328-
/// binary module?
329-
bool SerializeExternalDeclsOnly = false;
327+
/// Should we skip decls that cannot be referenced externally?
328+
bool SkipNonExportableDecls = false;
330329

331330
/// Should we warn if an imported module needed to be rebuilt from a
332331
/// module interface file?

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ def serialize_debugging_options : Flag<["-"], "serialize-debugging-options">,
197197
def serialized_path_obfuscate : Separate<["-"], "serialized-path-obfuscate">,
198198
HelpText<"Remap source paths in debug info">, MetaVarName<"<prefix=replacement>">;
199199

200-
def experimental_serialize_external_decls_only
201-
: Flag<["-"], "experimental-serialize-external-decls-only">,
202-
HelpText<"Only serialize decls that should be exposed to clients">;
203-
204200
def empty_abi_descriptor : Flag<["-"], "empty-abi-descriptor">,
205201
HelpText<"Avoid printing actual module content into ABI descriptor file">;
206202

@@ -1135,6 +1131,10 @@ def experimental_allow_module_with_compiler_errors:
11351131
Flags<[HelpHidden]>,
11361132
HelpText<"Attempt to output .swiftmodule, regardless of compilation errors">;
11371133

1134+
def experimental_skip_non_exportable_decls
1135+
: Flag<["-"], "experimental-skip-non-exportable-decls">,
1136+
HelpText<"Skip decls that are not exported to clients">;
1137+
11381138
def bad_file_descriptor_retry_count:
11391139
Separate<["-"], "bad-file-descriptor-retry-count">,
11401140
HelpText<"Number of retrying opening a file if previous open returns a bad "

include/swift/Serialization/SerializationOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ namespace swift {
157157
bool HermeticSealAtLink = false;
158158
bool EmbeddedSwiftModule = false;
159159
bool IsOSSA = false;
160-
bool SerializeExternalDeclsOnly = false;
160+
bool SkipNonExportableDecls = false;
161161
};
162162

163163
} // end namespace swift

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ bool ArgsToFrontendOptionsConverter::convert(
320320
A->getOption().matches(OPT_serialize_debugging_options);
321321
}
322322

323-
Opts.SerializeExternalDeclsOnly |=
324-
Args.hasArg(OPT_experimental_serialize_external_decls_only);
323+
Opts.SkipNonExportableDecls |=
324+
Args.hasArg(OPT_experimental_skip_non_exportable_decls);
325325
Opts.DebugPrefixSerializedDebuggingOptions |=
326326
Args.hasArg(OPT_prefix_serialized_debugging_options);
327327
Opts.EnableSourceImport |= Args.hasArg(OPT_enable_source_import);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
20002000
// -experimental-skip-*-function-bodies to SIL.
20012001
Opts.SkipFunctionBodies = TCOpts.SkipFunctionBodies;
20022002

2003+
// Propagate -experimental-skip-non-exportable-decls to SIL.
2004+
Opts.SkipNonExportableDecls = FEOpts.SkipNonExportableDecls;
2005+
20032006
// Parse the optimization level.
20042007
// Default to Onone settings if no option is passed.
20052008
Opts.OptMode = OptimizationMode::NoOptimization;

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
238238

239239
serializationOpts.IsOSSA = getSILOptions().EnableOSSAModules;
240240

241-
serializationOpts.SerializeExternalDeclsOnly =
242-
opts.SerializeExternalDeclsOnly;
241+
serializationOpts.SkipNonExportableDecls = opts.SkipNonExportableDecls;
243242

244243
return serializationOpts;
245244
}

lib/Serialization/Serialization.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4863,12 +4863,11 @@ static bool canSkipWhenInvalid(const Decl *D) {
48634863
}
48644864

48654865
bool Serializer::shouldSkipDecl(const Decl *D) const {
4866-
// The presence of -experimental-serialize-external-decls-only is the only
4866+
// The presence of -experimental-skip-non-exportable-decls is the only
48674867
// reason to omit decls during serialization.
4868-
if (!Options.SerializeExternalDeclsOnly)
4868+
if (!Options.SkipNonExportableDecls)
48694869
return false;
48704870

4871-
// For our purposes, "deserialization safe" is the same thing as "external".
48724871
if (DeclSerializer::isDeserializationSafe(D))
48734872
return false;
48744873

test/Serialization/serialize-external-decls-only-lazy-typecheck.swift renamed to test/Serialization/lazy-typecheck.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -enable-library-evolution -parse-as-library -package-name Package -DFLAG -typecheck -verify
3-
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -emit-module -emit-module-path %t/lazy_typecheck.swiftmodule -enable-library-evolution -parse-as-library -package-name Package -DFLAG -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-serialize-external-decls-only
3+
// RUN: %target-swift-frontend -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -emit-module -emit-module-path %t/lazy_typecheck.swiftmodule -enable-library-evolution -parse-as-library -package-name Package -DFLAG -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-skip-non-exportable-decls
44

55
// RUN: %target-swift-frontend -package-name Package -typecheck -verify %S/../Inputs/lazy_typecheck_client.swift -DFLAG -I %t
66

test/TBD/lazy-typecheck.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %s %t
33

4-
// RUN: %target-swift-frontend -target arm64-apple-macosx10.13 -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -emit-module -emit-module-path /dev/null -emit-tbd-path %t/lazy_typecheck.tbd -enable-library-evolution -parse-as-library -package-name Package -DFLAG -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-serialize-external-decls-only
4+
// RUN: %target-swift-frontend -target arm64-apple-macosx10.13 -swift-version 5 %S/../Inputs/lazy_typecheck.swift -module-name lazy_typecheck -emit-module -emit-module-path /dev/null -emit-tbd-path %t/lazy_typecheck.tbd -enable-library-evolution -parse-as-library -package-name Package -DFLAG -experimental-lazy-typecheck -experimental-skip-all-function-bodies -experimental-skip-non-exportable-decls
55
// RUN: %llvm-readtapi %t/lazy_typecheck.tbd %t/expected.tbd
66

77
// REQUIRES: OS=macosx

0 commit comments

Comments
 (0)