From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30199 invoked by alias); 26 Aug 2005 17:38:30 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30155 invoked by uid 48); 26 Aug 2005 17:38:24 -0000 Date: Fri, 26 Aug 2005 17:40:00 -0000 Message-ID: <20050826173824.30154.qmail@sourceware.org> From: "guillaume dot melquiond at ens-lyon dot fr" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050813080257.23372.guillaume.melquiond@ens-lyon.fr> References: <20050813080257.23372.guillaume.melquiond@ens-lyon.fr> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/23372] [4.0/4.1 Regression] Temporary aggregate copy not elided when passing parameters by value X-Bugzilla-Reason: CC X-SW-Source: 2005-08/txt/msg03061.txt.bz2 List-Id: ------- 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