public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27055]  New: Structures are copied byte by byte into function arguments
@ 2006-04-06 11:46 guillaume dot melquiond at ens-lyon dot fr
  2006-04-06 12:03 ` [Bug c/27055] " gdr at integrable-solutions dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: guillaume dot melquiond at ens-lyon dot fr @ 2006-04-06 11:46 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-04-16 18:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-06 11:46 [Bug c/27055] New: Structures are copied byte by byte into function arguments guillaume dot melquiond at ens-lyon dot fr
2006-04-06 12:03 ` [Bug c/27055] " gdr at integrable-solutions dot net
2006-04-06 12:49 ` pluto at agmk dot net
2006-04-06 13:05 ` guillaume dot melquiond at ens-lyon dot fr
2006-04-13  1:52 ` [Bug target/27055] " pinskia at gcc dot gnu dot org
2006-04-16 18:16 ` guillaume dot melquiond at ens-lyon dot fr

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).