aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGVTables.cpp
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
commit3d640e606165daf2eaf18d52c0697f68daec106a (patch)
tree18ecf011d07fa3119666f94012814d1a999ca880 /lib/CodeGen/CGVTables.cpp
parente3273e78da4716f9c999ae207f6898f376a6e1a4 (diff)
Emit weak vtables of non-template classes with hidden visibility.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVTables.cpp')
-rw-r--r--lib/CodeGen/CGVTables.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index f597a1338c..052a6fdca3 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/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 *