diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-05 19:06:31 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-05 19:06:31 +0000 |
commit | bd6d6197fcfc98356ea60e816365eb0648b69556 (patch) | |
tree | f917c297d0e6751c05d05a7bd4fca29581c99673 /lib/CodeGen/CGVtable.cpp | |
parent | ef372018c2dc0f8c2e5c34698401b87077eef6ed (diff) |
Improve key-function computation for templates. In particular:
- All classes can have a key function; templates don't change that.
non-template classes when computing the key function.
- We always mark all of the virtual member functions of class
template instantiations.
- The vtable for an instantiation of a class template has weak
linkage.
We could probably use available_externally linkage for vtables of
classes instantiated by explicit instantiation declarations (extern
templates), but GCC doesn't do this and I'm not 100% that the ABI
permits it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92753 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVtable.cpp')
-rw-r--r-- | lib/CodeGen/CGVtable.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index ba5a0c3543..ca148da956 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -1493,8 +1493,22 @@ void CGVtableInfo::MaybeEmitVtable(GlobalDecl GD) { llvm::GlobalVariable::LinkageTypes Linkage; if (RD->isInAnonymousNamespace() || !RD->hasLinkage()) Linkage = llvm::GlobalVariable::InternalLinkage; - else if (KeyFunction && !MD->isInlined()) - Linkage = llvm::GlobalVariable::ExternalLinkage; + else if (KeyFunction && !MD->isInlined()) { + switch (MD->getTemplateSpecializationKind()) { + case TSK_Undeclared: + case TSK_ExplicitSpecialization: + Linkage = llvm::GlobalVariable::ExternalLinkage; + break; + + case TSK_ImplicitInstantiation: + case TSK_ExplicitInstantiationDeclaration: + // FIXME: could an explicit instantiation declaration imply + // available_externally linkage? + case TSK_ExplicitInstantiationDefinition: + Linkage = llvm::GlobalVariable::WeakODRLinkage; + break; + } + } else Linkage = llvm::GlobalVariable::WeakODRLinkage; |