[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 21 06:19:09 PDT 2018


hans created this revision.
hans added reviewers: thakis, rnk, rsmith.

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).


https://reviews.llvm.org/D48426

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/ExternalASTSource.h
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendOptions.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  lib/AST/ASTContext.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  test/CodeGen/pch-dllexport.cpp
  test/Driver/cl-pch.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48426.152267.patch
Type: text/x-patch
Size: 19088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180621/9751b0c3/attachment-0001.bin>


More information about the cfe-commits mailing list