https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93008
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org --- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #0) > Currently GCC considers the 'inline' keyword as a hint for inlining, not > just a request for comdat semantics. > > This is a problem in C++20 where arbitrarily complex functions are marked > 'constexpr' so that they can be used at compile time, and a constexpr > function is implicitly an inline function. But we do not want the function > to get additional weighting for runtime optimizations just because it is > eligible for use in compile-time constant expressions. > > It would be useful to have a new attribute that tells the inliner to ignore > whether the function is 'inline' and only consider its size, use in hot/cold > regions etc. > > Alternatively, do not interpret 'constexpr' on its own as an inlining hint, > and only treat it as a hint when a constexpr function is explicitly declared > with the 'inline' specifier (or is defined in the class body). > I would prefer this second approach. > > constexpr void f() { } // not an inline hint > constexpr inline void g() { } // inline hint > inline constexpr void h() { } // inline hint > > struct X { > constexpr void i() { } // inline hint > };