Bug 84603 - -finline-limit not accepted in attribute and #pragma optimize
Summary: -finline-limit not accepted in attribute and #pragma optimize
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, opt-attribute
Depends on:
Blocks:
 
Reported: 2018-02-27 20:20 UTC by Martin Sebor
Modified: 2022-03-17 20:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2018-02-27 20:20:20 UTC
In testing my patch for bug 83871 I tried to verify that DECL_DISREGARD_INLINE_LIMITS() is being handled as expected by duplicate_decls().  I found out that even though the C and C++ front ends try to handle the limits the -finline-limit option itself is not recognized by either attribute optimize or #pragma GCC optimize.

Debugging the code shows that the warning is issued by parse_optimize_options() in response to options that aren't tagged as optimization options.  Sure enough, common.opt doesn't specify Optimization for the option:

  finline-limit-
  Common RejectNegative Joined Alias(finline-limit=)

  finline-limit=
  Common RejectNegative Joined UInteger
  -finline-limit=<number>	Limit the size of inlined functions to <number>.

$ cat b.c && gcc -O1 -S -Wall -Wextra -finline-limit=16 b.c
#pragma GCC optimize ("inline-functions")

void f0 (void);

#pragma GCC optimize ("align-loops=32")

void f1 (void);

#pragma GCC optimize ("inline-limit=32")

void f2 (void);

void __attribute__ ((optimize ("inline-functions")))
f3(void);

void __attribute__ ((optimize ("inline-limit=100")))
f4 (void);
b.c:9:9: warning: bad option ‘-finline-limit=32’ to pragma ‘optimize’ [-Wpragmas]
 #pragma GCC optimize ("inline-limit=32")
         ^~~
b.c:11:1: warning: bad option ‘-finline-limit=32’ to attribute ‘optimize’ [-Wattributes]
 void f2 (void);
 ^~~~
b.c:14:1: warning: bad option ‘-finline-limit=32’ to attribute ‘optimize’ [-Wattributes]
 f3(void);
 ^~
b.c:17:1: warning: bad option ‘-finline-limit=32’ to attribute ‘optimize’ [-Wattributes]
 f4 (void);
 ^~
b.c:17:1: warning: bad option ‘-finline-limit=100’ to attribute ‘optimize’ [-Wattributes]
Comment 1 Richard Biener 2018-02-28 08:58:15 UTC
-finline-limit is a deprecated way to affect inlining, please don't expose it further.
Comment 2 Martin Liška 2018-02-28 09:58:58 UTC
(In reply to Richard Biener from comment #1)
> -finline-limit is a deprecated way to affect inlining, please don't expose
> it further.

Then what about printing warning that we use for options that are deprecated?
Comment 3 Martin Sebor 2018-02-28 15:17:34 UTC
I didn't know the option was deprecated (the manual doesn't mention it).  I agree with Martin's suggestion to add a deprecation message for its uses (along with a note to the manual).  Let me take care of it.
Comment 4 Richard Biener 2018-03-02 08:08:23 UTC
Note this is an option having IPA effect so it doesn't make sense to specify it on a per-function level.  Thus INVALID.

That is, the effect is setting some --params but their values are always global and not per function.  So it's more an implementation "defect", some of the
inliner parameters might make sense to constrain on a per-function level.
Comment 5 Martin Liška 2018-03-02 11:26:07 UTC
(In reply to Richard Biener from comment #4)
> Note this is an option having IPA effect so it doesn't make sense to specify
> it on a per-function level.  Thus INVALID.
> 
> That is, the effect is setting some --params but their values are always
> global and not per function.  So it's more an implementation "defect", some
> of the
> inliner parameters might make sense to constrain on a per-function level.

And do you Richi agree with option obsoleting?
Comment 6 Martin Sebor 2018-03-03 19:59:44 UTC
I disagree with resolving this report as invalid.  If the option is deprecated at a minimum the manual, if not GCC itself, should say so.  Otheriwse, if it isn't deprecated but cannot be made to work in attribute/#pragma, the manual should explain that and, ideally, GCC should mention that in the text of the warning it prints.  Let me prepare a patch with one of these solutions.
Comment 7 Martin Sebor 2022-03-17 20:05:36 UTC
I'm no longer working on this.