aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@centrum.cz>2020-04-19 17:49:47 +0200
committerLuboš Luňák <l.lunak@centrum.cz>2020-06-21 17:05:52 +0200
commita45f713c673001abb4fe0612b909c698073eb356 (patch)
treed63305a8423959e6b94ede50a9bdc940bcf4011a /clang/lib/Frontend/CompilerInvocation.cpp
parent730ecb63ec0bac2ce83157d37bce4d2f7d4d1244 (diff)
downloadllvm-a45f713c673001abb4fe0612b909c698073eb356.zip
llvm-a45f713c673001abb4fe0612b909c698073eb356.tar.gz
llvm-a45f713c673001abb4fe0612b909c698073eb356.tar.bz2
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
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index f322cc7..1cd4830 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3370,6 +3370,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
+ Opts.PCHInstantiateTemplates = Args.hasArg(OPT_fpch_instantiate_templates);
Opts.MatrixTypes = Args.hasArg(OPT_fenable_matrix);