v.g.vassilev created this revision. Currently, we load all template specialization if we have more than one module attached and we touch anything around the template definition.
This patch registers the template specializations as a lazily-loadable entities. This reduces the amount of deserializations by 1%. Repository: rL LLVM https://reviews.llvm.org/D29951 Files: lib/Serialization/ASTReaderDecl.cpp Index: lib/Serialization/ASTReaderDecl.cpp =================================================================== --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -3788,9 +3788,31 @@ break; } - case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: - // It will be added to the template's specializations set when loaded. - (void)Record.readDecl(); + case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: { + // It will be added to the template's lazy specialization set when loaded. + // FIXME: reduce the copy paste. + SmallVector<serialization::DeclID, 1> SpecID; + if (auto *CTD = dyn_cast<ClassTemplateDecl>(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = CTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = FTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else if (auto *VTD = dyn_cast<VarTemplateDecl>(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = VTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else // TypeAliasTemplateDecl + assert(0 && "TypeAliasTemplateDecl doesn't have specs!"); + } break; case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
Index: lib/Serialization/ASTReaderDecl.cpp =================================================================== --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -3788,9 +3788,31 @@ break; } - case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: - // It will be added to the template's specializations set when loaded. - (void)Record.readDecl(); + case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: { + // It will be added to the template's lazy specialization set when loaded. + // FIXME: reduce the copy paste. + SmallVector<serialization::DeclID, 1> SpecID; + if (auto *CTD = dyn_cast<ClassTemplateDecl>(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = CTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = FTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else if (auto *VTD = dyn_cast<VarTemplateDecl>(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = VTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else // TypeAliasTemplateDecl + assert(0 && "TypeAliasTemplateDecl doesn't have specs!"); + } break; case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits