mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: Only give closures shared linkage if they're going to be serialized
Otherwise, we don't want them to be linkonce_odr at the LLVM level to avoid unnecessary link-time overhead.
This commit is contained in:
@@ -415,19 +415,23 @@ bool SILDeclRef::isImplicit() const {
|
||||
}
|
||||
|
||||
SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
|
||||
// Anonymous functions have shared linkage.
|
||||
// FIXME: This should really be the linkage of the parent function.
|
||||
if (getAbstractClosureExpr())
|
||||
return SILLinkage::Shared;
|
||||
|
||||
if (auto *ace = getAbstractClosureExpr()) {
|
||||
if (isSerialized())
|
||||
return SILLinkage::Shared;
|
||||
return SILLinkage::Private;
|
||||
}
|
||||
|
||||
// Native function-local declarations have shared linkage.
|
||||
// FIXME: @objc declarations should be too, but we currently have no way
|
||||
// of marking them "used" other than making them external.
|
||||
ValueDecl *d = getDecl();
|
||||
DeclContext *moduleContext = d->getDeclContext();
|
||||
while (!moduleContext->isModuleScopeContext()) {
|
||||
if (!isForeign && moduleContext->isLocalContext())
|
||||
return SILLinkage::Shared;
|
||||
if (!isForeign && moduleContext->isLocalContext()) {
|
||||
if (isSerialized())
|
||||
return SILLinkage::Shared;
|
||||
return SILLinkage::Private;
|
||||
}
|
||||
moduleContext = moduleContext->getParent();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user