summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2012-10-16 17:45:27 +0000
committerJoerg Sonnenberger <joerg@bec.de>2012-10-16 17:45:27 +0000
commitde78bba047b76d040fdbf1ef0ab2ebd3891f9675 (patch)
treea9a6076dc1afd2c4bd6f71eb1b1387f3df9fef6b /clang/lib/CodeGen/CodeGenModule.cpp
parent544284eb31e2bceb619da63002da927c3dde3b98 (diff)
downloadbcm5719-llvm-de78bba047b76d040fdbf1ef0ab2ebd3891f9675.tar.gz
bcm5719-llvm-de78bba047b76d040fdbf1ef0ab2ebd3891f9675.zip
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. llvm-svn: 166032
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 6be225c6b52..3353612c905 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud