From 7f055b7e1a07716517c5ef7564aa95b7749fc2f7 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 25 Jun 2018 13:23:49 +0000 Subject: [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 --- test/Driver/cl-pch.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/Driver/cl-pch.cpp') diff --git a/test/Driver/cl-pch.cpp b/test/Driver/cl-pch.cpp index 2503c97373..bef5ce6bd0 100644 --- a/test/Driver/cl-pch.cpp +++ b/test/Driver/cl-pch.cpp @@ -7,6 +7,7 @@ // 1. Build .pch file. // CHECK-YC: cc1 // CHECK-YC: -emit-pch +// CHECK-YC: -building-pch-with-obj // CHECK-YC: -o // CHECK-YC: pchfile.pch // CHECK-YC: -x @@ -14,6 +15,7 @@ // 2. Use .pch file. // CHECK-YC: cc1 // CHECK-YC: -emit-obj +// CHECK-YC: -building-pch-with-obj // CHECK-YC: -include-pch // CHECK-YC: pchfile.pch @@ -24,11 +26,13 @@ // 1. Build .pch file. // CHECK-YCO: cc1 // CHECK-YCO: -emit-pch +// CHECK-YCO: -building-pch-with-obj // CHECK-YCO: -o // CHECK-YCO: pchfile.pch // 2. Use .pch file. // CHECK-YCO: cc1 // CHECK-YCO: -emit-obj +// CHECK-YCO: -building-pch-with-obj // CHECK-YCO: -include-pch // CHECK-YCO: pchfile.pch // CHECK-YCO: -o @@ -46,6 +50,7 @@ // RUN: | FileCheck -check-prefix=CHECK-YU %s // Use .pch file, but don't build it. // CHECK-YU-NOT: -emit-pch +// CHECK-YU-NOT: -building-pch-with-obj // CHECK-YU: cc1 // CHECK-YU: -emit-obj // CHECK-YU: -include-pch @@ -63,6 +68,7 @@ // 1. Build .pch file. // CHECK-YC-YU: cc1 // CHECK-YC-YU: -emit-pch +// CHECK-YC-YU: -building-pch-with-obj // CHECK-YC-YU: -o // CHECK-YC-YU: pchfile.pch // 2. Use .pch file. -- cgit v1.2.1