public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter
@ 2006-08-24 2:52 guillaume dot melquiond at ens-lyon dot fr
2006-08-24 6:51 ` [Bug c/28831] [4.0/4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: guillaume dot melquiond at ens-lyon dot fr @ 2006-08-24 2:52 UTC (permalink / raw)
To: gcc-bugs
Bug 23372 was a missed optimization with respect to GCC 3.4. It is now fixed
when the parameter is a reference. But there is still a regression when the
parameter is the return value of another function. Testcase: (-Wall -O3
--march=i386)
struct A { int a[1000]; };
struct A f();
void g(struct A);
void h() { g(f()); }
GCC 3.3 and 3.4 first allocate the stack frame of g and then require f to
directly store its return value in the parameter location. GCC 4.0, 4.1, and
4.2 (as of 2006-08-23) use another stack location for the return value of f,
then allocate the stack frame of g, and finally copy the value to this new
frame (possibly using a byte-by-byte copy, see bug 27055). The code generated
by GCC 3.x is optimal, the one by GCC 4.x is not.
GCC 3.4:
movl %esp, %eax
subl $12, %esp
pushl %eax
call f
addl $12, %esp
call g
GCC 4.2:
leal -4004(%ebp), %ebx
pushl %ebx
call f
subl $3988, %esp
movl %esp, %eax
pushl %edx
pushl $4000
pushl %ebx
pushl %eax
call memcpy
addl $16, %esp
call g
$ LANG=C /opt/gcc/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++ --prefix=/opt/gcc
Thread model: posix
gcc version 4.2.0 20060823 (experimental)
--
Summary: Aggregate copy not elided when using a return value as a
pass-by-value parameter
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: guillaume dot melquiond at ens-lyon dot fr
GCC target triplet: i386-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/28831] [4.0/4.1/4.2 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
@ 2006-08-24 6:51 ` rguenth at gcc dot gnu dot org
2006-08-24 11:13 ` [Bug middle-end/28831] " pinskia at gcc dot gnu dot org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-08-24 6:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2006-08-24 06:51 -------
Confirmed. As the other one was a C++ frontend problem this one may be solved
in the C frontend then.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |missed-optimization
Last reconfirmed|0000-00-00 00:00:00 |2006-08-24 06:51:23
date| |
Summary|Aggregate copy not elided |[4.0/4.1/4.2 Regression]
|when using a return value as|Aggregate copy not elided
|a pass-by-value parameter |when using a return value as
| |a pass-by-value parameter
Target Milestone|--- |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.0/4.1/4.2 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
2006-08-24 6:51 ` [Bug c/28831] [4.0/4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
@ 2006-08-24 11:13 ` pinskia at gcc dot gnu dot org
2006-08-25 8:35 ` guillaume dot melquiond at ens-lyon dot fr
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-24 11:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-08-24 11:12 -------
This is going to be hard to fix really, unless we make explicate the target's
behavior for passing structs (via value or by reference).
Right now we get:
D.1992 = f () [return slot optimization];
g (D.1992) [tail call];
Which looks ok if we are passing via value but since we need to pass by
reference, the middle-end thinks we need a new stack space for it because it
does not know that D.1992 is not used after the call to g.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
GCC target triplet|i386-linux-gnu |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.0/4.1/4.2 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
2006-08-24 6:51 ` [Bug c/28831] [4.0/4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
2006-08-24 11:13 ` [Bug middle-end/28831] " pinskia at gcc dot gnu dot org
@ 2006-08-25 8:35 ` guillaume dot melquiond at ens-lyon dot fr
2006-09-01 21:51 ` mmitchel at gcc dot gnu dot org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: guillaume dot melquiond at ens-lyon dot fr @ 2006-08-25 8:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from guillaume dot melquiond at ens-lyon dot fr 2006-08-25 08:34 -------
> Which looks ok if we are passing via value but since we need to pass by
> reference, the middle-end thinks we need a new stack space for it because it
> does not know that D.1992 is not used after the call to g.
Isn't it the other way around? There is no problem if we are passing by
reference, as the code then looks like "g (&D.1992);". The middle-end will not
do any copy. But, because we are passing by value, D.1992 is copied into the
stack frame instead. I understand your point about the middle-end having to
ensure that D.1992 is not used after g in order to store it directly into the
stack frame of g. But isn't this information already available to the
middle-end?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.0/4.1/4.2 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (2 preceding siblings ...)
2006-08-25 8:35 ` guillaume dot melquiond at ens-lyon dot fr
@ 2006-09-01 21:51 ` mmitchel at gcc dot gnu dot org
2007-02-03 19:35 ` [Bug middle-end/28831] [4.0/4.1/4.2/4.3 " gdr at gcc dot gnu dot org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-09-01 21:51 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.0/4.1/4.2/4.3 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (3 preceding siblings ...)
2006-09-01 21:51 ` mmitchel at gcc dot gnu dot org
@ 2007-02-03 19:35 ` gdr at gcc dot gnu dot org
2007-02-03 20:54 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-02-03 19:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gdr at gcc dot gnu dot org 2007-02-03 19:35 -------
won't fix in GCC-4.0.x. Adjusting milestone.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.0.4 |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.0/4.1/4.2/4.3 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (4 preceding siblings ...)
2007-02-03 19:35 ` [Bug middle-end/28831] [4.0/4.1/4.2/4.3 " gdr at gcc dot gnu dot org
@ 2007-02-03 20:54 ` pinskia at gcc dot gnu dot org
2007-02-14 9:16 ` mmitchel at gcc dot gnu dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-03 20:54 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.1.3 |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.0/4.1/4.2/4.3 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (5 preceding siblings ...)
2007-02-03 20:54 ` pinskia at gcc dot gnu dot org
@ 2007-02-14 9:16 ` mmitchel at gcc dot gnu dot org
2008-06-25 21:50 ` [Bug middle-end/28831] [4.1/4.2/4.3/4.4 " jason at gcc dot gnu dot org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-02-14 9:16 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.1.2 |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.1/4.2/4.3/4.4 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (6 preceding siblings ...)
2007-02-14 9:16 ` mmitchel at gcc dot gnu dot org
@ 2008-06-25 21:50 ` jason at gcc dot gnu dot org
2008-07-04 21:29 ` [Bug middle-end/28831] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-06-25 21:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2008-06-25 21:49 -------
Here's another example:
struct A { int i[100]; };
void f(struct A);
int main()
{
f((struct A){1});
}
Here we build up the compound literal on the stack and then copy it into the
argument slot.
This seems to be a problem with GIMPLE, as there's no way to represent that we
want a particular temporary object to live in the argument slot.
This is both more and less of a problem for C++, as it has many more temporary
struct objects, but also has pass-by-reference (and the ABI does transparent
pass-by-reference for non-POD structs).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.2/4.3/4.4 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (7 preceding siblings ...)
2008-06-25 21:50 ` [Bug middle-end/28831] [4.1/4.2/4.3/4.4 " jason at gcc dot gnu dot org
@ 2008-07-04 21:29 ` jsm28 at gcc dot gnu dot org
2009-03-31 19:41 ` [Bug middle-end/28831] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 21:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jsm28 at gcc dot gnu dot org 2008-07-04 21:28 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2/4.3/4.4 Regression]|[4.2/4.3/4.4 Regression]
|Aggregate copy not elided |Aggregate copy not elided
|when using a return value as|when using a return value as
|a pass-by-value parameter |a pass-by-value parameter
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.3/4.4/4.5 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (8 preceding siblings ...)
2008-07-04 21:29 ` [Bug middle-end/28831] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2009-03-31 19:41 ` jsm28 at gcc dot gnu dot org
2009-08-04 12:34 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 19:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2009-03-31 19:40 -------
Closing 4.2 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.2/4.3/4.4/4.5 Regression]|[4.3/4.4/4.5 Regression]
|Aggregate copy not elided |Aggregate copy not elided
|when using a return value as|when using a return value as
|a pass-by-value parameter |a pass-by-value parameter
Target Milestone|4.2.5 |4.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.3/4.4/4.5 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (9 preceding siblings ...)
2009-03-31 19:41 ` [Bug middle-end/28831] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-08-04 12:34 ` rguenth at gcc dot gnu dot org
2010-01-17 13:10 ` rguenth at gcc dot gnu dot org
2010-05-22 18:17 ` [Bug middle-end/28831] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2009-08-04 12:27 -------
GCC 4.3.4 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.4 |4.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.3/4.4/4.5 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (10 preceding siblings ...)
2009-08-04 12:34 ` rguenth at gcc dot gnu dot org
@ 2010-01-17 13:10 ` rguenth at gcc dot gnu dot org
2010-05-22 18:17 ` [Bug middle-end/28831] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-17 13:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2010-01-17 13:10 -------
Re-confirmed with 4.5.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2007-08-06 14:44:49 |2010-01-17 13:10:45
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/28831] [4.3/4.4/4.5/4.6 Regression] Aggregate copy not elided when using a return value as a pass-by-value parameter
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
` (11 preceding siblings ...)
2010-01-17 13:10 ` rguenth at gcc dot gnu dot org
@ 2010-05-22 18:17 ` rguenth at gcc dot gnu dot org
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 18:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2010-05-22 18:11 -------
GCC 4.3.5 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.5 |4.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28831
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-05-22 18:17 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-24 2:52 [Bug c/28831] New: Aggregate copy not elided when using a return value as a pass-by-value parameter guillaume dot melquiond at ens-lyon dot fr
2006-08-24 6:51 ` [Bug c/28831] [4.0/4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
2006-08-24 11:13 ` [Bug middle-end/28831] " pinskia at gcc dot gnu dot org
2006-08-25 8:35 ` guillaume dot melquiond at ens-lyon dot fr
2006-09-01 21:51 ` mmitchel at gcc dot gnu dot org
2007-02-03 19:35 ` [Bug middle-end/28831] [4.0/4.1/4.2/4.3 " gdr at gcc dot gnu dot org
2007-02-03 20:54 ` pinskia at gcc dot gnu dot org
2007-02-14 9:16 ` mmitchel at gcc dot gnu dot org
2008-06-25 21:50 ` [Bug middle-end/28831] [4.1/4.2/4.3/4.4 " jason at gcc dot gnu dot org
2008-07-04 21:29 ` [Bug middle-end/28831] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2009-03-31 19:41 ` [Bug middle-end/28831] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-08-04 12:34 ` rguenth at gcc dot gnu dot org
2010-01-17 13:10 ` rguenth at gcc dot gnu dot org
2010-05-22 18:17 ` [Bug middle-end/28831] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
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).