summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorTakuto Ikuta <takuto.ikuta@gmail.com>2018-11-03 06:45:00 +0000
committerTakuto Ikuta <takuto.ikuta@gmail.com>2018-11-03 06:45:00 +0000
commit302c64353122d7251c10640e10623c0d8bc38422 (patch)
tree38d8b520d82fc0deb8811f556850eb4cdf45e81d /clang/lib/Sema/SemaDecl.cpp
parent4ec5d67e49a5df9381b30470b68ebf0d01545dc0 (diff)
downloadbcm5719-llvm-302c64353122d7251c10640e10623c0d8bc38422.tar.gz
bcm5719-llvm-302c64353122d7251c10640e10623c0d8bc38422.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f8068dd9c82..0965c3f3473 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11930,6 +11930,14 @@ void Sema::CheckStaticLocalForDllExport(VarDecl *VD) {
assert(VD->isStaticLocal());
auto *FD = dyn_cast_or_null<FunctionDecl>(VD->getParentFunctionOrMethod());
+
+ // Find outermost function when VD is in lambda function.
+ while (FD && !getDLLAttr(FD) &&
+ !FD->hasAttr<DLLExportStaticLocalAttr>() &&
+ !FD->hasAttr<DLLImportStaticLocalAttr>()) {
+ FD = dyn_cast_or_null<FunctionDecl>(FD->getParentFunctionOrMethod());
+ }
+
if (!FD)
return;
@@ -11938,6 +11946,24 @@ void Sema::CheckStaticLocalForDllExport(VarDecl *VD) {
auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
NewAttr->setInherited(true);
VD->addAttr(NewAttr);
+ } else if (Attr *A = FD->getAttr<DLLExportStaticLocalAttr>()) {
+ auto *NewAttr = ::new (getASTContext()) DLLExportAttr(A->getRange(),
+ getASTContext(),
+ A->getSpellingListIndex());
+ NewAttr->setInherited(true);
+ VD->addAttr(NewAttr);
+
+ // Export this function to enforce exporting this static variable even
+ // if it is not used in this compilation unit.
+ if (!FD->hasAttr<DLLExportAttr>())
+ FD->addAttr(NewAttr);
+
+ } else if (Attr *A = FD->getAttr<DLLImportStaticLocalAttr>()) {
+ auto *NewAttr = ::new (getASTContext()) DLLImportAttr(A->getRange(),
+ getASTContext(),
+ A->getSpellingListIndex());
+ NewAttr->setInherited(true);
+ VD->addAttr(NewAttr);
}
}
OpenPOWER on IntegriCloud