llvm-project/clang/test/CodeGenCXX/dllexport-no-dllexport-inli...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

134 lines
6.1 KiB
C++
Raw Normal View History

Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \
// RUN: -disable-llvm-passes -std=c++14 \
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - | \
// RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \
// RUN: -disable-llvm-passes -std=c++14 \
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// RUN: -emit-llvm -O1 -o - | \
// RUN: FileCheck --check-prefix=CHECK --check-prefix=EXPORTINLINE %s
struct __declspec(dllexport) ExportedClass {
// NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@ExportedClass@@
// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
void InclassDefFunc() {}
// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
int InclassDefFuncWithStaticVariable() {
// CHECK-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
static int static_variable = 0;
++static_variable;
return static_variable;
}
// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
int InclassDefFunctWithLambdaStaticVariable() {
// CHECK-DAG: @"?static_x@?2???R<lambda_1>@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?<auto>@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
return ([]() { static int static_x; return ++static_x; })();
}
// NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
inline void InlineOutclassDefFunc();
// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
inline int InlineOutclassDefFuncWithStaticVariable();
// CHECK-DAG: define dso_local dllexport void @"?OutoflineDefFunc@ExportedClass@@QEAAXXZ"
void OutoflineDefFunc();
};
void ExportedClass::OutoflineDefFunc() {}
inline void ExportedClass::InlineOutclassDefFunc() {}
inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
static int static_variable = 0;
return ++static_variable;
}
void ExportedClassUser() {
ExportedClass a;
a.InclassDefFunc();
a.InlineOutclassDefFunc();
}
template<typename T>
struct __declspec(dllexport) TemplateExportedClass {
void InclassDefFunc() {}
int InclassDefFuncWithStaticVariable() {
static int static_x = 0;
return ++static_x;
}
};
class A11{};
class B22{};
// CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11@@@@QEAAXXZ"
// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11@@@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11@@@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
template class TemplateExportedClass<A11>;
// NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@?$TemplateExportedClass@VB22@@@@QEAAXXZ"
// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VB22@@@@QEAAXXZ
// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VB22@@@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VB22@@@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
TemplateExportedClass<B22> b22;
void TemplateExportedClassUser() {
b22.InclassDefFunc();
b22.InclassDefFuncWithStaticVariable();
}
template<typename T>
struct TemplateNoAttributeClass {
void InclassDefFunc() {}
int InclassDefFuncWithStaticLocal() {
static int static_x;
return ++static_x;
}
};
// CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateNoAttributeClass@VA11@@@@QEAAXXZ"
// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VA11
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VA11@@@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
template class __declspec(dllexport) TemplateNoAttributeClass<A11>;
// CHECK-DAG: define available_externally dllimport void @"?InclassDefFunc@?$TemplateNoAttributeClass@VB22@@@@QEAAXXZ"
// CHECK-DAG: define available_externally dllimport i32 @"?InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VB22@@@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VB22@@@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4
extern template class __declspec(dllimport) TemplateNoAttributeClass<B22>;
void TemplateNoAttributeClassUser() {
TemplateNoAttributeClass<B22> b22;
b22.InclassDefFunc();
b22.InclassDefFuncWithStaticLocal();
}
struct __declspec(dllimport) ImportedClass {
// NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InClassDefFunc@ImportedClass@@QEAAXXZ"
// EXPORTINLINE-DAG: define available_externally dllimport void @"?InClassDefFunc@ImportedClass@@QEAAXXZ"
void InClassDefFunc() {}
// EXPORTINLINE-DAG: define available_externally dllimport i32 @"?InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ"
// NOEXPORTINLINE-DAG: define linkonce_odr dso_local i32 @"?InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ"
Add /Zc:DllexportInlines option to clang-cl Summary: This CL adds /Zc:DllexportInlines flag to clang-cl. When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables. By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables. On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below. These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied * https://chromium-review.googlesource.com/c/chromium/src/+/1212379 * https://chromium-review.googlesource.com/c/v8/v8/+/1186017 Below stats were taken with this patch applied on https://github.com/llvm-project/llvm-project-20170507/commit/a05115cd4c57ff76b0f529e38118765b58ed7f2e | config | build time | speedup | build dir size | | with patch, PCH on, debug | 1h10m0s | x1.13 | 35.6GB | | without patch, PCH on, debug | 1h19m17s | | 49.0GB | | with patch, PCH off, debug | 1h15m45s | x1.16 | 33.7GB | | without patch, PCH off, debug | 1h28m10s | | 52.3GB | | with patch, PCH on, release | 1h13m13s | x1.22 | 26.2GB | | without patch, PCH on, release | 1h29m57s | | 37.5GB | | with patch, PCH off, release | 1h23m38s | x1.32 | 23.7GB | | without patch, PCH off, release | 1h50m50s | | 38.7GB | This patch reduced obj size and the number of exported symbols largely, that improved link time too. e.g. link time stats of blink_core.dll become like below | | cold disk cache | warm disk cache | | with patch, PCH on, debug | 71s | 30s | | without patch, PCH on, debug | 111s | 48s | This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats. Bug: https://bugs.llvm.org/show_bug.cgi?id=33628 Reviewers: hans, thakis, rnk, javed.absar Reviewed By: hans Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman Differential Revision: https://reviews.llvm.org/D51340 llvm-svn: 346069
2018-11-03 14:45:00 +08:00
int InClassDefFuncWithStaticVariable() {
// CHECK-DAG: @"?static_variable@?1??InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4
static int static_variable = 0;
++static_variable;
return static_variable;
}
};
int InClassDefFuncUser() {
// This is necessary for declare statement of ImportedClass::InClassDefFunc().
ImportedClass c;
c.InClassDefFunc();
return c.InClassDefFuncWithStaticVariable();
}