From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11881 invoked by alias); 6 Apr 2006 11:46:57 -0000 Received: (qmail 11848 invoked by uid 48); 6 Apr 2006 11:46:53 -0000 Date: Thu, 06 Apr 2006 11:46:00 -0000 Subject: [Bug c/27055] New: Structures are copied byte by byte into function arguments X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "guillaume dot melquiond at ens-lyon dot fr" 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 X-SW-Source: 2006-04/txt/msg00511.txt.bz2 List-Id: I tried the following testcase with various GCC versions available as Debian packages. With 3.3.5, the copy from *a to the stack frame of g is done word-by-word with rep movsl. With 3.4.4, it is done by memcpy. Both previous methods are fine. With 3.4.6, the copy is done byte-by-byte without string opcodes. With 4.0.3 and 4.1.0, it is done byte-by-byte and out-of-line: there are two jumps for each copied byte! So argument copy got broken for x86 during GCC 3.4 cycle and it did not get any better with GCC 4. typedef struct A { int a[1000]; } A; void g(A); void f(A *a) { g(*a); } Assembly output with GCC4 and -O3 optimization: pushl %ebp xorl %edx, %edx movl %esp, %ebp subl $4008, %esp movl 8(%ebp), %ecx .L3: cmpl $4000, %edx jb .L2 call g leave ret .p2align 4,,7 .L2: movzbl (%ecx,%edx), %eax movb %al, (%esp,%edx) incl %edx .p2align 4,,3 jmp .L3 $ LANG=C gcc-3.4 -v Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.6/specs Configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal --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-clocale=gnu --enable-libstdcxx-debug --with-tune=i686 i486-linux-gnu Thread model: posix gcc version 3.4.6 (Debian 3.4.6-1) $ LANG=C gcc-4.1 -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.1.0 (Debian 4.1.0-1) -- Summary: Structures are copied byte by byte into function arguments Product: gcc Version: 4.1.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: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27055