[all-commits] [llvm/llvm-project] a45f71: add option to instantiate templates already in the...

Luboš Luňák via All-commits all-commits at lists.llvm.org
Sun Jun 21 08:06:19 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a45f713c673001abb4fe0612b909c698073eb356
      https://github.com/llvm/llvm-project/commit/a45f713c673001abb4fe0612b909c698073eb356
  Author: Luboš Luňák <l.lunak at centrum.cz>
  Date:   2020-06-21 (Sun, 21 Jun 2020)

  Changed paths:
    M clang/include/clang/Basic/LangOptions.def
    M clang/include/clang/Driver/Options.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/test/PCH/crash-12631281.cpp
    M clang/test/PCH/cxx-alias-decl.cpp
    M clang/test/PCH/cxx-dependent-sized-ext-vector.cpp
    M clang/test/PCH/cxx-explicit-specifier.cpp
    M clang/test/PCH/cxx-exprs.cpp
    M clang/test/PCH/cxx-friends.cpp
    M clang/test/PCH/cxx-member-init.cpp
    M clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp
    M clang/test/PCH/cxx-static_assert.cpp
    M clang/test/PCH/cxx-templates.cpp
    M clang/test/PCH/cxx-variadic-templates-with-default-params.cpp
    M clang/test/PCH/cxx-variadic-templates.cpp
    M clang/test/PCH/cxx0x-default-delete.cpp
    M clang/test/PCH/cxx11-constexpr.cpp
    M clang/test/PCH/cxx11-enum-template.cpp
    M clang/test/PCH/cxx11-exception-spec.cpp
    M clang/test/PCH/cxx11-inheriting-ctors.cpp
    M clang/test/PCH/cxx11-user-defined-literals.cpp
    M clang/test/PCH/cxx1y-decltype-auto.cpp
    M clang/test/PCH/cxx1y-deduced-return-type.cpp
    M clang/test/PCH/cxx1y-default-initializer.cpp
    M clang/test/PCH/cxx1y-init-captures.cpp
    M clang/test/PCH/cxx1y-variable-templates.cpp
    M clang/test/PCH/cxx1z-aligned-alloc.cpp
    M clang/test/PCH/cxx1z-decomposition.cpp
    M clang/test/PCH/cxx1z-using-declaration.cpp
    M clang/test/PCH/cxx2a-bitfield-init.cpp
    M clang/test/PCH/cxx2a-concept-specialization-expr.cpp
    M clang/test/PCH/cxx2a-constraints.cpp
    M clang/test/PCH/cxx2a-defaulted-comparison.cpp
    M clang/test/PCH/cxx2a-requires-expr.cpp
    M clang/test/PCH/cxx2a-template-lambdas.cpp
    A clang/test/PCH/delayed-pch-instantiate.cpp
    M clang/test/PCH/friend-template.cpp
    M clang/test/PCH/implicitly-deleted.cpp
    M clang/test/PCH/late-parsed-instantiations.cpp
    M clang/test/PCH/local_static.cpp
    M clang/test/PCH/macro-undef.cpp
    M clang/test/PCH/make-integer-seq.cpp
    M clang/test/PCH/ms-if-exists.cpp
    A clang/test/PCH/pch-instantiate-templates-forward-decl.cpp
    A clang/test/PCH/pch-instantiate-templates.cpp
    M clang/test/PCH/pr18806.cpp
    M clang/test/PCH/pragma-diag-section.cpp
    M clang/test/PCH/rdar10830559.cpp
    A clang/test/PCH/specialization-after-instantiation.cpp
    M clang/test/PCH/type_pack_element.cpp

  Log Message:
  -----------
  add option to instantiate templates already in the PCH

Add -fpch-instantiate-templates which makes template instantiations be
performed already in the PCH instead of it being done in every single
file that uses the PCH (but every single file will still do it as well
in order to handle its own instantiations). I can see 20-30% build
time saved with the few tests I've tried.

The change may reorder compiler output and also generated code, but
should be generally safe and produce functionally identical code.
There are some rare cases that do not compile with it,
such as test/PCH/pch-instantiate-templates-forward-decl.cpp. If
template instantiation bailed out instead of reporting the error,
these instantiations could even be postponed, which would make them
work.

Enable this by default for clang-cl. MSVC creates PCHs by compiling
them using an empty .cpp file, which means templates are instantiated
while building the PCH and so the .h needs to be self-contained,
making test/PCH/pch-instantiate-templates-forward-decl.cpp to fail
with MSVC anyway. So the option being enabled for clang-cl matches this.

Differential Revision: https://reviews.llvm.org/D69585




More information about the All-commits mailing list