public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/23372] [4.0/4.1 Regression] Temporary aggregate copy not elided when passing parameters by value
Date: Fri, 26 Aug 2005 17:40:00 -0000	[thread overview]
Message-ID: <20050826173824.30154.qmail@sourceware.org> (raw)
In-Reply-To: <20050813080257.23372.guillaume.melquiond@ens-lyon.fr>


------- Additional Comments From guillaume dot melquiond at ens-lyon dot fr  2005-08-26 17:38 -------
> all of 3.4 and 4.1 produce exactly two temporaries.

Yet I said that g++ 3.4 did not produce any temporary, and I still think so. No
temporaries, only g's stack frame. See the following assembly code for the C
testcase (the generated assembly is the same as for C++, but easier to read
since there is no name mangling nor local labels).

h:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $4008, %esp
        movl    %esp, %eax
        subl    $12, %esp
        pushl   %eax
        call    f
        addl    $12, %esp
        call    g
        leave
        ret

For the sake of completeness, I'm also writing the assembly output for GCC 4.0,
so that the regression with respect to GCC 3.4 is clearly visible. Two
temporaries and two memory copies:

h:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %esi
        pushl   %ebx
        subl    $8012, %esp
        leal    -8008(%ebp), %ebx
        pushl   %ebx
        call    f
        leal    -4008(%ebp), %esi
        subl    $8, %esp
        pushl   $4000
        pushl   %ebx
        pushl   %esi
        call    memcpy
        subl    $3968, %esp
        movl    %esp, %eax
        pushl   %edx
        pushl   $4000
        pushl   %esi
        pushl   %eax
        call    memcpy
        addl    $16, %esp
        call    g
        addl    $4000, %esp
        leal    -8(%ebp), %esp
        popl    %ebx
        popl    %esi
        popl    %ebp
        ret

The C testcase is almost identical to the C++ testcase:

typedef struct A { int a[1000]; } A;
A f();
void g(A);
void h() { g(f()); }

And this is my version of GCC 3.4:

$ LANG=C gcc-3.4 -v
Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.5/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,f77,pascal,objc,ada --prefix=/usr --libexecdir=/usr/lib
--with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --program-suffix=-3.4
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug i486-linux-gnu
Thread model: posix
gcc version 3.4.5 20050821 (prerelease) (Debian 3.4.4-8)

Hope it helps.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23372


  parent reply	other threads:[~2005-08-26 17:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-13  8:03 [Bug c++/23372] New: " guillaume dot melquiond at ens-lyon dot fr
2005-08-13 14:17 ` [Bug c++/23372] " rguenth at tat dot physik dot uni-tuebingen dot de
2005-08-13 16:48 ` fang at csl dot cornell dot edu
2005-08-13 17:57 ` [Bug c++/23372] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-08-13 18:00 ` giovannibajo at libero dot it
2005-08-13 18:11 ` rguenth at tat dot physik dot uni-tuebingen dot de
2005-08-13 18:13 ` pinskia at gcc dot gnu dot org
2005-08-13 18:16 ` rguenth at tat dot physik dot uni-tuebingen dot de
2005-08-13 21:21 ` rguenth at gcc dot gnu dot org
2005-08-14  6:45 ` guillaume dot melquiond at ens-lyon dot fr
2005-08-26 14:59 ` rguenth at gcc dot gnu dot org
2005-08-26 17:40 ` guillaume dot melquiond at ens-lyon dot fr [this message]
2005-08-29 12:33 ` rguenth at gcc dot gnu dot org
2005-08-29 13:15 ` rguenth at gcc dot gnu dot org
2005-09-14  6:36 ` pinskia at gcc dot gnu dot org
2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
     [not found] <bug-23372-7904@http.gcc.gnu.org/bugzilla/>
2005-10-16 22:20 ` pinskia at gcc dot gnu dot org
2005-10-31  5:00 ` mmitchel at gcc dot gnu dot org
2006-01-31 15:24 ` pinskia at gcc dot gnu dot org
2006-01-31 16:03 ` rguenth at gcc dot gnu dot org
2006-01-31 16:05 ` pinskia at gcc dot gnu dot org
2006-01-31 16:05 ` pinskia at gcc dot gnu dot org
2006-02-02  9:16 ` rguenth at gcc dot gnu dot org
2006-02-02 17:16 ` sje at cup dot hp dot com
2006-02-03  1:49 ` hp at gcc dot gnu dot org
2006-02-03  9:16 ` rguenth at gcc dot gnu dot org
2006-02-07 15:36 ` rguenth at gcc dot gnu dot org
2006-08-23 14:23 ` jason at gcc dot gnu dot org
2006-08-23 14:23 ` jason at gcc dot gnu dot org
2006-08-23 14:34 ` jason at gcc dot gnu dot org
2006-10-07  3:49 ` pinskia at gcc dot gnu dot org
2006-10-07  6:16 ` pinskia at gcc dot gnu dot org
     [not found] <bug-23372-4@http.gcc.gnu.org/bugzilla/>
2011-03-18 15:07 ` jason 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=20050826173824.30154.qmail@sourceware.org \
    --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).