[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 Andrew Pinski changed: What|Removed |Added CC||marxin at gcc dot gnu.org Keywords||missed-optimization Severity|normal |enhancement Component|c |ipa
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 Martin Liška changed: What|Removed |Added CC||hubicka at gcc dot gnu.org Status|UNCONFIRMED |NEW Last reconfirmed||2022-01-24 Ever confirmed|0 |1
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #1 from Richard Biener --- Confirmed. For C++ an attribute on the call stmt might work even better. Note we're low on bits to represent this on the GENERIC CALL_EXPR and the GIMPLE gcall.
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #2 from Andrew Pinski --- (In reply to Richard Biener from comment #1) > Confirmed. For C++ an attribute on the call stmt might work even better. I think even C, it might be better too. [[]] syntax is there for GNU C now too. But those only apply to the full statement and not just a subset of one ...
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #3 from hubicka at kam dot mff.cuni.cz --- > > Confirmed. For C++ an attribute on the call stmt might work even better. > > I think even C, it might be better too. [[]] syntax is there for GNU C now > too. > But those only apply to the full statement and not just a subset of one ... I agree it is quite desirable thing to have Implementaiton on the inliner side is quite easy: all we need to do is to detect the attribute and put it into the inline summary and then handle it same way as always_inline. However what is the way to add the attribute to front-ends and get it attached to the gimple call statement?
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #4 from joseph at codesourcery dot com --- Right now, all the C front end does with statement attributes is parses them and then passes them to c_warn_unused_attributes; it doesn't have any other handling for such attributes.
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #5 from Dávid Bolvanský --- So you prefer eg. g = a[i] - [[gnu::always_inline]] foo(x, y) + 2 * bar(); over g = a[i] - __builtin_always_inline(foo(x, y)) + 2 * bar(); ? What is your proposed syntax?
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #6 from Jan Hubicka --- For Gimple representation __builtin_always_inline(foo(x, y)) does not make very good sense since gimple is not nested and foo may return void so there may not be any link between call and the builtin. I see that llvm has something like this https://reviews.llvm.org/D51200 (or at least it was proposed), but I think in our setting it would be more natural to have flag in the gimple call statement or some generic way to attach attributes to statements like we attach histograms.
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 Aaron Ballman changed: What|Removed |Added CC||aaron at aaronballman dot com --- Comment #7 from Aaron Ballman --- (In reply to Dávid Bolvanský from comment #5) > So you prefer eg. > > g = a[i] - [[gnu::always_inline]] foo(x, y) + 2 * bar(); To be clear, this syntax isn't valid in either C or C++. There are statement-level attributes, there are not expression-level attributes.
[Bug ipa/104187] Call site specific attribute to control inliner
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187 --- Comment #8 from Dávid Bolvanský --- So this works in Clang now int foo(int x, int y) { // any compiler will happily inline this function return x / y; } int test(int x, int y) { int r = 0; [[clang::noinline]] r += foo(x, y); // for some reason we don't want any inlining here return r; } foo(int, int): # @foo(int, int) mov eax, edi cdq idiv esi ret test(int, int): # @test(int, int) jmp foo(int, int) # TAILCALL foo(int, int): # @foo(int, int) mov eax, edi cdq idiv esi ret test(int, int): # @test(int, int) jmp foo(int, int) # TAILCALL