https://gcc.gnu.org/g:a8a1183d58e19b84a32e5e0a469352639fdbe312
commit r16-7196-ga8a1183d58e19b84a32e5e0a469352639fdbe312 Author: Patrick Palka <[email protected]> Date: Fri Jan 30 13:16:20 2026 -0500 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 <[email protected]> Diff: --- libstdc++-v3/include/bits/regex_executor.tcc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc index ccdec934b49c..3412ad683e46 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<typename _BiIter, typename _Alloc, typename _TraitsT, bool __dfs_mode> - 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))
