This is the mail archive of the
mailing list for the GCC project.
Re: RFC: PATCH to gimplify_modify_expr_rhs to make return slot explicit
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org, Mark Mitchell <mark at codesourcery dot com>, "Frank Ch. Eigler" <fche at redhat dot com>
- Date: Wed, 19 Jan 2005 17:04:28 -0500
- Subject: Re: RFC: PATCH to gimplify_modify_expr_rhs to make return slot explicit
- Organization: Red Hat Canada
- References: <firstname.lastname@example.org> <20050119215802.GA8831@redhat.com>
Richard Henderson wrote:
On Wed, Jan 12, 2005 at 09:34:12PM -0500, Jason Merrill wrote:Yes, but that still leaves the mudflap problem open. pass_mudflap_1
needs to figure out, somehow, that this particular DECL is interesting
to it. Perhaps mudflap ought to not rely on TREE_ADDRESSABLE alone, and
ask whether the symbol is addressable or the target of a call that will
force its address in the return slot.
An early version of this patch performed this transformation
unconditionally, as the rtl version in expand_call does. However, a
problem occurred to me: if we elide both the copy from the user variable
(the NRV optimization) and the copy from the return slot (this
optimization), we can end up combining a local variable in the called
function with a globally visible object:
Another alternative is to do this lowering later. As late as possible,
actually. This has a couple of advantages:
Agreed. Exposing this too early is not kind to the optimizers.
(1) Don't have to worry about optimizers thinking the object address
leaks as with an address passed normally.
(2) Don't take the address of a variable that we might otherwise be
able to scalarize.
(3) We'll have a much clearer picture of when we need to use a temporary,
since we'll have true escape analysis results.