This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34384] New: Poor code generated when passing returned struct as a parameter
- From: "sandmann at daimi dot au dot dk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Dec 2007 21:59:17 -0000
- Subject: [Bug c/34384] New: Poor code generated when passing returned struct as a parameter
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The program I will attach has a function that returns a struct. This struct is
then immediately passed by value to another function.
The code generated is using a local temporary variable, which leads to this
code:
(1) load address of temporary into eax
(2) call fun2(), which then fills out the temporary
(3) push temporary on stack
(4) call fun1()
It would be better to generate this:
(1) reserve space on stack for temporary
(2) move pointer to temporary into eax
(3) call fun2(), which fills out the temporary
(4) call fun1(), with the temporary already available on the stack
--
Summary: Poor code generated when passing returned struct as a
parameter
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sandmann at daimi dot au dot dk
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34384