Skip to content

Commit 8c9f0f5

Browse files
authored
Merge pull request swiftlang#41157 from eeckstein/cmo-fixes
Two fixes related to cross-module-optimization
2 parents 9134725 + 5bc1633 commit 8c9f0f5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,16 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
20742074
// from a fragile function is an error.
20752075
if (F.isSerialized()) {
20762076
require((SingleFunction && RefF->isExternalDeclaration()) ||
2077-
RefF->hasValidLinkageForFragileRef(),
2077+
RefF->hasValidLinkageForFragileRef() ||
2078+
2079+
// A serialized specialized function can reference another
2080+
// specialized function. In case the other specialization is already
2081+
// generated by the optimizer before the de-serialization point,
2082+
// we can end up that a shared_external function references a
2083+
// shared function. This is okay.
2084+
(F.getLinkage() == SILLinkage::SharedExternal &&
2085+
RefF->getLinkage() == SILLinkage::Shared),
2086+
20782087
"function_ref inside fragile function cannot "
20792088
"reference a private or hidden symbol");
20802089
}

lib/SILOptimizer/IPO/CrossModuleOptimization.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ void CrossModuleOptimization::makeDeclUsableFromInline(ValueDecl *decl) {
511511
if (decl->getEffectiveAccess() >= AccessLevel::Public)
512512
return;
513513

514+
// We must not modify decls which are defined in other modules.
515+
if (M.getSwiftModule() != decl->getDeclContext()->getParentModule())
516+
return;
517+
514518
if (decl->getFormalAccess() < AccessLevel::Public &&
515519
!decl->isUsableFromInline()) {
516520
// Mark the nominal type as "usableFromInline".

0 commit comments

Comments
 (0)