public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Easwaran Raman <eraman@google.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: Richard Guenther <richard.guenther@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: Mark variables addressable if they are copied using libcall in RTL expander
Date: Wed, 22 Jun 2011 19:39:00 -0000	[thread overview]
Message-ID: <BANLkTimie4iac=V5bqeGcRp9xUbU1-3ak-hwSXfYtpJxToQUig@mail.gmail.com> (raw)
In-Reply-To: <201106221613.09011.ebotcazou@adacore.com>

On Wed, Jun 22, 2011 at 7:13 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> I fear this isn't enough considering pass-by-value aggregates that
>> are callee copied.
>
> It's indeed not sufficient for arguments passed by reference but callee-copied.
>
> This is PR target/49454.  For gcc.c-torture/execute/20000717-1.c:
>
> typedef struct trio { int a, b, c; } trio;
>
> int
> foo (trio t, int i)
> {
>  return bar (i, t);
> }
>
> yiedls in the .optimized dump:
>
> foo (struct trio t, int i)
> {
>  int D.1968;
>  struct trio t.0;
>
> <bb 2>:
>  t.0 = t;
>  D.1968_2 = bar (i_1(D), t.0);
>  return D.1968_2;
> }
>
> and the aggregate copy is elided by DSE because t.0 isn't may_be_aliased.  This
> seems to be a pre-existing bug though: its address is passed to bar in RTL.
>
> --
> Eric Botcazou
>

Is the following patch a reasonable fix for this case?  I assume I
should add similar code inside emit_library_call_value_1.

-Easwaran


--- gcc/calls.c	(revision 175081)
+++ gcc/calls.c	(working copy)
@@ -1073,6 +1073,8 @@ initialize_argument_information (int num_actuals A
 	  callee_copies
 	    = reference_callee_copied (args_so_far, TYPE_MODE (type),
 				       type, argpos < n_named_args);
+          if (callee_copies)
+            mark_addressable (args[i].tree_value);

 	  /* If we're compiling a thunk, pass through invisible references
 	     instead of making a copy.  */

  reply	other threads:[~2011-06-22 19:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21  2:15 Easwaran Raman
2011-06-21  9:02 ` Richard Guenther
2011-06-22 13:15   ` Eric Botcazou
2011-06-22 13:53     ` Jakub Jelinek
2011-06-22 13:54       ` Richard Guenther
2011-06-22 14:26   ` Eric Botcazou
2011-06-22 19:39     ` Easwaran Raman [this message]
2011-06-23 10:00       ` Eric Botcazou
2011-06-23 10:32         ` Richard Guenther
2011-06-23 11:07           ` Eric Botcazou
2011-06-23 19:16             ` Easwaran Raman
2011-06-23 19:32               ` Jakub Jelinek
2011-06-23 21:56                 ` Easwaran Raman
2011-06-24  9:00                   ` Richard Guenther

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='BANLkTimie4iac=V5bqeGcRp9xUbU1-3ak-hwSXfYtpJxToQUig@mail.gmail.com' \
    --to=eraman@google.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.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).