[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 19 14:55:05 PST 2017


v.g.vassilev created this revision.
v.g.vassilev added reviewers: rsmith, bruno.

Currently, we load all lazy template specializations when we search whether there is a suitable template specialization for a template. This is especially suboptimal with modules. If module `B` specializes a template from module `A` the ASTReader would only read the specialization DeclID. This is observed to be especially pathological when module `B` is stl. However, the template instantiator (almost immediately after) will call `findSpecialization`. In turn, findSpecialization will load all lazy specializations to give an answer.

This patch teaches `findSpecialization` to work with lazy specializations without having to deserialize their full content. It provides along with the DeclID an cross-TU stable ODRHash of the template arguments which is enough to decide if we have already specialization and which are the exact ones (we load all decls with the same hash to avoid potential collisions) to deserialize.

While we make finding a template specialization more memory-efficient we are far from being done. There are still a few places which trigger eager deserialization of template specializations: the places where we require completion of the redeclaration chain.


Repository:
  rC Clang

https://reviews.llvm.org/D41416

Files:
  include/clang/AST/DeclTemplate.h
  lib/AST/DeclTemplate.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41416.127604.patch
Type: text/x-patch
Size: 18363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171219/7217a02a/attachment-0001.bin>


More information about the cfe-commits mailing list