From b1465ae7e3453a98cb167f4388e704eb5f13b165 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Wed, 12 Jun 2013 18:07:07 +0200 Subject: [PATCH] Extended DtoLinkage comments. --- gen/tollvm.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 54fe029b..cae8f2ea 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -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)