https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121692

--- Comment #4 from jchrist at linux dot ibm.com ---
(In reply to Andrew Pinski from comment #3)
> So with the cold attribute, small "functions" don't inline always:
> ```
> Deciding on inlining of small functions.  Starting with size 0.
> 
> /app/example.cpp:66:15: missed:   not inlinable: __order_base_2.part.0/17 ->
> __flogr/1, call is unlikely and code size would grow
> 
> ```

That is exactly the problem.  Since all the __builtin_constant_p paths through
the function are folded away later (and, especially, at the call sites, the
input is not compile-time constant anymore), the function size should actually
be small.  Nevertheless, size computation includes all the statements of the
__builtin_constant_p branches.

Our kernel devs have such patterns a lot in the code and assume that the code
gets properly inlined.  Nevertheless, we see a lot of out-of-line functions
based on this.

> Maybe cold is not the right attribute here.


Well, that comes from the kernel init functions and at least semantically is
right since the init function is called only once.  I see inlining into
non-cold functions, but as soon as only cold functions are left to inline into,
we get an out-of-line function.

Reply via email to