diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2012-10-16 17:45:27 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2012-10-16 17:45:27 +0000 |
commit | 4695f91f4302a90ae462cd64dda59b34c3dad821 (patch) | |
tree | 66649fe07335fd10f213614c983a10aee2f804d2 /lib/CodeGen | |
parent | 1c9a2daf902aacb1a606497a7d09a7c2c29957ed (diff) |
When using a symbol with attribute weakref, search for it first and
don't try the normal GetOrCreateLLVM. The latter could drop the weak
atrtibute on the second reference, if there is no explicit declaration
of the aliasee.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166032 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 6be225c6b5..3353612c90 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -884,6 +884,10 @@ llvm::Constant *CodeGenModule::GetWeakRefReference(const ValueDecl *VD) { // See if there is already something with the target's name in the module. llvm::GlobalValue *Entry = GetGlobalValue(AA->getAliasee()); + if (Entry) { + unsigned AS = getContext().getTargetAddressSpace(VD->getType()); + return llvm::ConstantExpr::getBitCast(Entry, DeclTy->getPointerTo(AS)); + } llvm::Constant *Aliasee; if (isa<llvm::FunctionType>(DeclTy)) @@ -893,11 +897,10 @@ llvm::Constant *CodeGenModule::GetWeakRefReference(const ValueDecl *VD) { else Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), llvm::PointerType::getUnqual(DeclTy), 0); - if (!Entry) { - llvm::GlobalValue* F = cast<llvm::GlobalValue>(Aliasee); - F->setLinkage(llvm::Function::ExternalWeakLinkage); - WeakRefReferences.insert(F); - } + + llvm::GlobalValue* F = cast<llvm::GlobalValue>(Aliasee); + F->setLinkage(llvm::Function::ExternalWeakLinkage); + WeakRefReferences.insert(F); return Aliasee; } |