While testing my recent changes to the handling of attributes on C++ templates I noticed that the -finline-limit=N option is not recognized in attribute or pragma optimize. In response to the bug I raised, Richard you said the option is deprecated, so I went ahead and documented the deprecation in the manual and also added a deprecation warning. I also added it to Optimization options. The attached patch reflects these changes.
I also tried to put together a test to verify that the option works as expected, both in attributes and in pragmas. I wasn't able to get it to work reliably or sensibly. In C, #pragma optimize ("inline-limit=1") has a global effect on all functions in the file, even those lexically before the pragma. In C++, the pragma has no effect. Both of these effects are contrary to my reading of the manual. Attribute optimize ("inline-limit") behaves similarly, which seems even more unexpected and even more contrary to the manual which by referring to Function Specific Option Pragmas suggests that both the pragma and especially the attribute apply optimizations to just the functions they're specified for. I don't expect this to be news to anyone here or easily fixable, but I think the effects or limitations of the mechanism should be made clear in the manual. Ditto for #pragma GDD diagnostic and its effect on middle-end warnings (or lack thereof). With the increasing number of such warnings that's increasingly becoming a source of frustration for users. If you agree I'll put together a documentation patch to try to clarify this. Martin
PR middle-end/84603 - -finline-limit not accepted in attribute and #pragma optimize gcc/testsuite/ChangeLog: PR middle-end/84603 * gcc.dg/inline-40.c: New test. gcc/ChangeLog: PR middle-end/84603 * common.opt (-finline-limit): Add to Optimization options. Add deprecation warning. * doc/invoke.texi: Document deprecation. Index: gcc/common.opt =================================================================== --- gcc/common.opt (revision 258114) +++ gcc/common.opt (working copy) @@ -1621,7 +1621,7 @@ finline-limit- Common RejectNegative Joined Alias(finline-limit=) finline-limit= -Common RejectNegative Joined UInteger +Common RejectNegative Joined UInteger Optimization Warn(%<-finline-limit%> is deprecated; use %<--param%> instead) -finline-limit=<number> Limit the size of inlined functions to <number>. finline-atomics Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 258114) +++ gcc/doc/invoke.texi (working copy) @@ -7854,6 +7854,8 @@ in default behavior. abstract measurement of function's size. In no way does it represent a count of assembly instructions and as such its exact meaning might change from one release to an another. +@code{-finline-limit} is deprecated in favor of +the corresponding @option{--param @var{name}=@var{value}} options. @item -fno-keep-inline-dllexport @opindex fno-keep-inline-dllexport Index: gcc/testsuite/gcc.dg/inline-40.c =================================================================== --- gcc/testsuite/gcc.dg/inline-40.c (nonexistent) +++ gcc/testsuite/gcc.dg/inline-40.c (working copy) @@ -0,0 +1,19 @@ +/* PR middle-end/84603 - -finline-limit not accepted in attribute + and #pragma optimize + { dg-do compile } + { dg-options "-Wall" } */ + +/* Verify that the options are accepted in both pragmas and attributes. */ +#pragma GCC optimize ("inline-functions") +void f0 (void); + +#pragma GCC optimize ("inline-limit=32") /* { dg-bogus "bad option .-finline-limit=32." } */ +void f1 (void); + +void __attribute__ ((optimize ("inline-functions"))) +f2 (void); + +void __attribute__ ((optimize ("inline-limit=100"))) /* { dg-bogus "bad option .-finline-limit=100." } */ +f3 (void); + +