[Libreoffice-commits] core.git: compilerplugins/clang config_host/config_clang.h.in configure.ac
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 9 08:09:59 UTC 2021
compilerplugins/clang/pluginhandler.cxx | 13 +++++++++++++
config_host/config_clang.h.in | 2 ++
configure.ac | 1 +
3 files changed, 16 insertions(+)
New commits:
commit 422c939f44eec82aca1060d22ea9a95a44d6b17d
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Apr 8 17:01:15 2021 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Apr 9 10:09:07 2021 +0200
make clang plugin check code in headers only once if in PCH
When using Clang PCHs, we know for certain that the content of a PCH
will be used once by the PCH's dedicated source file. So it is not
necessary to let clang plugin check locations coming from a PCH
every time, but just once when compiling that dedicated source.
For starmath's parse.cxx this reduces compilation time 0.94s->0.4s
(0.1s when not using plugins at all), for sc's document.cxx it is
5.9s->5.0s (4.0s without plugins). For reference, without PCHs
the numbers are (with/without plugins) 2.1s/1.9s for parse.cxx
and 11.2s/10.3s for document.cxx.
Change-Id: Ie39787e65d7951187941dcff4899d053da63cbdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113817
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 54dba3e3bcc0..622caf917b8e 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -231,6 +231,19 @@ bool PluginHandler::ignoreLocation(SourceLocation loc) {
bool PluginHandler::checkIgnoreLocation(SourceLocation loc)
{
+#if HAVE_BUILDING_PCH_WITH_OBJ
+ // If we're building a separate precompiled_foo.cxx file
+ // for a PCH, then it is not necessary to check contents of everything
+ // included by the PCH in every compilation, check only once for that
+ // precompiled_foo.cxx file.
+ if( !compiler.getSourceManager().isLocalSourceLocation( loc ))
+ {
+ if( !compiler.getLangOpts().BuildingPCHWithObjectFile )
+ return true;
+ }
+#elif CLANG_VERSION >= 110000
+#error Internal error, -building-pch-with-obj support not detected in Clang.
+#endif
SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc );
if( compiler.getSourceManager().isInSystemHeader( expansionLoc ))
return true;
diff --git a/config_host/config_clang.h.in b/config_host/config_clang.h.in
index c19c0875ce86..e588c86cf0ed 100644
--- a/config_host/config_clang.h.in
+++ b/config_host/config_clang.h.in
@@ -17,4 +17,6 @@ Settings related to Clang compiler plugins.
thus causing update of this .h file and triggering rebuild of our Clang plugin. */
#undef CLANG_FULL_VERSION
+#define HAVE_BUILDING_PCH_WITH_OBJ 0
+
#endif
diff --git a/configure.ac b/configure.ac
index 3a03dd38290f..cfc63ed6b6f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5779,6 +5779,7 @@ if test -n "$ENABLE_PCH"; then
CFLAGS=$save_CFLAGS
if test -n "$BUILDING_PCH_WITH_OBJ"; then
AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BUILDING_PCH_WITH_OBJ)
else
AC_MSG_RESULT(no)
fi
More information about the Libreoffice-commits
mailing list