DebugInfo: Emit only the declaration of a class template that has an explicit instantiation declaration (& always emit such a type when there's an explicit instantiation definition)

We should only have this optimization fire when the explicit
instantiation definition would cause at  least one member function to be
emitted, thus ensuring that even a compiler not performing this
optimization would still emit the full type information elsewhere.

But we should also pessimize output still by always emitting the
definition when the explicit instantiation definition appears so that at
some point in the future we can depend on that information even when no
code had to be emitted in that TU. (this shouldn't happen very often,
since people mostly use explicit spec decl/defs to reduce code size -
but perhaps one day they could use it to explicitly reduce debug info
size too)

This was worth about 2% for Clang and LLVM - so not a huge win, but a
win. It looks really great for simple STL programs (include <string> and
just declare a string - 14k -> 1.4k of .dwo)

llvm-svn: 202769
This commit is contained in:
David Blaikie
2014-03-03 23:48:23 +00:00
parent fe45290566
commit 0e716b42f4
4 changed files with 134 additions and 19 deletions

View File

@@ -3000,7 +3000,15 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
ImportedModules.insert(Import->getImportedModule());
break;
}
}
case Decl::ClassTemplateSpecialization: {
const ClassTemplateSpecializationDecl *Spec =
cast<ClassTemplateSpecializationDecl>(D);
if (DebugInfo &&
Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition)
DebugInfo->completeTemplateDefinition(*Spec);
}
default:
// Make sure we handled everything we should, every other kind is a