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