summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-08-03 07:24:12 +0000
committerJohn McCall <rjmccall@apple.com>2010-08-03 07:24:12 +0000
commit5696d6d316ed7a66aa405450b7991a8eee8937b8 (patch)
tree951fc7cbac949009c4c4b76d079395e16df96f50 /clang/lib
parent42b8c30de6c36b415d3ae7b6f962d3e84c936882 (diff)
downloadbcm5719-llvm-5696d6d316ed7a66aa405450b7991a8eee8937b8.tar.gz
bcm5719-llvm-5696d6d316ed7a66aa405450b7991a8eee8937b8.zip
Emit weak vtables of non-template classes with hidden visibility.
llvm-svn: 110107
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index f597a1338cd..052a6fdca36 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -2926,6 +2926,22 @@ CodeGenVTables::EmitVTableDefinition(llvm::GlobalVariable *VTable,
// Set the right visibility.
CGM.setGlobalVisibility(VTable, RD);
+
+ // It's okay to have multiple copies of a vtable, so don't make the
+ // dynamic linker unique them. Suppress this optimization if it's
+ // possible that there might be unresolved references elsewhere,
+ // which can happen if
+ // - there's a key function and the vtable is getting emitted weak
+ // anyway for whatever reason
+ // - there might be an explicit instantiation declaration somewhere,
+ // i.e. if it's a template at all
+ if (Linkage == llvm::GlobalVariable::WeakODRLinkage &&
+ VTable->getVisibility() == llvm::GlobalVariable::DefaultVisibility &&
+ !RD->hasAttr<VisibilityAttr>() &&
+ RD->getTemplateSpecializationKind() == TSK_Undeclared &&
+ !CGM.Context.getKeyFunction(RD)) {
+ VTable->setVisibility(llvm::GlobalVariable::HiddenVisibility);
+ }
}
llvm::GlobalVariable *
OpenPOWER on IntegriCloud