diff mbox

Fix PR58115

Message ID 87eh4kvs2e.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford Jan. 6, 2014, 7:16 p.m. UTC
Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
>>
>> Jakub Jelinek <jakub@redhat.com> wrote:
>>>On Mon, Jan 06, 2014 at 10:27:06AM +0000, Richard Sandiford wrote:
>>>> Of course, IMO, the cleanest fix would be to use switchable targets
>>>> for i386...
>>>
>>>We IMHO want that anyway, e.g. #pragma omp declare simd tests take eons
>>>to
>>>compile because even with just a few routines in a CU there are
>>>hundreds or
>>>thousands of IRA reinitializations.
>>
>> We also want a big fat comment before the non-obvious order of inits
>> when switching cfuns.
>>
>> Bernd, please revert your patch for now.
>>
>
> OK, reverted for now.

Thanks Bernd.  (And sorry for the tone of my original message -- wasn't happy
with that when I read it back.)

How about this patch for the big comment?

Thanks,
Richard


gcc/
	* function.c (invoke_set_current_function_hook): Add more commentary.

Comments

Bernd Edlinger Jan. 6, 2014, 9:43 p.m. UTC | #1
On Mon, 6 Jan 2014 19:16:57, Richard Saniford wrote:
>
> Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
>>>
>>> Jakub Jelinek <jakub@redhat.com> wrote:
>>>>On Mon, Jan 06, 2014 at 10:27:06AM +0000, Richard Sandiford wrote:
>>>>> Of course, IMO, the cleanest fix would be to use switchable targets
>>>>> for i386...
>>>>
>>>>We IMHO want that anyway, e.g. #pragma omp declare simd tests take eons
>>>>to
>>>>compile because even with just a few routines in a CU there are
>>>>hundreds or
>>>>thousands of IRA reinitializations.
>>>
>>> We also want a big fat comment before the non-obvious order of inits
>>> when switching cfuns.
>>>
>>> Bernd, please revert your patch for now.
>>>
>>
>> OK, reverted for now.
>
> Thanks Bernd. (And sorry for the tone of my original message -- wasn't happy
> with that when I read it back.)
>

No problem, Richard, I don't see this personally in any way.
 
> How about this patch for the big comment?
>

The comment should say that target_set_current_function()
cannot call target_reinit() because:

target_reinit()=>lang_dependent_init_target()
=>init_optabs()=>init_all_optabs(this_fn_optabs);

uses this_fn_optabs which is undefined here.

However many targets (nios2, rx, i386, rs6000) do exactly that.

Is there currently any target, that sets this_target_optab in the
target_set_current_function?


Regards,
Bernd.

> Thanks,
> Richard
>
>
> gcc/
> * function.c (invoke_set_current_function_hook): Add more commentary.
>
> Index: gcc/function.c
> ===================================================================
> --- gcc/function.c 2014-01-06 19:09:27.821167117 +0000
> +++ gcc/function.c 2014-01-06 19:15:27.764240857 +0000
> @@ -4405,9 +4405,23 @@ invoke_set_current_function_hook (tree f
> cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts));
> }
>
> + /* Give the target an opportunity to change the global state in
> + response to function attributes. This includes picking the
> + correct value of this_target on SWITCHABLE_TARGET targets.
> +
> + Note that this_target (and in particular this_target_optabs)
> + should always reflect the target state with default optimization
> + options. We therefore call the target hook first and then apply
> + any function-specific optimization options on top. */
> targetm.set_current_function (fndecl);
> +
> + /* Set this_fn_optabs appropriately, on the assumption that we
> + want the default optimization options. */
> this_fn_optabs = this_target_optabs;
>
> + /* Now adjust this_fn_optabs if using non-default optimization options.
> + init_tree_optimization_optabs ensures that the cached value of
> + TREE_OPTIMIZATION_OPTABS (opts) is correct for this_target. */
> if (opts != optimization_default_node)
> {
> init_tree_optimization_optabs (opts);
diff mbox

Patch

Index: gcc/function.c
===================================================================
--- gcc/function.c	2014-01-06 19:09:27.821167117 +0000
+++ gcc/function.c	2014-01-06 19:15:27.764240857 +0000
@@ -4405,9 +4405,23 @@  invoke_set_current_function_hook (tree f
 	  cl_optimization_restore (&global_options, TREE_OPTIMIZATION (opts));
 	}
 
+      /* Give the target an opportunity to change the global state in
+	 response to function attributes.  This includes picking the
+	 correct value of this_target on SWITCHABLE_TARGET targets.
+
+	 Note that this_target (and in particular this_target_optabs)
+	 should always reflect the target state with default optimization
+	 options.  We therefore call the target hook first and then apply
+	 any function-specific optimization options on top.  */
       targetm.set_current_function (fndecl);
+
+      /* Set this_fn_optabs appropriately, on the assumption that we
+	 want the default optimization options.  */
       this_fn_optabs = this_target_optabs;
 
+      /* Now adjust this_fn_optabs if using non-default optimization options.
+	 init_tree_optimization_optabs ensures that the cached value of
+	 TREE_OPTIMIZATION_OPTABS (opts) is correct for this_target.  */
       if (opts != optimization_default_node)
 	{
 	  init_tree_optimization_optabs (opts);