[Bug c/23631] New: construct to memory and memcpy instead of memset
etienne_lorrain at yahoo dot fr
gcc-bugzilla@gcc.gnu.org
Tue Aug 30 10:24:00 GMT 2005
A global .rodata constant is created in the following case
and then memcpy() to the variable in the stack, instead
of just calling the intended memset.
etienne@cygne:~/projet/gujin$ cat > tmp.c
int
sub (int i)
{
int array[1000000] = { 0 };
sub2 (&array[i]);
}
etienne@cygne:~/projet/gujin$ ~/projet/toolchain/bin/gcc -S -Os tmp.c -o tmp.s
etienne@cygne:~/projet/gujin$ cat tmp.s
.file "tmp.c"
.section .rodata
.align 32
.type C.0.1134, @object
.size C.0.1134, 4000000
C.0.1134:
.zero 4000000
.text
.globl sub
.type sub, @function
sub:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $4000000, %esp
pushl $4000000
pushl $C.0.1134
leal -4000004(%ebp), %ebx
pushl %ebx
call memcpy
movl 8(%ebp), %eax
leal (%ebx,%eax,4), %eax
pushl %eax
call sub2
addl $16, %esp
movl -4(%ebp), %ebx
leave
ret
.size sub, .-sub
.ident "GCC: (GNU) 4.0.2 20050811 (prerelease)"
.section .note.GNU-stack,"",@progbits
etienne@cygne:~/projet/gujin$ ~/projet/toolchain/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/home/etienne/projet/toolchain --enable-
l
anguages=c
Thread model: posix
gcc version 4.0.2 20050811 (prerelease)
See also the thread at:
http://gcc.gnu.org/ml/gcc/2005-08/msg00660.html
Thanks to Jim Wilson (GNU Tools Support, http://www.specifix.com) for the
reduced test case and the analysis of the bug in gcc@gcc.gnu.org list.
Etienne.
--
Summary: construct to memory and memcpy instead of memset
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: etienne_lorrain at yahoo dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23631
More information about the Gcc-bugs
mailing list