Skip to content

Commit cb77608

Browse files
authored
Merge pull request #75154 from swiftlang/elsh/drop-exp-prefix
Drop experimental prefixes from PackageCMO flags.
2 parents e4cd1d7 + f405ad4 commit cb77608

15 files changed

+81
-131
lines changed

include/swift/AST/Decl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
780780
/// Whether this module has been built with C++ interoperability enabled.
781781
HasCxxInteroperability : 1,
782782

783-
/// Whether this module has been built with -experimental-allow-non-resilient-access.
783+
/// Whether this module has been built with -allow-non-resilient-access.
784784
AllowNonResilientAccess : 1,
785785

786-
/// Whether this module has been built with -experimental-package-cmo.
786+
/// Whether this module has been built with -package-cmo.
787787
SerializePackageEnabled : 1
788788
);
789789

include/swift/AST/Module.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ class ModuleDecl
726726
Bits.ModuleDecl.IsBuiltFromInterface = flag;
727727
}
728728

729-
/// Returns true if -experimental-allow-non-resilient-access was passed
729+
/// Returns true if -allow-non-resilient-access was passed
730730
/// and the module is built from source.
731731
bool allowNonResilientAccess() const {
732732
return Bits.ModuleDecl.AllowNonResilientAccess &&
@@ -736,11 +736,12 @@ class ModuleDecl
736736
Bits.ModuleDecl.AllowNonResilientAccess = flag;
737737
}
738738

739-
/// Returns true if -experimental-package-cmo was passed, which
739+
/// Returns true if -package-cmo was passed, which
740740
/// enables serialization of package, public, and inlinable decls in a
741-
/// package. This requires -experimental-allow-non-resilient-access.
741+
/// package. This requires -allow-non-resilient-access.
742742
bool serializePackageEnabled() const {
743-
return Bits.ModuleDecl.SerializePackageEnabled;
743+
return Bits.ModuleDecl.SerializePackageEnabled &&
744+
allowNonResilientAccess();
744745
}
745746
void setSerializePackageEnabled(bool flag = true) {
746747
Bits.ModuleDecl.SerializePackageEnabled = flag;

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@ class SILOptions {
126126
/// Controls whether cross module optimization is enabled.
127127
CrossModuleOptimizationMode CMOMode = CrossModuleOptimizationMode::Off;
128128

129-
/// Optimization to perform default CMO within a package boundary.
130-
/// Unlike the existing CMO, package CMO can be built with
131-
/// -enable-library-evolution since package modules are required
132-
/// to be built in the same project. To enable this optimization, the
133-
/// module also needs to opt in to allow non-resilient access with
134-
/// -experimental-allow-non-resilient-access.
129+
/// Optimization to perform default mode CMO within a package boundary.
130+
/// Package CMO can be performed for resiliently built modules as package
131+
/// modules are required to be built together in the same project. To enable
132+
/// this optimization, the module also needs -allow-non-resilient-access.
135133
bool EnableSerializePackage = false;
136134

137135
/// Enables the emission of stack protectors in functions.

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ namespace swift {
187187
/// Disable API availability checking.
188188
bool DisableAvailabilityChecking = false;
189189

190-
/// Enable optimization to bypass resilience checks in a package
191-
bool EnableBypassResilienceInPackage = false;
192-
193190
/// Optimization mode for unavailable declarations.
194191
std::optional<UnavailableDeclOptimization> UnavailableDeclOptimizationMode;
195192

@@ -583,7 +580,7 @@ namespace swift {
583580
/// Skips decls that cannot be referenced externally.
584581
bool SkipNonExportableDecls = false;
585582

586-
/// True if -experimental-allow-non-resilient-access is passed and built
583+
/// True if -allow-non-resilient-access is passed and built
587584
/// from source.
588585
bool AllowNonResilientAccess = false;
589586

include/swift/Option/Options.td

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,15 @@ def unavailable_decl_optimization_EQ : Joined<["-"], "unavailable-decl-optimizat
519519

520520
def experimental_package_bypass_resilience : Flag<["-"], "experimental-package-bypass-resilience">,
521521
Flags<[FrontendOption]>,
522-
HelpText<"Enable optimization to bypass resilience within a package">;
522+
HelpText<"Deprecated; has no effect">;
523523

524524
def experimental_allow_non_resilient_access : Flag<["-"], "experimental-allow-non-resilient-access">,
525525
Flags<[FrontendOption]>,
526-
HelpText<"Allow non-resilient access by generating all contents besides exportable decls">;
526+
HelpText<"Deprecated; use -allow-non-resilient-access instead">;
527+
528+
def allow_non_resilient_access : Flag<["-"], "allow-non-resilient-access">,
529+
Flags<[FrontendOption]>,
530+
HelpText<"Ensures all contents are generated besides exportable decls in the binary module, so non-resilient access can be allowed">;
527531

528532
def library_level : Separate<["-"], "library-level">,
529533
MetaVarName<"<level>">,
@@ -998,7 +1002,11 @@ def Oplayground : Flag<["-"], "Oplayground">, Group<O_Group>,
9981002

9991003
def ExperimentalPackageCMO : Flag<["-"], "experimental-package-cmo">,
10001004
Flags<[FrontendOption]>,
1001-
HelpText<"Enable optimization to perform default CMO within a package boundary">;
1005+
HelpText<"Deprecated; use -package-cmo instead">;
1006+
1007+
def PackageCMO : Flag<["-"], "package-cmo">,
1008+
Flags<[FrontendOption]>,
1009+
HelpText<"Enable optimization to perform defalut CMO within a package boundary">;
10021010

10031011
def EnbaleDefaultCMO : Flag<["-"], "enable-default-cmo">,
10041012
Flags<[HelpHidden, FrontendOption]>,

lib/AST/Decl.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,23 +4396,14 @@ bool ValueDecl::hasOpenAccess(const DeclContext *useDC) const {
43964396
}
43974397

43984398
bool ValueDecl::bypassResilienceInPackage(ModuleDecl *accessingModule) const {
4399+
// If the defining module is built with package-cmo, bypass
4400+
// resilient access from the use site that belongs to a module
4401+
// in the same package.
43994402
auto declModule = getModuleContext();
4400-
if (declModule->inSamePackage(accessingModule) &&
4401-
declModule->allowNonResilientAccess()) {
4402-
// If the defining module is built with package-cmo,
4403-
// allow direct access from the use site that belongs
4404-
// to accessingModule (client module).
4405-
if (declModule->isResilient() &&
4406-
declModule->serializePackageEnabled())
4407-
return true;
4408-
4409-
// If not, check if the client can still opt in to
4410-
// have a direct access to this decl from the use
4411-
// site with a flag.
4412-
// FIXME: serialize this flag to Module and get it via accessingModule.
4413-
return getASTContext().LangOpts.EnableBypassResilienceInPackage;
4414-
}
4415-
return false;
4403+
return declModule->inSamePackage(accessingModule) &&
4404+
declModule->isResilient() &&
4405+
declModule->allowNonResilientAccess() &&
4406+
declModule->serializePackageEnabled();
44164407
}
44174408

44184409
/// Given the formal access level for using \p VD, compute the scope where

lib/Driver/ToolChains.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
303303
inputArgs.AddLastArg(arguments, options::OPT_suppress_remarks);
304304
inputArgs.AddLastArg(arguments, options::OPT_experimental_package_bypass_resilience);
305305
inputArgs.AddLastArg(arguments, options::OPT_ExperimentalPackageCMO);
306+
inputArgs.AddLastArg(arguments, options::OPT_PackageCMO);
306307
inputArgs.AddLastArg(arguments, options::OPT_profile_generate);
307308
inputArgs.AddLastArg(arguments, options::OPT_profile_use);
308309
inputArgs.AddLastArg(arguments, options::OPT_profile_coverage_mapping);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
786786
Opts.EnablePackageInterfaceLoad = Args.hasArg(OPT_experimental_package_interface_load) ||
787787
::getenv("SWIFT_ENABLE_PACKAGE_INTERFACE_LOAD");
788788

789-
Opts.EnableBypassResilienceInPackage =
790-
Args.hasArg(OPT_experimental_package_bypass_resilience) ||
791-
Opts.hasFeature(Feature::ClientBypassResilientAccessInPackage);
792-
793789
Opts.DisableAvailabilityChecking |=
794790
Args.hasArg(OPT_disable_availability_checking);
795791
if (Args.hasArg(OPT_check_api_availability_only))
@@ -1239,13 +1235,14 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
12391235

12401236
Opts.AllowNonResilientAccess =
12411237
Args.hasArg(OPT_experimental_allow_non_resilient_access) ||
1238+
Args.hasArg(OPT_allow_non_resilient_access) ||
12421239
Opts.hasFeature(Feature::AllowNonResilientAccessInPackage);
12431240
if (Opts.AllowNonResilientAccess) {
12441241
// Override the option to skip non-exportable decls.
12451242
if (Opts.SkipNonExportableDecls) {
12461243
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
12471244
"-experimental-skip-non-exportable-decls",
1248-
"-experimental-allow-non-resilient-access");
1245+
"-allow-non-resilient-access");
12491246
Opts.SkipNonExportableDecls = false;
12501247
}
12511248
// If built from interface, non-resilient access should not be allowed.
@@ -1254,7 +1251,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
12541251
FrontendOpts.RequestedAction)) {
12551252
Diags.diagnose(
12561253
SourceLoc(), diag::warn_ignore_option_overriden_by,
1257-
"-experimental-allow-non-resilient-access",
1254+
"-allow-non-resilient-access",
12581255
"-compile-module-from-interface or -typecheck-module-from-interface");
12591256
Opts.AllowNonResilientAccess = false;
12601257
}
@@ -1671,7 +1668,7 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16711668
if (LangOpts.AllowNonResilientAccess)
16721669
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
16731670
"-experimental-skip-non-inlinable-function-bodies-without-types",
1674-
"-experimental-allow-non-resilient-access");
1671+
"-allow-non-resilient-access");
16751672
else
16761673
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinableWithoutTypes;
16771674
}
@@ -1682,7 +1679,7 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16821679
if (LangOpts.AllowNonResilientAccess)
16831680
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
16841681
"-experimental-skip-non-inlinable-function-bodies",
1685-
"-experimental-allow-non-resilient-access");
1682+
"-allow-non-resilient-access");
16861683
else
16871684
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
16881685
}
@@ -1691,7 +1688,7 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
16911688
if (LangOpts.AllowNonResilientAccess)
16921689
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
16931690
"-tbd-is-installapi",
1694-
"-experimental-allow-non-resilient-access");
1691+
"-allow-non-resilient-access");
16951692
else
16961693
Opts.SkipFunctionBodies = FunctionBodySkipping::NonInlinable;
16971694
}
@@ -1700,7 +1697,7 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
17001697
if (LangOpts.AllowNonResilientAccess)
17011698
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
17021699
"-experimental-skip-all-function-bodies",
1703-
"-experimental-allow-non-resilient-access");
1700+
"-allow-non-resilient-access");
17041701
else
17051702
Opts.SkipFunctionBodies = FunctionBodySkipping::All;
17061703
}
@@ -1774,7 +1771,7 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
17741771
Opts.EnableLazyTypecheck) {
17751772
Diags.diagnose(SourceLoc(), diag::warn_ignore_option_overriden_by,
17761773
"-experimental-lazy-typecheck",
1777-
"-experimental-allow-non-resilient-access");
1774+
"-allow-non-resilient-access");
17781775
Opts.EnableLazyTypecheck = false;
17791776
}
17801777

@@ -2608,11 +2605,12 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
26082605
}
26092606

26102607
if (Args.hasArg(OPT_ExperimentalPackageCMO) ||
2608+
Args.hasArg(OPT_PackageCMO) ||
26112609
LangOpts.hasFeature(Feature::PackageCMO)) {
26122610
if (!LangOpts.AllowNonResilientAccess) {
26132611
Diags.diagnose(SourceLoc(), diag::ignoring_option_requires_option,
2614-
"-experimental-package-cmo",
2615-
"-experimental-allow-non-resilient-access");
2612+
"-package-cmo",
2613+
"-allow-non-resilient-access");
26162614
} else {
26172615
Opts.EnableSerializePackage = true;
26182616
Opts.CMOMode = CrossModuleOptimizationMode::Default;

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ void ModuleFileSharedCore::outputDiagnosticInfo(llvm::raw_ostream &os) const {
703703
<< " against SDK " << SDKVersion
704704
<< ", " << (resilient? "resilient": "non-resilient");
705705
if (Bits.AllowNonResilientAccess)
706-
os << ", built with -experimental-allow-non-resilient-access";
706+
os << ", built with -allow-non-resilient-access";
707707
if (Bits.IsAllowModuleWithCompilerErrorsEnabled)
708708
os << ", built with -experimental-allow-module-with-compiler-errors";
709709
if (ModuleInputBuffer)

lib/Serialization/ModuleFileSharedCore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ class ModuleFileSharedCore {
391391
/// Whether this module is built with C++ interoperability enabled.
392392
unsigned HasCxxInteroperability : 1;
393393

394-
/// Whether this module is built with -experimental-allow-non-resilient-access.
394+
/// Whether this module is built with -allow-non-resilient-access.
395395
unsigned AllowNonResilientAccess : 1;
396396

397-
/// Whether this module is built with -experimental-package-cmo.
397+
/// Whether this module is built with -package-cmo.
398398
unsigned SerializePackageEnabled : 1;
399399

400400
// Explicitly pad out to the next word boundary.

test/IRGen/package_bypass_resilience_class.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@
1010
// RUN: -emit-tbd -emit-tbd-path %t/libCore.tbd \
1111
// RUN: -Xfrontend -tbd-install_name=libCore.dylib -Xfrontend -validate-tbd-against-ir=all
1212

13-
/// Build without -experimental-allow-non-resilient-access
13+
/// Build with -allow-non-resilient-access
14+
// RUN: %target-build-swift %t/Core.swift \
15+
// RUN: -module-name=Core -package-name Pkg \
16+
// RUN: -Xfrontend -allow-non-resilient-access \
17+
// RUN: -enable-library-evolution -O -wmo \
18+
// RUN: -emit-ir -o %t/Core2.ir \
19+
// RUN: -emit-tbd -emit-tbd-path %t/libCore2.tbd \
20+
// RUN: -Xfrontend -tbd-install_name=libCore2.dylib -Xfrontend -validate-tbd-against-ir=all
21+
22+
/// Build without -allow-non-resilient-access
1423
// RUN: %target-build-swift %t/Core.swift \
1524
// RUN: -module-name=Core -package-name Pkg \
1625
// RUN: -enable-library-evolution -O -wmo \
@@ -19,7 +28,9 @@
1928
// RUN: -Xfrontend -tbd-install_name=libCoreRes.dylib -Xfrontend -validate-tbd-against-ir=all
2029

2130
// RUN: %FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-OPT < %t/Core.ir
31+
// RUN: %FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-OPT < %t/Core2.ir
2232
// RUN: %FileCheck %s --check-prefixes=CHECK-TBD-COMMON,CHECK-TBD-OPT < %t/libCore.tbd
33+
// RUN: %FileCheck %s --check-prefixes=CHECK-TBD-COMMON,CHECK-TBD-OPT < %t/libCore2.tbd
2334
// RUN: %FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-RES < %t/CoreRes.ir
2435
// RUN: %FileCheck %s --check-prefixes=CHECK-TBD-COMMON,CHECK-TBD-RES < %t/libCoreRes.tbd
2536

test/IRGen/package_resilience.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
//
2-
// Unlike its counterparts in the other *_resilience.swift files, the goal is
3-
// for the package's component modules to all be considered within the same
4-
// resilience domain. This file ensures that we use direct access to package
5-
// decls at use site as much as possible with -experimental-package-bypass-resilience.
2+
// Tests resilient access is bypassed when package optimization flags are passed.
63
//
7-
84
// RUN: %empty-directory(%t)
95
// RUN: %{python} %utils/chex.py < %s > %t/package_resilience.swift
10-
// RUN: %target-swift-frontend -package-name MyPkg -emit-module -enable-library-evolution -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct -experimental-allow-non-resilient-access %S/Inputs/package_types/resilient_struct.swift
11-
// RUN: %target-swift-frontend -package-name MyPkg -emit-module -enable-library-evolution -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/Inputs/package_types/resilient_enum.swift -experimental-allow-non-resilient-access
12-
// RUN: %target-swift-frontend -package-name MyPkg -emit-module -enable-library-evolution -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class -I %t %S/Inputs/package_types/resilient_class.swift -experimental-allow-non-resilient-access
6+
// RUN: %target-swift-frontend -package-name MyPkg -emit-module -enable-library-evolution -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct -allow-non-resilient-access -package-cmo %S/Inputs/package_types/resilient_struct.swift
7+
// RUN: %target-swift-frontend -package-name MyPkg -emit-module -enable-library-evolution -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/Inputs/package_types/resilient_enum.swift -allow-non-resilient-access -package-cmo
8+
// RUN: %target-swift-frontend -package-name MyPkg -emit-module -enable-library-evolution -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class -I %t %S/Inputs/package_types/resilient_class.swift -allow-non-resilient-access -package-cmo
139

14-
// RUN: %target-swift-frontend -package-name MyPkg -module-name=package_resilience -experimental-package-bypass-resilience -enable-objc-interop -I %t -emit-ir -enable-library-evolution %t/package_resilience.swift | %FileCheck %t/package_resilience.swift --check-prefixes=CHECK,CHECK-objc,CHECK-objc%target-ptrsize,CHECK-%target-ptrsize,CHECK-%target-cpu,CHECK-%target-import-type-objc-STABLE-ABI-%target-mandates-stable-abi,CHECK-%target-sdk-name -DINT=i%target-ptrsize -D#MDWORDS=7 -D#MDSIZE32=52 -D#MDSIZE64=80 -D#WORDSIZE=%target-alignment
10+
// RUN: %target-swift-frontend -package-name MyPkg -module-name=package_resilience -enable-objc-interop -I %t -emit-ir -enable-library-evolution %t/package_resilience.swift | %FileCheck %t/package_resilience.swift --check-prefixes=CHECK,CHECK-objc,CHECK-objc%target-ptrsize,CHECK-%target-ptrsize,CHECK-%target-cpu,CHECK-%target-import-type-objc-STABLE-ABI-%target-mandates-stable-abi,CHECK-%target-sdk-name -DINT=i%target-ptrsize -D#MDWORDS=7 -D#MDSIZE32=52 -D#MDSIZE64=80 -D#WORDSIZE=%target-alignment
1511

16-
// RUN: %target-swift-frontend -package-name MyPkg -module-name=package_resilience -experimental-package-bypass-resilience -disable-objc-interop -I %t -emit-ir -enable-library-evolution %t/package_resilience.swift | %FileCheck %t/package_resilience.swift --check-prefixes=CHECK,CHECK-native,CHECK-native%target-ptrsize,CHECK-%target-ptrsize,CHECK-%target-cpu,CHECK-native-STABLE-ABI-%target-mandates-stable-abi,CHECK-%target-sdk-name -DINT=i%target-ptrsize -D#MDWORDS=4 -D#MDSIZE32=40 -D#MDSIZE64=56 -D#WORDSIZE=%target-alignment
12+
// RUN: %target-swift-frontend -package-name MyPkg -module-name=package_resilience -disable-objc-interop -I %t -emit-ir -enable-library-evolution %t/package_resilience.swift | %FileCheck %t/package_resilience.swift --check-prefixes=CHECK,CHECK-native,CHECK-native%target-ptrsize,CHECK-%target-ptrsize,CHECK-%target-cpu,CHECK-native-STABLE-ABI-%target-mandates-stable-abi,CHECK-%target-sdk-name -DINT=i%target-ptrsize -D#MDWORDS=4 -D#MDSIZE32=40 -D#MDSIZE64=56 -D#WORDSIZE=%target-alignment
1713

1814
// RUN: %target-swift-frontend -package-name MyPkg -module-name=package_resilience -experimental-package-bypass-resilience -I %t -emit-ir -enable-library-evolution -O %t/package_resilience.swift -package-name MyPkg
1915

0 commit comments

Comments
 (0)