Skip to content

Commit 47bc712

Browse files
committed
[SIL linker] Ensure that we only link the foreign entrypoint when that's all there is
1 parent ce02872 commit 47bc712

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/SILOptimizer/UtilityPasses/Link.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ linkEmbeddedRuntimeFunctionByName(#NAME, EFFECT, StringRef(#CC) == "C_CC"); \
206206
}
207207

208208
for (auto *F : Functions) {
209-
auto declRef = SILDeclRef(F, SILDeclRef::Kind::Func);
209+
auto declRef = SILDeclRef(F, SILDeclRef::Kind::Func,
210+
F->hasOnlyCEntryPoint());
210211
auto *Fn = linkUsedFunctionByName(declRef.mangle(), /*Linkage*/{},
211212
/*byAsmName=*/false);
212213

213214
// If we have @_cdecl or @_silgen_name, also link the foreign thunk
214-
if (Fn->hasCReferences()) {
215+
if (Fn->hasCReferences() && !F->hasOnlyCEntryPoint()) {
215216
auto declRef = SILDeclRef(F, SILDeclRef::Kind::Func, /*isForeign*/true);
216217
linkUsedFunctionByName(declRef.mangle(), /*Linkage*/{},
217218
/*byAsmName=*/false);

0 commit comments

Comments
 (0)