This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR target/52555: attribute optimize is overriding command line options


Richard Sandiford <rdsandiford@googlemail.com> writes:
> Aldy Hernandez <aldyh@redhat.com> writes:
>>> Rather than:
>>>
>>> 	  /* Change optabs if needed.  */
>>> 	  if (TREE_OPTIMIZATION_OPTABS (opts))
>>> 	    this_target_optabs
>>> 	      = (struct target_optabs *) TREE_OPTIMIZATION_OPTABS (opts);
>>> 	  else
>>> 	    this_target_optabs = &default_target_optabs;
>>>
>>> I think it'd be better to have:
>>>
>>> 	  /* Change optabs if needed.  */
>>> 	  if (TREE_OPTIMIZATION_OPTABS (opts))
>>> 	    this_fn_optabs
>>> 	      = (struct target_optabs *) TREE_OPTIMIZATION_OPTABS (opts);
>>> 	  else
>>> 	    this_fn_optabs = this_target_optabs;
>>>
>>> with genopinit.c updated to use this_fn_optabs instead of this_target_optabs.
>>
>> Hmmm, ok.
>>
>> I also added a default case setting this_fn_optabs = 
>> &default_target_optabs when the optimizations haven't changed.  I can 
>> remove this if redundant.
>
> No, sounds like a good plan, but I think it should be this_target_optabs
> rather than &default_target_optabs.

Gah, just realised after sending that it would be better to have:

static void
invoke_set_current_function_hook (tree fndecl)
{
  this_fn_optabs = this_target_optabs;
  if (!in_dummy_function)
    {
      tree opts = ((fndecl)
		   ? DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
		   : optimization_default_node);

      if (!opts)
	opts = optimization_default_node;

      /* Change optimization options if needed.  */
      if (optimization_current_node != opts)
	{
	  optimization_current_node = opts;
	  cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts));

	  /* Change optabs if needed.  */
	  if (TREE_OPTIMIZATION_OPTABS (opts))
	    this_fn_optabs
	      = (struct target_optabs *) TREE_OPTIMIZATION_OPTABS (opts);
	}

      targetm.set_current_function (fndecl);
    }
}

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]