https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69087
Bug ID: 69087 Summary: e500v2 cross compiler skips assignment of double local variable in large stack frame Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mavik at outlook dot com.au Target Milestone: --- Created attachment 37192 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37192&action=edit Preprocessed file When compiled for a e500v2 target, the following program works as expected with values of N in the ranges 1..4095 and 8192..8223. For values of N 4096..8191 or greater than 8224 the output is either 0 or a random/uninitialised value. I suspected that the issue was due to a stack overflow, however, when inspecting the generated assembly code, for values of N 4096..8191 the assembly code corresponding to the line "array[N-1] = N;" is omitted. test.c ----- #include <stdio.h> int main(int argc, char *argv[]) { double array[N]; array[N-1] = N; printf("array[%d] = %f\n", N-1, array[N-1]); return 1; } ----- Compiler details and building on the host: $ /opt/Denx/eldk/usr/bin/ppc_85xxDP-gcc -v -save-temps -DN=4096 test.c Reading specs from /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/specs Target: powerpc-linux Configured with: /opt/eldk/build/ppc-2008-04-01/work/usr/src/denx/BUILD/crosstool-0.43/build/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/gcc-4.2.2/configure --target=powerpc-linux --host=i686-host_pc-linux-gnu --prefix=/var/tmp/eldk.UZpAG7/usr/crosstool/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux --disable-hosted-libstdcxx --with-headers=/var/tmp/eldk.UZpAG7/usr/crosstool/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/powerpc-linux/include --with-local-prefix=/var/tmp/eldk.UZpAG7/usr/crosstool/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/powerpc-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++,java --enable-shared --enable-c99 --enable-long-long --without-x Thread model: posix gcc version 4.2.2 /opt/Denx/eldk/usr/bin/../libexec/gcc/powerpc-linux/4.2.2/cc1 -E -quiet -v -imultilib m8540 -iprefix /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/ -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix -DN=4096 test.c -mcpu=8540 -mfloat-gprs=double -mspe=yes -mabi=spe -fpch-preprocess -o test.i ignoring nonexistent directory "/opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/../../../../powerpc-linux/sys-include" ignoring nonexistent directory "/opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/../../../../powerpc-linux/include" ignoring nonexistent directory "/var/tmp/eldk.UZpAG7/usr/crosstool/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/lib/gcc/powerpc-linux/4.2.2/include" ignoring nonexistent directory "/var/tmp/eldk.UZpAG7/usr/crosstool/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/powerpc-linux/sys-include" ignoring nonexistent directory "/var/tmp/eldk.UZpAG7/usr/crosstool/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/powerpc-linux/include" ignoring duplicate directory "/opt/Denx/eldk/usr/lib/gcc/powerpc-linux/4.2.2/include" ignoring nonexistent directory "/opt/Denx/eldk/usr/lib/gcc/powerpc-linux/4.2.2/../../../../powerpc-linux/sys-include" ignoring nonexistent directory "/opt/Denx/eldk/usr/lib/gcc/powerpc-linux/4.2.2/../../../../powerpc-linux/include" #include "..." search starts here: #include <...> search starts here: /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/include /opt/Denx/eldk/usr/../ppc_85xxDP/usr/include End of search list. /opt/Denx/eldk/usr/bin/../libexec/gcc/powerpc-linux/4.2.2/cc1 -fpreprocessed test.i -quiet -dumpbase test.c -mcpu=8540 -mfloat-gprs=double -mspe=yes -mabi=spe -auxbase test -version -o test.s GNU C version 4.2.2 (powerpc-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.3 2.96-113). GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128253 Compiler executable checksum: 1aec0482efbebeb41ccfcf839ce71331 /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/../../../../powerpc-linux/bin/as -me500 -mspe -V -Qy -o test.o test.s GNU assembler version 2.17.50.0.12 (powerpc-linux) using BFD version 2.17.50.0.12 20070128 /opt/Denx/eldk/usr/bin/../libexec/gcc/powerpc-linux/4.2.2/collect2 --eh-frame-hdr -V -Qy -m elf32ppclinux --hash-style=gnu -dynamic-linker /lib/ld.so.1 /opt/Denx/eldk/usr/../ppc_85xxDP/usr/lib/crt1.o /opt/Denx/eldk/usr/../ppc_85xxDP/usr/lib/crti.o /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/m8540/crtbegin.o -L/opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/m8540 -L/opt/Denx/eldk/usr/lib/gcc/powerpc-linux/4.2.2/m8540 -L/opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2 -L/opt/Denx/eldk/usr/bin/../lib/gcc -L/opt/Denx/eldk/usr/lib/gcc/powerpc-linux/4.2.2 -L/opt/Denx/eldk/usr/../ppc_85xxDP/lib -L/opt/Denx/eldk/usr/../ppc_85xxDP/usr/lib test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/m8540/crtsavres.o /opt/Denx/eldk/usr/bin/../lib/gcc/powerpc-linux/4.2.2/m8540/crtend.o /opt/Denx/eldk/usr/../ppc_85xxDP/usr/lib/crtn.o GNU ld version 2.17.50.0.12 20070128 Supported emulations: elf32ppclinux elf32ppc elf32ppcsim $ Running on the target: #./a.out array[4095] = -0.208637 # The block of assembly that gets omitted is of the form: ----- 6:test.c **** array[N-1] = N; 40 .loc 1 6 0 41 0034 3D200000 lis 9,.LC0@ha 42 0038 39290010 la 9,.LC0@l(9) 43 003c 10090301 evldd 0,0(9) 44 0040 39207FF8 li 9,32760 45 0044 101F4B20 evstddx 0,31,9 ----- I haven't yet run the test with a later version of the cross compiler as configuring the tool chain is non-trivial and it may not be possible to upgrade for this particular product. But I will give it a go anyway.