]> granicus.if.org Git - clang/commit
[clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)
authorHans Wennborg <hans@hanshq.net>
Mon, 25 Jun 2018 13:23:49 +0000 (13:23 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 25 Jun 2018 13:23:49 +0000 (13:23 +0000)
commit7f055b7e1a07716517c5ef7564aa95b7749fc2f7
tree815f3cd286d172c0ca238b2f0d293dc1d10ef2a0
parent9bbcb03216cb2f853c4603bf367284992c47a1aa
[clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

With MSVC, PCH files are created along with an object file that needs to
be linked into the final library or executable. That object file
contains the code generated when building the headers. In particular, it
will include definitions of inline dllexport functions, and because they
are emitted in this object file, other files using the PCH do not need
to emit them. See the bug for an example.

This patch makes clang-cl match MSVC's behaviour in this regard, causing
significant compile-time savings when building dlls using precompiled
headers.

For example, in a 64-bit optimized shared library build of Chromium with
PCH, it reduces the binary size and compile time of
stroke_opacity_custom.obj from 9315564 bytes to 3659629 bytes and 14.6
to 6.63 s. The wall-clock time of building blink_core.dll goes from
38m41s to 22m33s. ("user" time goes from 1979m to 1142m).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335466 91177308-0d34-0410-b5e6-96231b3b80d8
17 files changed:
include/clang/AST/ExternalASTSource.h
include/clang/Basic/LangOptions.def
include/clang/Driver/CC1Options.td
include/clang/Sema/MultiplexExternalSemaSource.h
include/clang/Serialization/ASTBitCodes.h
include/clang/Serialization/ASTReader.h
include/clang/Serialization/Module.h
lib/AST/ASTContext.cpp
lib/Driver/Driver.cpp
lib/Driver/ToolChains/Clang.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/FrontendActions.cpp
lib/Sema/MultiplexExternalSemaSource.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/CodeGen/pch-dllexport.cpp [new file with mode: 0644]
test/Driver/cl-pch.cpp