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

Reply via email to