From 8e79b8491f4609f3fb08c41befbf17201efc4726 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 6 Mar 2009 16:20:49 +0000 Subject: IRgen support for weak_import. - clang should support weak_import llvm-svn: 66270 --- clang/lib/CodeGen/CodeGenModule.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3f930feaaa08..953413d82476 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -263,8 +263,12 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, } else GV->setLinkage(llvm::Function::DLLImportLinkage); } - } else if (D->getAttr()) + } else if (D->getAttr() || + D->getAttr()) { + // "extern_weak" is overloaded in LLVM; we probably should have + // separate linkage types for this. GV->setLinkage(llvm::Function::ExternalWeakLinkage); + } } else { if (IsInternal) { GV->setLinkage(llvm::Function::InternalLinkage); @@ -276,7 +280,8 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, GV->setLinkage(llvm::Function::DLLExportLinkage); } else GV->setLinkage(llvm::Function::DLLExportLinkage); - } else if (D->getAttr() || IsInline) + } else if (D->getAttr() || D->getAttr() || + IsInline) GV->setLinkage(llvm::Function::WeakLinkage); } } @@ -602,7 +607,7 @@ void CodeGenModule::EmitGlobalDefinition(const ValueDecl *D) { if (D->getStorageClass() == VarDecl::PrivateExtern) setGlobalVisibility(GV, VisibilityAttr::HiddenVisibility); - if (D->getAttr()) + if (D->getAttr() || D->getAttr()) GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); if (const AsmLabelAttr *ALA = D->getAttr()) { @@ -737,7 +742,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { GV->setLinkage(llvm::Function::DLLImportLinkage); else if (D->getAttr()) GV->setLinkage(llvm::Function::DLLExportLinkage); - else if (D->getAttr()) + else if (D->getAttr() || D->getAttr()) GV->setLinkage(llvm::GlobalVariable::WeakLinkage); else { // FIXME: This isn't right. This should handle common linkage and other -- cgit v1.2.3