On Thu, May 20, 2021 at 12:29 AM Joern Wolfgang Rennecke
<joern.renne...@riscy-ip.com> wrote:
>
> We set default for some target options in TARGET_OPTION_OPTIMIZATION_TABLE,
> but these can be overridden by specifying the corresponding explicit
> -mXXX / -mno-XXX options.
> When a function bears the attribue
> __attribute__ ((optimize("02")))
> the target options are set to the default for that optimization level,
> which can be different from what was selected for the file as a whole.
> As handle_optimize_attribute is right now, it will thus clobber the
> target options, and with enable_checking it will then abort.
>
> The attached patch makes it save and restore the target options.
>
> Bootstrapped and regression tested on x86_64-pc-linux-gnu.

That looks reasonable but of course it doesn't solve the issue that those
altered target options will not be in effect on the optimize("O2") function.

IIRC Martin has changes in the works to unify target & optimize here
which should obsolete this fix.  Martin - what's the state of this?  Do you
think this patch makes sense in the mean time (and maybe also on
the branch though the assert is not in effect there but the behavior
is still observed and unexpected).

Thanks,
Richard.

Reply via email to