mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SIL] Make @_silgen_name and @_cdecl functions immune to some optimizations (#12696)
@_silgen_name and @_cdecl functions are assumed to be referenced from C code. Public and internal functions marked as such must not be deleted by the optimizer, and their C symbols must be public or hidden respectively. rdar://33924873, SR-6209
This commit is contained in:
@@ -96,7 +96,8 @@ SILFunction::SILFunction(SILModule &Module, SILLinkage Linkage, StringRef Name,
|
||||
Serialized(isSerialized), Thunk(isThunk),
|
||||
ClassSubclassScope(unsigned(classSubclassScope)), GlobalInitFlag(false),
|
||||
InlineStrategy(inlineStrategy), Linkage(unsigned(Linkage)),
|
||||
KeepAsPublic(false), EffectsKindAttr(E), EntryCount(entryCount) {
|
||||
HasCReferences(false), KeepAsPublic(false), EffectsKindAttr(E),
|
||||
EntryCount(entryCount) {
|
||||
if (InsertBefore)
|
||||
Module.functions.insert(SILModule::iterator(InsertBefore), this);
|
||||
else
|
||||
@@ -445,13 +446,15 @@ bool SILFunction::hasValidLinkageForFragileRef() const {
|
||||
return hasPublicVisibility(getLinkage());
|
||||
}
|
||||
|
||||
/// Helper method which returns true if the linkage of the SILFunction
|
||||
/// indicates that the objects definition might be required outside the
|
||||
/// current SILModule.
|
||||
bool
|
||||
SILFunction::isPossiblyUsedExternally() const {
|
||||
return swift::isPossiblyUsedExternally(getLinkage(),
|
||||
getModule().isWholeModule());
|
||||
auto linkage = getLinkage();
|
||||
|
||||
// Hidden functions may be referenced by other C code in the linkage unit.
|
||||
if (linkage == SILLinkage::Hidden && hasCReferences())
|
||||
return true;
|
||||
|
||||
return swift::isPossiblyUsedExternally(linkage, getModule().isWholeModule());
|
||||
}
|
||||
|
||||
bool SILFunction::isExternallyUsedSymbol() const {
|
||||
|
||||
Reference in New Issue
Block a user