From eda9a5ec380f172f4e0063744eb796144a125480 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 21 Feb 2009 00:24:10 +0000 Subject: Emit extern_weak when needed. - PR3629. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65203 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 7432b01e25..ccba324aa0 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -264,7 +264,8 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, } else GV->setLinkage(llvm::Function::DLLImportLinkage); } - } + } else if (D->getAttr()) + GV->setLinkage(llvm::Function::ExternalWeakLinkage); } else { if (IsInternal) { GV->setLinkage(llvm::Function::InternalLinkage); @@ -287,11 +288,10 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D, setGlobalVisibility(GV, attr->getVisibility()); // FIXME: else handle -fvisibility - if (const AsmLabelAttr *ALA = D->getAttr()) { - // Prefaced with special LLVM marker to indicate that the name - // should not be munged. + // Prefaced with special LLVM marker to indicate that the name + // should not be munged. + if (const AsmLabelAttr *ALA = D->getAttr()) GV->setName("\01" + ALA->getLabel()); - } if (const SectionAttr *SA = D->getAttr()) GV->setSection(SA->getName()); @@ -598,8 +598,13 @@ void CodeGenModule::EmitGlobalDefinition(const ValueDecl *D) { GV->setConstant(D->getType().isConstant(Context)); + // FIXME: Merge with other attribute handling code. + if (D->getStorageClass() == VarDecl::PrivateExtern) setGlobalVisibility(GV, VisibilityAttr::HiddenVisibility); + + if (D->getAttr()) + GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); } // Make sure the result is of the correct type. -- cgit v1.2.3-18-g5258