Extended DtoLinkage comments.

This commit is contained in:
David Nadlinger
2013-06-12 18:07:07 +02:00
parent d3f89f81a8
commit b1465ae7e3

View File

@@ -342,20 +342,28 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
// intrinsics are always external
if (fdecl->llvmInternal == LLVMintrinsic)
return llvm::GlobalValue::ExternalLinkage;
// generated by inlining semantics run
// Mark functions generated by an inlining semantic run as
// available_externally. Naked functions are turned into module-level
// inline asm and are thus declaration-only as far as the LLVM IR level
// is concerned.
if (fdecl->availableExternally && mustDefine && !fdecl->naked)
return llvm::GlobalValue::AvailableExternallyLinkage;
// array operations are always template linkage
if (fdecl->isArrayOp == 1)
return templateLinkage;
// template instances should have weak linkage
// but only if there's a body, and it's not naked
// otherwise we make it external
else if (needsTemplateLinkage(fdecl) && fdecl->fbody && !fdecl->naked)
if (needsTemplateLinkage(fdecl) && fdecl->fbody && !fdecl->naked)
return templateLinkage;
// extern(C) functions are always external
else if (ft->linkage == LINKc)
if (ft->linkage == LINKc)
return llvm::GlobalValue::ExternalLinkage;
// If a function without a body is nested in another
// function, we cannot use internal linkage for that
// function (see below about nested functions)