Add @_neverEmitIntoClient to prohibit SIL serialization for a function

Part of the Embedded Swift linkage model, this attribute ensures that
the function it applies to has a strong definition in its owning
module, and that its SIL is never serialized. That way, other modules
will not have access to its definition.

Implements rdar://158364184.
This commit is contained in:
Doug Gregor
2025-08-17 23:21:57 -07:00
parent 9a20ebac5b
commit 2f60d729f0
10 changed files with 118 additions and 1 deletions

View File

@@ -1068,6 +1068,14 @@ public:
/// behaviors for it and, if it's an extension, its members.
bool isObjCImplementation() const;
/// True if this declaration should never have its implementation made
/// available to any client. This overrides cross-module optimization and
/// optimizations that might use the implementation, such that the only
/// implementation of this function is the one compiled into its owning
/// module. Practically speaking, this prohibits serialization of the SIL
/// for this definition.
bool isNeverEmittedIntoClient() const;
using AuxiliaryDeclCallback = llvm::function_ref<void(Decl *)>;
/// Iterate over the auxiliary declarations for this declaration,

View File

@@ -201,7 +201,11 @@ SIMPLE_DECL_ATTR(requires_stored_property_inits, RequiresStoredPropertyInits,
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove | UnreachableInABIAttr,
27)
// Unused '28'
SIMPLE_DECL_ATTR(_neverEmitIntoClient, NeverEmitIntoClient,
OnVar | OnSubscript | OnAbstractFunction,
UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove | ForbiddenInABIAttr,
28)
// Unused '29'
SIMPLE_DECL_ATTR(nonobjc, NonObjC,