Skip to content

Commit 2b6f70d

Browse files
committed
Map package optimization flags to new features to match
a more standard method to enable optimizations. Also set EnableSerializePackage to false by default. Ref: rdar://124648653
1 parent 3deb5d4 commit 2b6f70d

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

include/swift/AST/SILOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class SILOptions {
132132
/// to be built in the same project. To enable this optimization, the
133133
/// module also needs to opt in to allow non-resilient access with
134134
/// -experimental-allow-non-resilient-access.
135-
bool EnableSerializePackage = true;
135+
bool EnableSerializePackage = false;
136136

137137
/// Enables the emission of stack protectors in functions.
138138
bool EnableStackProtection = true;

include/swift/Basic/Features.def

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,19 @@ EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
219219

220220
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)
221221

222+
/// Enables a module to allow non resilient access from other
223+
/// modules within a package if built from source.
224+
EXPERIMENTAL_FEATURE(AllowNonResilientAccessInPackage, false)
225+
226+
/// Enables a client module within a package to bypass resilient
227+
/// access (at use site) to decls defined in another module within
228+
/// the same package.
229+
EXPERIMENTAL_FEATURE(ClientBypassResilientAccessInPackage, false)
230+
231+
/// Enables serialization of package decls and bodies and performs
232+
/// CMO within a package.
233+
EXPERIMENTAL_FEATURE(PackageCMO, false)
234+
222235
/// Whether to enable experimental layout string value witnesses
223236
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(LayoutStringValueWitnesses, true)
224237
EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE(LayoutStringValueWitnessesInstantiation, true)

lib/AST/FeatureSet.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,16 @@ static bool usesFeatureLayoutPrespecialization(Decl *decl) {
468468
}
469469

470470
UNINTERESTING_FEATURE(AccessLevelOnImport)
471+
UNINTERESTING_FEATURE(AllowNonResilientAccessInPackage)
472+
UNINTERESTING_FEATURE(ClientBypassResilientAccessInPackage)
471473
UNINTERESTING_FEATURE(LayoutStringValueWitnesses)
472474
UNINTERESTING_FEATURE(LayoutStringValueWitnessesInstantiation)
473475
UNINTERESTING_FEATURE(DifferentiableProgramming)
474476
UNINTERESTING_FEATURE(ForwardModeDifferentiation)
475477
UNINTERESTING_FEATURE(AdditiveArithmeticDerivedConformances)
476478
UNINTERESTING_FEATURE(SendableCompletionHandlers)
477479
UNINTERESTING_FEATURE(OpaqueTypeErasure)
480+
UNINTERESTING_FEATURE(PackageCMO)
478481
UNINTERESTING_FEATURE(ParserRoundTrip)
479482
UNINTERESTING_FEATURE(ParserValidation)
480483
UNINTERESTING_FEATURE(ParserDiagnostics)

lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
681681
Opts.EnablePackageInterfaceLoad = Args.hasArg(OPT_experimental_package_interface_load) ||
682682
::getenv("SWIFT_ENABLE_PACKAGE_INTERFACE_LOAD");
683683

684-
Opts.EnableBypassResilienceInPackage = Args.hasArg(OPT_experimental_package_bypass_resilience);
684+
Opts.EnableBypassResilienceInPackage = Args.hasArg(OPT_experimental_package_bypass_resilience) ||
685+
Opts.hasFeature(Feature::ClientBypassResilientAccessInPackage);
685686

686687
Opts.DisableAvailabilityChecking |=
687688
Args.hasArg(OPT_disable_availability_checking);
@@ -2101,7 +2102,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
21012102
const FrontendOptions &FEOpts,
21022103
const TypeCheckerOptions &TCOpts,
21032104
DiagnosticEngine &Diags,
2104-
const llvm::Triple &Triple,
2105+
LangOptions &LangOpts,
21052106
ClangImporterOptions &ClangOpts) {
21062107
using namespace options;
21072108

@@ -2346,7 +2347,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
23462347
Opts.CMOMode = CrossModuleOptimizationMode::Everything;
23472348
}
23482349

2349-
if (Args.hasArg(OPT_ExperimentalPackageCMO)) {
2350+
if (Args.hasArg(OPT_ExperimentalPackageCMO) ||
2351+
LangOpts.hasFeature(Feature::PackageCMO) {
23502352
if (!FEOpts.AllowNonResilientAccess) {
23512353
Diags.diagnose(SourceLoc(), diag::ignoring_option_requires_option,
23522354
"-experimental-package-cmo",
@@ -2439,7 +2441,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
24392441

24402442
if (const Arg *A = Args.getLastArg(options::OPT_sanitize_EQ)) {
24412443
Opts.Sanitizers = parseSanitizerArgValues(
2442-
Args, A, Triple, Diags,
2444+
Args, A, LangOpts.Triple, Diags,
24432445
/* sanitizerRuntimeLibExists= */[](StringRef libName, bool shared) {
24442446

24452447
// The driver has checked the existence of the library
@@ -3289,7 +3291,7 @@ bool CompilerInvocation::parseArgs(
32893291

32903292
if (ParseSILArgs(SILOpts, ParsedArgs, IRGenOpts, FrontendOpts,
32913293
TypeCheckerOpts, Diags,
3292-
LangOpts.Target, ClangImporterOpts)) {
3294+
LangOpts, ClangImporterOpts)) {
32933295
return true;
32943296
}
32953297

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,8 @@ ModuleDecl *CompilerInstance::getMainModule() const {
14021402
if (Invocation.getLangOptions().EnableCXXInterop &&
14031403
Invocation.getLangOptions().RequireCxxInteropToImportCxxInteropModule)
14041404
MainModule->setHasCxxInteroperability();
1405-
if (Invocation.getFrontendOptions().AllowNonResilientAccess)
1405+
if (Invocation.getFrontendOptions().AllowNonResilientAccess ||
1406+
Context->LangOpts.hasFeature(Feature::AllowNonResilientAccessInPackage))
14061407
MainModule->setAllowNonResilientAccess();
14071408

14081409
// Register the main module with the AST context.

0 commit comments

Comments
 (0)