SIL: Introduce '@_alwaysEmitIntoClient' attribute for use by standard library

This is like '@inlinable', except that the symbol does not have a public
entry point in the generated binary at all; it is deserialized and a copy
is always emitted into the client binary, with shared linkage.

Just like '@inlinable', if you apply this to an internal declaration it
becomes '@usableFromInline' automatically.

This uses the same mechanism as default arguments ever since Swift 4, so
it should work reasonably well, but there are rough edges with diagnostics
and such. Don't use this if you are not the standard library.

Fixes <rdar://problem/33767512>, <https://bugs.swift.org/browse/SR-5646>.
This commit is contained in:
Slava Pestov
2019-02-15 20:41:59 -05:00
parent c2f8622aa8
commit bd6490b391
13 changed files with 79 additions and 11 deletions

View File

@@ -2518,12 +2518,14 @@ bool ValueDecl::isUsableFromInline() const {
assert(getFormalAccess() == AccessLevel::Internal);
if (getAttrs().hasAttribute<UsableFromInlineAttr>() ||
getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>() ||
getAttrs().hasAttribute<InlinableAttr>())
return true;
if (auto *accessor = dyn_cast<AccessorDecl>(this)) {
auto *storage = accessor->getStorage();
if (storage->getAttrs().hasAttribute<UsableFromInlineAttr>() ||
storage->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>() ||
storage->getAttrs().hasAttribute<InlinableAttr>())
return true;
}