public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Alexandre Oliva <oliva@adacore.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH zero-call-used-regs] Add leafy mode for zero-call-used-regs
Date: Thu, 27 Oct 2022 13:30:10 +0000	[thread overview]
Message-ID: <3CF608E7-C293-4627-8FE9-8B580D69D764@oracle.com> (raw)
In-Reply-To: <or5yg6gtnw.fsf@lxoliva.fsfla.org>



> On Oct 26, 2022, at 5:29 PM, Alexandre Oliva <oliva@adacore.com> wrote:
> 
> On Oct 25, 2022, Qing Zhao <qing.zhao@oracle.com> wrote:
> 
>>> 'all' for leaf functions is likely wasteful.  If no other functions are
>>> called, one can determine exactly which registers might carry
>>> information out and thus need zeroing, and 'used' is thus likely enough,
>>> depending on the purpose of register scrubbing.  (In some scenarios, it
>>> might make sense to want scrubbing of all registers, even unused ones
>>> that carry incoming values)
> 
>> Under what kinds of situations, we should clear the un-used registers
>> for leaf functions?
> 
> The one (admittedly contrived) scenario that comes to mind is calling an
> out-of-line, empty leaf function with 'all' for explicit register
> scrubbing at desired points in the program.  I.e., this empty leaf
> function would be in charge of scrubbing the caller's registers.  It
> could even be tail-called.
> 
> I'm sure there are other scenarios in which keeping at least the
> possibility of 'all' is useful.
Okay.

> 
>> Now I am wondering whether we should make “leafy” mode by default then?
> 
> I'm not sure what you mean by default.  I think "skip" is the right
> default for general use, where register scrubbing is not explicitly
> requested.  When it is, perhaps -fzero-call-used-regs without
> '=<choice>' could be 'leafy' indeed or, even better, the extended form
> thereof that is in search of a name and so far unimplemented.

I guess that I was not clear in the previous email with the “by default”.
My previous point was:

If there is no need to clear the un-used registers for leaf functions, we can make the following change:

+  if ((zero_regs_type & LEAFY_MODE) && leaf_function_p ())
+    only_used = true;
+

As 

+  if ( leaf_function_p ())
+    only_used = true;
+

i.e, instead introducing a new MODE “LEAFY_MODE” and a new user sub-option, for LEAF functions, only
Clear its’ used registers even for “ALL”.

However, since there is need to clear the un-used registers for leaf functions. It looks like it is needed to provide
This new sub-option to users.

Is this clear this time?

> 
>> Another thing is, do you have any information on how much this new mode can save the 
>> code size and run-time compared to mode “all”?
> 
> I'm afraid I have not performed any measurements.

The major purpose of this new mode is to provide some improvement for the run-time and code-size. So, I think that 
Some information on this will be very helpful. Just a suggestion.


Another suggestion is: If this new mode is decided to add into GCC, the documentation might need to add more details on what’s the LEAFY mode,
The purpose of it, and how to use it, provide more details to the end-users
> 
>>> I have not (yet?) implemented this variant; I haven't even found a name
>>> I'm happy with for it.  (seal?  plug?  cork?  another leak antonym?)
> 
>> For this improvement, I am still thinking no need to add a new mode,
>> just add it by default?
> 
> Even if it is default, it may still need a name to appear before
> e.g. '-gpr'.  'default-gpr' might do, but I'm not happy with it either.

Default here, also means, no-need to introduce a user sub option, just add an optimization to the compiler. -:)

Qing
> 
> 
> -- 
> Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
>   Free Software Activist                       GNU Toolchain Engineer
> Disinformation flourishes because many people care deeply about injustice
> but very few check the facts.  Ask me about <https://stallmansupport.org>


  reply	other threads:[~2022-10-27 13:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21  7:31 Alexandre Oliva
2022-10-21 14:26 ` Qing Zhao
2022-10-25  2:48   ` Alexandre Oliva
2022-10-25 15:22     ` Qing Zhao
2022-10-26 21:29       ` Alexandre Oliva
2022-10-27 13:30         ` Qing Zhao [this message]
2023-06-16  7:26           ` Alexandre Oliva
2023-06-16 19:34             ` Qing Zhao
2023-06-22  1:16               ` Alexandre Oliva
2023-06-23 14:47                 ` Qing Zhao
2023-06-23 23:27                   ` [PATCH v3] " Alexandre Oliva
2023-06-26 13:58                     ` Qing Zhao
2023-06-27  6:27                       ` Richard Biener

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=3CF608E7-C293-4627-8FE9-8B580D69D764@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=oliva@adacore.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).