From: Patrick Palka Date: Fri, 30 Jan 2026 18:16:20 +0000 (-0500) Subject: libstdc++/regex: add [[gnu::always_inline]] to _Executor::_M_node X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8a1183d58e19b84a32e5e0a469352639fdbe312;p=thirdparty%2Fgcc.git libstdc++/regex: add [[gnu::always_inline]] to _Executor::_M_node The compiler understandably doesn't know that _M_node only ever has a single call site, _M_dfs, (and is not directly called from other library headers or user code) and so decides not to inline it. So use the always_inline attribute to force the inlining. This seems sufficient to make all _M_dfs subroutines get inlined away, and speeds up the executor by 30% on some microbenchmarks. libstdc++-v3/ChangeLog: * include/bits/regex_executor.tcc (__detail::_Executor::_M_node) [__OPTIMIZE__]: Add [[gnu::always_inline]] attribute. Declare inline. Reviewed-by: Jonathan Wakely --- diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc index ccdec934b49..3412ad683e4 100644 --- a/libstdc++-v3/include/bits/regex_executor.tcc +++ b/libstdc++-v3/include/bits/regex_executor.tcc @@ -578,7 +578,10 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2) template - void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: +#ifdef __OPTIMIZE__ + [[__gnu__::__always_inline__]] +#endif + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: _M_node(_Match_mode __match_mode, _StateIdT __i) { if (_M_states._M_visited(__i))