public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiufu Guo <guojiufu@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@gcc.gnu.org, wschmidt@linux.ibm.com
Subject: Re: [PATCH, rs6000]: mark clobber for registers changed by untpyed_call
Date: Thu, 06 Feb 2020 02:49:00 -0000	[thread overview]
Message-ID: <h488slgl9a7.fsf@genoa.aus.stglabs.ibm.com> (raw)
In-Reply-To: <20200205192514.GU22482@gate.crashing.org> (Segher Boessenkool's	message of "Wed, 5 Feb 2020 13:25:14 -0600")

Segher Boessenkool <segher@kernel.crashing.org> writes:

> On Wed, Feb 05, 2020 at 09:53:27PM +0800, Jiufu Guo wrote:
>> As PR93047 said, __builtin_apply/__builtin_return does not work well with
>> -frename-registers.  This is caused by return register(e.g. r3) is used to
>> rename another register, before return register is stored to stack.
>> 
>> This patch fix this issue by emitting clobber for those egisters which
>> maybe changed by untyped call.
>
> Yeah.  untyped_call does
>
>   /* The optimizer does not know that the call sets the function value
>      registers we stored in the result block.  We avoid problems by
>      claiming that all hard registers are used and clobbered at this
>      point.  */
>   emit_insn (gen_blockage ());
>
> but blockage does not say registers are used and clobbered:
>
> @cindex @code{blockage} instruction pattern
> @item @samp{blockage}
> This pattern defines a pseudo insn that prevents the instruction
> scheduler and other passes from moving instructions and using register
> equivalences across the boundary defined by the blockage insn.
> This needs to be an UNSPEC_VOLATILE pattern or a volatile ASM.
>
> Many archs have this same implementation of untyped_call (and of
> blockage, too).  It all just works by luck (or it doesn't work).
>
> What we have is:
>
>   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
>
>   for (i = 0; i < XVECLEN (operands[2], 0); i++)
>     {
>       rtx set = XVECEXP (operands[2], 0, i);
>       emit_move_insn (SET_DEST (set), SET_SRC (set));
>     }
>
> ... and nothing in the rtl stream says that those return registers are
> actually set by that call.  Maybe we should use gen_call_value?  Can we
> ever be asked to return more than a single thing here?
I was also thinking about using "gen_call_value" or "emit_clobber (r3)"
which could generate rtl: "%3:DI=call [foo]" or "call [foo]; clobber
r3".  This could tell optimizer that %3 is changed.  While there are
potential issues that untyped_call may change other registers.  So, mark
clobber for all touched registers maybe more safe.

>
> Some trivial patch comments:
>
>> gcc/
>> 2020-02-05  Jiufu Guo  <guojiufu@linux.ibm.com>
>> 
>> 	PR target/93047
>> 	* config/rs6000/rs6000.md (untyped_call): add emit_clobber.
>
> "Add", capital.
Thanks,
>
>> gcc/testsuite
>> 2020-02-05  Jiufu Guo  <guojiufu@linux.ibm.com>
>> 
>> 	PR target/93047
>> 	* gcc.dg/torture/stackalign/builtin-return-2.c: New case.
>
> "New test case."  (And there is trailing whitespace here; Git warns
> about that, so this won't happen much in the future :-) )
Oh, get it, thanks. The withspace is after this line.

Jiufu
>
>
> Segher

  reply	other threads:[~2020-02-06  2:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 13:53 Jiufu Guo
2020-02-05 19:25 ` Segher Boessenkool
2020-02-06  2:49   ` Jiufu Guo [this message]
2020-02-06 15:35     ` Segher Boessenkool
2020-02-07  7:10       ` Jiufu Guo
2020-02-08 16:17         ` Segher Boessenkool
2020-02-08 21:45           ` Segher Boessenkool
2020-02-14  6:58             ` Jiufu Guo
2020-02-14 18:12               ` Segher Boessenkool

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=h488slgl9a7.fsf@genoa.aus.stglabs.ibm.com \
    --to=guojiufu@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.ibm.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).