http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49207
Summary: Instruction scheduling error in GCC mips
cross-compiler
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: ha...@ece.ubc.ca
When compiling a testbench program using -O2 optimization, the GCC MIPS
cross-compiler generates an incorrect instruction sequence (a store before a
load to the same memory location) which leads to a memory corruption problem
and crashes the program. If the -O1 or -O0 switches are used, this problem does
not occur.
The output of the gcc -v -save-temps command is included below and the test.i
file is attached. I am also including, below, the portion of assembly code that
contains the erroneous instruction sequence (see arrows).
/mnt/disk/home/tools/mipsel/bin/mipsel-linux-gcc -v -save-temps -O2 -static
-DSPEC_CPU_LINUX_IA32 test.o -lm-o perlbench
Using built-in specs.
Target: mipsel-linux
Configured with: ../../src/gcc-4.4.3/configure --target=mipsel-linux
--prefix=/mnt/disk/home/tools/mipsel --with-sysroot=/mnt/disk/home/tools/mipsel
--disable-libssp --disable-libgomp --disable-libmudflap --disable-nls
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.4.3 (GCC)
COMPILER_PATH=/mnt/disk/home/tools/mipsel/libexec/gcc/mipsel-linux/4.4.3/:/mnt/disk/home/tools/mipsel/libexec/gcc/mipsel-linux/4.4.3/:/mnt/disk/home/tools/mipsel/libexec/gcc/mipsel-linux/:/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/:/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/:/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/../../../../mipsel-linux/bin/
LIBRARY_PATH=/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/:/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/../../../../mipsel-linux/lib/:/mnt/disk/home/tools/mipsel/lib/:/mnt/disk/home/tools/mipsel/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O2' '-static' '-DSPEC_CPU_LINUX_IA32'
'-o' 'perlbench' '-mllsc' '-mno-shared'
/mnt/disk/home/tools/mipsel/libexec/gcc/mipsel-linux/4.4.3/collect2
--sysroot=/mnt/disk/home/tools/mipsel -EL -static -o perlbench
/mnt/disk/home/tools/mipsel/usr/lib/crt1.o
/mnt/disk/home/tools/mipsel/usr/lib/crti.o
/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/crtbeginT.o
-L/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3
-L/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/../../../../mipsel-linux/lib
-L/mnt/disk/home/tools/mipsel/lib -L/mnt/disk/home/tools/mipsel/usr/lib test.o
-lm --start-group -lgcc -lgcc_eh -lc --end-group
/mnt/disk/home/tools/mipsel/lib/gcc/mipsel-linux/4.4.3/crtend.o
/mnt/disk/home/tools/mipsel/usr/lib/crtn.o
/mnt/disk/home/tools/mipsel/usr/lib/crt1.o: In function `__start':
>>> assembly code
$L100:
lw$3,%got(PL_xiv_root)($28)
lw$2,0($16)
lw$5,0($3)
addiu$4,$2,12
sw $5,12($2)
lw $19,12($2)
li$2,2# 0x2
beq$17,$2,$L184
sw$4,0($3)
beq$18,$0,$L111
nop
move$20,$0
move$21,$0
move$18,$0