mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85908 from drexin/wip-163631865
[IRGen] Use proper linkage for async function pointers to partial app…
This commit is contained in:
@@ -1863,6 +1863,15 @@ public:
|
||||
|
||||
bool isAlwaysSharedLinkage() const;
|
||||
|
||||
/// Partial apply forwarders always need real private linkage,
|
||||
/// to ensure the correct implementation is used in case of
|
||||
/// colliding symbols.
|
||||
bool privateMeansPrivate() const {
|
||||
return getKind() == Kind::PartialApplyForwarder ||
|
||||
getKind() == Kind::PartialApplyForwarderAsyncFunctionPointer ||
|
||||
getKind() == Kind::PartialApplyForwarderCoroFunctionPointer;
|
||||
}
|
||||
|
||||
/// Whether the link entity's definitions must be considered non-unique.
|
||||
///
|
||||
/// This applies only in the Embedded Swift linkage model, and is used for
|
||||
|
||||
@@ -2326,11 +2326,11 @@ void IRGenerator::emitEntryPointInfo() {
|
||||
IGM.addUsedGlobal(var);
|
||||
}
|
||||
|
||||
static IRLinkage
|
||||
getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
|
||||
SILLinkage linkage, ForDefinition_t isDefinition,
|
||||
bool isWeakImported, bool isKnownLocal,
|
||||
bool hasNonUniqueDefinition) {
|
||||
static IRLinkage getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
|
||||
SILLinkage linkage, ForDefinition_t isDefinition,
|
||||
bool isWeakImported, bool isKnownLocal,
|
||||
bool hasNonUniqueDefinition,
|
||||
bool privateMeansPrivate) {
|
||||
#define RESULT(LINKAGE, VISIBILITY, DLL_STORAGE) \
|
||||
IRLinkage{llvm::GlobalValue::LINKAGE##Linkage, \
|
||||
llvm::GlobalValue::VISIBILITY##Visibility, \
|
||||
@@ -2392,12 +2392,15 @@ getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
|
||||
case SILLinkage::Private: {
|
||||
if (info.forcePublicDecls() && !isDefinition)
|
||||
return getIRLinkage(name, info, SILLinkage::PublicExternal, isDefinition,
|
||||
isWeakImported, isKnownLocal, hasNonUniqueDefinition);
|
||||
isWeakImported, isKnownLocal, hasNonUniqueDefinition,
|
||||
privateMeansPrivate);
|
||||
|
||||
auto linkage = info.needLinkerToMergeDuplicateSymbols()
|
||||
? llvm::GlobalValue::LinkOnceODRLinkage
|
||||
: llvm::GlobalValue::InternalLinkage;
|
||||
auto visibility = info.shouldAllPrivateDeclsBeVisibleFromOtherFiles()
|
||||
auto linkage =
|
||||
info.needLinkerToMergeDuplicateSymbols() && !privateMeansPrivate
|
||||
? llvm::GlobalValue::LinkOnceODRLinkage
|
||||
: llvm::GlobalValue::InternalLinkage;
|
||||
auto visibility = info.shouldAllPrivateDeclsBeVisibleFromOtherFiles() &&
|
||||
!privateMeansPrivate
|
||||
? llvm::GlobalValue::HiddenVisibility
|
||||
: llvm::GlobalValue::DefaultVisibility;
|
||||
return {linkage, visibility, llvm::GlobalValue::DefaultStorageClass};
|
||||
@@ -2448,8 +2451,8 @@ void irgen::updateLinkageForDefinition(IRGenModule &IGM,
|
||||
auto IRL =
|
||||
getIRLinkage(global->hasName() ? global->getName() : StringRef(),
|
||||
linkInfo, entity.getLinkage(ForDefinition), ForDefinition,
|
||||
weakImported, isKnownLocal,
|
||||
entity.hasNonUniqueDefinition());
|
||||
weakImported, isKnownLocal, entity.hasNonUniqueDefinition(),
|
||||
entity.privateMeansPrivate());
|
||||
ApplyIRLinkage(IRL).to(global);
|
||||
|
||||
LinkInfo link = LinkInfo::get(IGM, entity, ForDefinition);
|
||||
@@ -2500,10 +2503,10 @@ LinkInfo LinkInfo::get(const UniversalLinkageInfo &linkInfo,
|
||||
}
|
||||
|
||||
bool weakImported = entity.isWeakImported(swiftModule);
|
||||
result.IRL = getIRLinkage(result.Name, linkInfo,
|
||||
entity.getLinkage(isDefinition), isDefinition,
|
||||
weakImported, isKnownLocal,
|
||||
entity.hasNonUniqueDefinition());
|
||||
result.IRL = getIRLinkage(
|
||||
result.Name, linkInfo, entity.getLinkage(isDefinition), isDefinition,
|
||||
weakImported, isKnownLocal, entity.hasNonUniqueDefinition(),
|
||||
entity.privateMeansPrivate());
|
||||
result.ForDefinition = isDefinition;
|
||||
return result;
|
||||
}
|
||||
@@ -2515,7 +2518,8 @@ LinkInfo LinkInfo::get(const UniversalLinkageInfo &linkInfo, StringRef name,
|
||||
result.Name += name;
|
||||
result.IRL = getIRLinkage(name, linkInfo, linkage, isDefinition,
|
||||
isWeakImported, linkInfo.Internalize,
|
||||
/*hasNonUniqueDefinition=*/false);
|
||||
/*hasNonUniqueDefinition=*/false,
|
||||
/*privateMeansPrivate=*/false);
|
||||
result.ForDefinition = isDefinition;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,11 @@ entry(%e : $EmptyType, %b : $WeakBox<τ_0_0>):
|
||||
unreachable
|
||||
}
|
||||
|
||||
// CHECK-DAG: @"$s7takingQTATu" = internal
|
||||
// CHECK-DAG: @"$s11takingQAndSTATu" = internal
|
||||
// CHECK-DAG: @"$s13inner_closureTATu" = internal
|
||||
// CHECK-DAG: @"$s15returns_closureTATu" = internal
|
||||
|
||||
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swift{{(tail)?}}cc void @bind_polymorphic_param_from_context(
|
||||
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @"$s7takingQTA"(
|
||||
sil public @bind_polymorphic_param_from_context : $@async @convention(thin) <τ_0_1>(@in τ_0_1) -> @owned @async @callee_guaranteed () -> () {
|
||||
|
||||
Reference in New Issue
Block a user