Skip to content

Commit 7c7a2de

Browse files
authored
Merge pull request #72344 from apple/elsh/pkg-cmo-flag-false
Set EnableSerializePackage to false.
2 parents 4fb2c59 + 6fc9098 commit 7c7a2de

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
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/SIL/SILLinkage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ inline bool hasPublicVisibility(SILLinkage linkage) {
289289
llvm_unreachable("Unhandled SILLinkage in switch.");
290290
}
291291

292+
/// Opt in package linkage for visibility in case Package CMO is enabled.
293+
/// Used in SIL verification and other checks that determine inlinability to
294+
/// accomodate for the optimization.
292295
inline bool hasPublicOrPackageVisibility(SILLinkage linkage, bool includePackage) {
293296
switch (linkage) {
294297
case SILLinkage::Public:

lib/SIL/IR/SILFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,9 @@ bool SILFunction::hasValidLinkageForFragileRef() const {
899899
return false;
900900

901901
// Otherwise, only public or package functions can be referenced.
902-
return hasPublicOrPackageVisibility(getLinkage(), getModule().getOptions().EnableSerializePackage);
902+
// If it has a package linkage at this point, package CMO must
903+
// have been enabled, so opt in for visibility.
904+
return hasPublicOrPackageVisibility(getLinkage(), /*includePackage*/ true);
903905
}
904906

905907
bool

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,8 +2418,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
24182418
"cannot access storage of resilient global");
24192419
}
24202420
if (F.isSerialized()) {
2421+
// If it has a package linkage at this point, package CMO must
2422+
// have been enabled, so opt in for visibility.
24212423
require(RefG->isSerialized()
2422-
|| hasPublicOrPackageVisibility(RefG->getLinkage(), F.getModule().getOptions().EnableSerializePackage),
2424+
|| hasPublicOrPackageVisibility(RefG->getLinkage(), /*includePackage*/ true),
24232425
"alloc_global inside fragile function cannot "
24242426
"reference a private or hidden symbol");
24252427
}
@@ -2437,8 +2439,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
24372439
"cannot access storage of resilient global");
24382440
}
24392441
if (F.isSerialized()) {
2442+
// If it has a package linkage at this point, package CMO must
2443+
// have been enabled, so opt in for visibility.
24402444
require(RefG->isSerialized()
2441-
|| hasPublicOrPackageVisibility(RefG->getLinkage(), F.getModule().getOptions().EnableSerializePackage),
2445+
|| hasPublicOrPackageVisibility(RefG->getLinkage(), /*includePackage*/ true),
24422446
"global_addr/value inside fragile function cannot "
24432447
"reference a private or hidden symbol");
24442448
}

0 commit comments

Comments
 (0)