最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

performance - __attribute__((flatten)): how to increase size of function used when considered for inlining? - Stack Overflow

programmeradmin2浏览0评论

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)?

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)?

Share Improve this question edited Apr 1 at 10:56 pmor asked Mar 31 at 14:12 pmorpmor 6,4884 gold badges24 silver badges49 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论