https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93008
Bug ID: 93008 Summary: Need a way to make inlining heuristics ignore whether a function is inline Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- 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). 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 };