This question may be a duplicate.
GCC supports "flatten" attribute (emphasis added):
flatten
Generally, inlining into a function is limited. For a function marked with this attribute, every call inside this function will be inlined, if possible. Whether the function itself is considered for inlining depends on its size and the current inlining parameters. The flatten attribute only works reliably in unit-at-a-time mode.
My function foo
has inline
and "inside flatten". However, in the generated code I see:
bl 404a50 <foo.constprop.0>
It seems that GCC decided not to inline foo
because of its size. If I add __attribute__((__always_inline__))
, then the generated code doesn't have any calls (as expected).
Hence, the question: how to increase (or decrease) size of function used when considered for inlining (as a result of specifying "flatten" attribute)?
Extra question: what is the default size of function used when considered for inlining (as a result of specifying "flatten" attribute)?
I think adding -Winline
is your best bet to answering that question for your code. It should tell you where and why a function couldn't be inline
'd. The heruistics for inlining a function are complicated (I don't fully understand them) and depend heavily on your existing code and target hardware.
Check out the full description in warning options doc