On Mon, May 18, 2020 at 1:10 PM Jakub Jelinek via Gcc-patches
<[email protected]> wrote:
>
> On Mon, May 18, 2020 at 01:03:40PM +0200, Jakub Jelinek wrote:
> > > The optimize attribute is used to specify that a function is to be
> > > compiled
> > > with different optimization options than specified on the command line.
> > > ```
> > >
> > > It's pretty clear about the command line arguments (that are ignored).
> >
> > That is not clear at all. The difference is primarily in what the option
> > string says in there.
>
> And if we decide we want to keep existing behavior (haven't checked if we
> actually behave that way yet), we should add some syntax that will allow
> ammending command line options rather than replacing it.
We do behave this way - while we're running against the current
gcc_options we call decode_options which first does
default_options_optimization. So it behaves inconsistently with
respect to options not explicitly listed in default_options_table.
But I also think doing the whole processing as in decode_options
is the only thing that's really tested. And a fix would be to not
start from the current set of options but from a clean slate...
The code clearly thinks we're doing incremental changes:
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options);
/* If we previously had some optimization options, use them as the
default. */
if (old_opts)
cl_optimization_restore (&global_options,
TREE_OPTIMIZATION (old_opts));
/* Parse options, and update the vector. */
parse_optimize_options (args, true);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node (&global_options);
/* Restore current options. */
cl_optimization_restore (&global_options, &cur_opts);
so for example you should see -fipa-pta preserved from the
command-line while -fno-tree-pta would be overridden even
if not mentioned explicitely in the optimize attribute.
IMHO the current situation is far from useful...
Richard.
> Could be say start the optimize attribute string with + or something
> similar.
> Does target attribute behave that way too?
>
> Jakub
>