Mordante added a comment. In D86559#2243583 <https://reviews.llvm.org/D86559#2243583>, @staffantj wrote:
> The use case for this becomes clearer when considering that the attribute > that will be used 95% of the time is [[unlikely]]. You may have a constructor > that you wish to ask the compiler to please, please, do not inline this, in a > particular function, even if the rest of that function is either likely or > neutral. At the moment the likelihood is used only for branch prediction and not for inlining decisions. I'm not sure it would be a good idea to use this attribute for that duality. If it's wanted to control the inlining of calls at the callers side I feel a separate attribute would make more sense. void foo() { [[unlikely]] expensive_class q{}; ... } This looks odd to me and the attribute isn't allowed on the declaration. I think this looks better: void foo() { [[noinline]] expensive_class q{}; ... } > if (a) > [[unlikely]] expensive_class q{}; > > This could be the case if expensive_class held large static members, for > instance. This can be rewritten to be an expression and not a declaration, then the attribute can be used: if(a) [[unlikely]] expensive_class{}; Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86559/new/ https://reviews.llvm.org/D86559 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits