public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kyrill Tkachov <kyrylo.tkachov@foss.arm.com>
To: Christian Bruel <christian.bruel@st.com>,
	 "ramana.gcc@googlemail.com" <ramana.gcc@googlemail.com>,
	"Richard.Earnshaw@arm.com" <Richard.Earnshaw@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH][ARM] Fix PR target/69245 Rewrite arm_set_current_function
Date: Tue, 26 Jan 2016 17:04:00 -0000	[thread overview]
Message-ID: <56A7A6FB.2030505@foss.arm.com> (raw)
In-Reply-To: <56A7A52F.9070702@st.com>


On 26/01/16 16:56, Christian Bruel wrote:
>
>
> On 01/26/2016 04:58 PM, Kyrill Tkachov wrote:
>> Hi Christian,
>>
>> On 26/01/16 15:29, Christian Bruel wrote:
>>>
>>> On 01/25/2016 05:37 PM, Kyrill Tkachov wrote:
>>>
>>>
>>> So this is ok for trunk with the testcase changed as discussed above and using -O2
>>> optimisation level and with a couple comment fixes below.
>>>
>>> Hi Kyrill,
>>>
>>> I realized afterwards that my implementation had a flaw with the handling of #pragma GCC reset. What happened is that when both old and new TREE_TARGET_OPTION are NULL, we didn't save_restore the globals flags, to save compute time. The
>>> problem is that with #pragma GCC reset, we also fall into this situation, and exit without calling target_reeinit :-(
>>>
>>> Handling this situation doesn't complicate the code much, because I factorized the calls to target_reeinit + restore_target_globals into a new function (save_restore_target_globals). This function is called from the pragma context when
>>> resetting the state arm_reset_previous_fndecl to the default, and from arm_set_current_function when setting to a new target. This is only done when there is a change of the target flags, so no extra computing cost.
>>>
>>> Same testing as with previous patch:
>>>      arm-qemu/
>>>      arm-qemu//-mfpu=neon-fp-armv8
>>>      arm-qemu//-mfpu=neon
>>>
>>> Still OK ?
>>>
>> +/* Restore the TREE_TARGET_GLOBALS from previous state, or save it.  */
>> +static void
>> +save_restore_target_globals (tree new_tree)
>> +{
>> +  /* If we have a previous state, use it.  */
>> +  if (TREE_TARGET_GLOBALS (new_tree))
>> +    restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
>> +  else if (new_tree == target_option_default_node)
>> +    restore_target_globals (&default_target_globals);
>> +  else
>> +    {
>> +      /* Call target_reinit and save the state for TARGET_GLOBALS.  */
>> +      TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
>> +    }
>> +
>> +  arm_option_params_internal ();
>> +}
>>
>> Space before the function comment and signature.
> what do you mean ?  a new line between the comment and the function signature ? I usually mimic what's done in the other arm.c declarations, which sometimes have a new line, sometime not. It's not clear to me what's mandatory here, even 
> in the other parts of the compiler.
>

Yes, I meant new line, sorry. A new line is the rule, though there are some
functions that don't follow it. I guess we can fix those as we encounter them.

>>   Also, you need to document what is the NEW_TREE
>> parameter.
>>
>>    /* Invalidate arm_previous_fndecl.  */
>>    void
>> -arm_reset_previous_fndecl (void)
>> +arm_reset_previous_fndecl (tree new_tree)
>>    {
>> +  if (new_tree)
>> +    save_restore_target_globals (new_tree);
>> +
>>      arm_previous_fndecl = NULL_TREE;
>>    }
>>
>> I'm a bit wary of complicating this function. Suddenly it doesn't just reset the previous fndecl
>> but also restores globals and can save stuff into its argument. It's suddenly not clear what it's
>> purpose is.
>> I think it would be clearer if you just added save_restore_target_globals to arm_protos.h and called
>> it explicitly from arm_pragma_target_parse when appropriate.
>
> sure, like this one attached (sanity checked) ?
>
>

This is ok if it passes a proper testing round.

Thanks,
Kyrill


>>
>> +
>> +  /* If nothing to do return. #pragma GCC reset or #pragma GCC pop to
>> +     the default have been handled by save_restore_target_globals from
>> +     arm_pragma_target_parse.  */
>>
>> Two spaces between fullstop and "#pragma GCC".
>
> thanks,
>
> Christian
>

      reply	other threads:[~2016-01-26 17:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 10:37 Christian Bruel
2016-01-21 12:22 ` Kyrill Tkachov
2016-01-22 14:08   ` Christian Bruel
2016-01-22 14:17     ` Kyrill Tkachov
2016-01-22 14:51       ` Christian Bruel
2016-01-25 16:38         ` Kyrill Tkachov
2016-01-26 15:30           ` Christian Bruel
2016-01-26 15:58             ` Kyrill Tkachov
2016-01-26 16:56               ` Christian Bruel
2016-01-26 17:04                 ` Kyrill Tkachov [this message]

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=56A7A6FB.2030505@foss.arm.com \
    --to=kyrylo.tkachov@foss.arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=christian.bruel@st.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ramana.gcc@googlemail.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).