public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/28831] [8/9/10/11 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
Date: Mon, 22 Mar 2021 11:05:32 +0000	[thread overview]
Message-ID: <bug-28831-4-bHrYu7qqgT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-28831-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831

--- Comment #36 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that if we'd want to "preallocate" (or re-use) variables for argument
slots we have to properly arrange them according to the ABI.  Consider
a function taking more than just a single argument [passed on stack] which
we might still able to handle optimally [with greater difficulty].

Jasons C++ example expands from

  D.2368 = {};
  D.2368.i[0] = 1;
  f (D.2368);

if you modify that to

struct A { int i[100]; };
void f(int i, struct A, int j);
int main()
{
  f(0, (struct A){1}, 2);
}

then on i?86 both extra arguments are passed on the stack as well but
RTL expansion sees again

  D.2370 = {};
  D.2370.i[0] = 1;
  f (0, D.2370, 2);

but clearly we cannot just allocate D.2370 in a random place if it is
passed on the stack (on i?86 it's passed by reference).  For example

struct A { int i[2]; };
void f(struct A);
int main()
{
  f((struct A){1});
}

expanded as

  MEM <char[4]> [(struct A *)&D.1960 + 4B] = {};
  D.1960.i[0] = 1;
  f (D.1960);

is passed on the stack though.  So if we want to expose anything on GIMPLE
then we have to make the argument space on the stack distinct from random
stack variables.

  parent reply	other threads:[~2021-03-22 11:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-28831-4@http.gcc.gnu.org/bugzilla/>
2011-06-27 13:15 ` [Bug middle-end/28831] [4.3/4.4/4.5/4.6/4.7 " rguenth at gcc dot gnu.org
2012-01-12 12:06 ` [Bug middle-end/28831] [4.4/4.5/4.6/4.7 " rguenth at gcc dot gnu.org
2012-03-13 13:14 ` [Bug middle-end/28831] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-07-02 11:24 ` rguenth at gcc dot gnu.org
2012-08-06  0:39 ` [Bug middle-end/28831] [4.6/4.7/4.8 " chip at pobox dot com
2012-08-06  0:58 ` chip at pobox dot com
2012-08-14 22:51 ` chip at pobox dot com
2012-08-15 18:02 ` chip at pobox dot com
2012-08-18 15:34 ` hjl.tools at gmail dot com
2012-08-18 16:12 ` hjl.tools at gmail dot com
2013-04-12 15:16 ` [Bug middle-end/28831] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-09-05 20:04 ` chip at pobox dot com
2014-06-12 13:43 ` [Bug middle-end/28831] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-06-12 17:09 ` [Bug middle-end/28831] [4.8/4.9/4.10 " chip at pobox dot com
2014-12-19 13:26 ` [Bug middle-end/28831] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-06-23  8:18 ` [Bug middle-end/28831] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org
2015-06-26 19:53 ` [Bug middle-end/28831] [4.9/5/6 " jakub at gcc dot gnu.org
2015-06-26 20:27 ` jakub at gcc dot gnu.org
2021-03-22 11:05 ` rguenth at gcc dot gnu.org [this message]
2021-05-14  9:45 ` [Bug middle-end/28831] [9/10/11/12 " jakub at gcc dot gnu.org
2021-06-01  8:04 ` rguenth at gcc dot gnu.org
2022-05-27  9:33 ` [Bug middle-end/28831] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:29 ` jakub at gcc dot gnu.org
2023-07-07 10:28 ` [Bug middle-end/28831] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-05-23 12:29 ` [Bug middle-end/28831] [11/12/13/14/15 " pinskia at gcc dot gnu.org
2024-05-23 13:10 ` mkretz at gcc dot gnu.org
2024-05-23 13:32 ` rguenther at suse dot de
2024-05-27  7:38 ` mkretz at gcc dot gnu.org

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=bug-28831-4-bHrYu7qqgT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).