public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Jakub Jelinek <jakub@redhat.com>,
	Richard Biener <richard.guenther@gmail.com>
Cc: Michael Matz <matz@suse.de>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Optimize macro: make it more predictable
Date: Mon, 7 Dec 2020 12:03:46 +0100	[thread overview]
Message-ID: <68745cd7-e6d3-445b-1322-6d5b3eff0c37@suse.cz> (raw)
In-Reply-To: <0cca4c25-78ab-6eaf-4a73-03474373d33a@suse.cz>

PING^2

On 11/26/20 2:56 PM, Martin Liška wrote:
> PING^1
> 
> On 11/9/20 11:35 AM, Martin Liška wrote:
>> On 11/3/20 2:34 PM, Jakub Jelinek wrote:
>>> On Tue, Nov 03, 2020 at 02:27:52PM +0100, Richard Biener wrote:
>>>> On Fri, Oct 23, 2020 at 1:47 PM Martin Liška <mliska@suse.cz> wrote:
>>>>> This is a follow-up of the discussion that happened in thread about no_stack_protector
>>>>> attribute: https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545916.html
>>>>>
>>>>> The current optimize attribute works in the following way:
>>>>> - 1) we take current global_options as base
>>>>> - 2) maybe_default_options is called for the currently selected optimization level, which
>>>>>        means all rules in default_options_table are executed
>>>>> - 3) attribute values are applied (via decode_options)
>>>>>
>>>>> So the step 2) is problematic: in case of -O2 -fno-omit-frame-pointer and __attribute__((optimize("-fno-stack-protector")))
>>>>> ends basically with -O2 -fno-stack-protector because -fno-omit-frame-pointer is default:
>>>>>       /* -O1 and -Og optimizations.  */
>>>>>       { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
>>>>>
>>>>> My patch handled and the current optimize attribute really behaves that same as appending attribute value
>>>>> to the command line. So far so good. We should also reflect that in documentation entry which is quite
>>>>> vague right now:
>>>>>
>>>>> """
>>>>> The optimize attribute is used to specify that a function is to be compiled with different optimization options than specified on the command line.
>>>>> """
>>>>>
>>>>> and we may want to handle -Ox in the attribute in a special way. I guess many macro/pragma users expect that
>>>>>
>>>>> -O2 -ftree-vectorize and __attribute__((optimize(1))) will end with -O1 and not
>>>>> with -ftree-vectorize -O1 ?
>>>>
>>>> Hmm.  I guess the only two reasonable options are to append to the active set
>>>> and thus end up with -ftree-vectorize -O1 or to start from an empty set and thus
>>>> end up with -O1.
>>>
>>> I'd say we always want to append, but only take into account explicit
>>> options.
>>
>> Yes, I also prefer to always append and basically drop the "reset" functionality.
>>
>>> So basically get the effect of
>>> take the command line, append to that options from the optimize/target
>>> pragmas in effect and append to that options from optimize/target
>>> attributes and only from that figure out the implicit options.
>>
>> Few notes here:
>> - target and optimize attributes are separate so parsing happens independently; however
>>    they use global_options and global_options_set as a starting point
>> - you can have a series of wrapped optimize/pragma macros and again information is shared
>> in global_options/global_options_set
>> - target and optimize options interact, but in a controlled way with SET_OPTION_IF_UNSET
>>
>> That said, I hope the biggest offender is right now the handling of -Olevel.
>>
>> @Jakub: Do you see a situation with my patch where it breaks?
>>
>> Thanks,
>> Martin
>>
>>>
>>>     Jakub
>>>
>>
> 


  reply	other threads:[~2020-12-07 11:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 11:47 Martin Liška
2020-11-03 13:27 ` Richard Biener
2020-11-03 13:34   ` Jakub Jelinek
2020-11-03 13:40     ` Richard Biener
2020-11-09 10:35     ` Martin Liška
2020-11-26 13:56       ` Martin Liška
2020-12-07 11:03         ` Martin Liška [this message]
2021-01-11 13:10           ` Martin Liška
2020-11-09 10:27   ` Martin Liška
2020-11-06 17:34 ` Jeff Law
2020-11-09 10:36   ` Martin Liška
2021-07-01 13:13 ` Martin Liška
2021-08-10 15:52   ` Martin Liška
2021-08-24 11:06     ` Martin Liška
2021-08-24 12:13   ` Richard Biener
2021-08-24 13:04     ` Martin Liška
2021-08-26 11:04       ` Richard Biener
2021-08-26 12:39         ` Martin Liška
2021-08-26 13:20           ` Richard Biener
2021-08-27  8:35           ` Martin Liška
2021-08-27  9:05             ` Richard Biener
2021-09-13 13:52               ` Martin Liška
2021-09-19  5:46                 ` Jeff Law
2021-09-06 11:37         ` [PATCH] flag_complex_method: support optimize attribute Martin Liška
2021-09-06 11:46           ` Jakub Jelinek
2021-09-06 12:16             ` Richard Biener
2021-09-06 12:24               ` Jakub Jelinek
2021-09-07  9:42               ` Martin Liška
2021-09-13 13:32                 ` Martin Liška
2021-09-19 14:45                 ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68745cd7-e6d3-445b-1322-6d5b3eff0c37@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=matz@suse.de \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).