From 1a756f637fc4276c0d9a279e0e7be89c8e69a2d7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 24 Jul 2020 22:09:19 -0700 Subject: [PATCH] ircd::spirit: Isolate aggressive inlining; remove unit-level setting. --- configure.ac | 10 ---------- include/ircd/spirit.h | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 6f40f0a43..9b973be82 100644 --- a/configure.ac +++ b/configure.ac @@ -2370,16 +2370,6 @@ SPIRIT_UNIT_CPPFLAGS+=" -include ircd/spirit.h" AC_SUBST(SPIRIT_UNIT_CXXFLAGS) -dnl Slightly more aggressive than the default of 250. A large number of -dnl internal functions are generated out of some grammars at the default. -dnl The more aggressive value embeds rules together for optimization but -dnl may generate slightly larger functions. -AM_COND_IF([CLANG], -[ - SPIRIT_UNIT_CXXFLAGS+=" -mllvm -inlinehint-threshold=1000" - SPIRIT_UNIT_CXXFLAGS+=" -mllvm -inline-threshold=400" -]) - AM_COND_IF([GCC], [ SPIRIT_UNIT_CXXFLAGS+=" -fno-var-tracking" diff --git a/include/ircd/spirit.h b/include/ircd/spirit.h index ac5ce9028..542009448 100644 --- a/include/ircd/spirit.h +++ b/include/ircd/spirit.h @@ -26,12 +26,19 @@ // some false asserts around boolean character tests in spirit. #define BOOST_DISABLE_ASSERTS -#pragma GCC visibility push(default) +// This prevents spirit grammar rules from generating a very large and/or deep +// call-graph where rules compose together using wrapped indirect calls through +// boost::function -- this is higly inefficient as the grammar's logic ends up +// being a fraction of the generated code and the rest is invocation related +// overhead. By force-flattening here we can allow each entry-point into +// spirit to compose rules at once and eliminate the wrapping complex. +#pragma clang attribute push ([[gnu::always_inline]], apply_to = function) +#pragma clang attribute push ([[gnu::flatten]], apply_to = function) + #include #include -#pragma GCC visibility pop -#pragma GCC visibility push(hidden) +#pragma GCC visibility push (internal) #include #include #include @@ -45,6 +52,9 @@ #include #pragma GCC visibility pop +#pragma clang attribute pop +#pragma clang attribute pop + namespace ircd { namespace spirit __attribute__((visibility("default")))