jonathan@comp.vuw.ac.nz (09/01/89)
Summary:
Beta-test gcc does not adhere to alignment constraints
on Pyramids.
Version:
gcc 1.35.96, gcc 1.35.97
Hardware:
Pyramid 90x family.
Description:
The following program (abstracted from genflags.c) will
dump core with a signal 4 (bus error) when compiled with -O.
The other seven gen*.cprograms exhibit the same problem.
Therefore, gcc no longer bootstraps on Pyramids.
#include <stdio.h>
main ()
{
exit (ferror (stdout) != 0 ? 5 : 7);
}
Assembler output from 1.35.97 with -O:
gcc_compiled.:
.text
.align 2
.globl _main
_main:
adsf $0
movw $0,pr1
movw __iob+34,pr0
andw $32,pr0
cvthw pr0,pr0
beq L4
movw $1,pr1
L4:
mtstw pr1,pr1
beq L2
movw $5,pr0
jump L3
L2:
movw $7,pr0
L3:
movw pr0,tr0
call _exit
retd $0x0
Assembler output from 1.35.97 without -O:
gcc_compiled.:
.text
.align 2
.globl _main
_main:
adsf $0
movw $0,pr0
cvthw __iob+36,pr1
andw $32,pr1
cvthw pr1,pr1
movw $0,pr2
cmpw pr2,pr1
beq L4
movw $1,pr0
L4:
mtstw pr0,pr0
beq L2
movw $5,pr0
jump L3
L2:
movw $7,pr0
L3:
movw pr0,tr0
call _exit
L1:
retd $0x0
Assembler output from 1.35 release (built with a slightly buggier md) with -O:
#NO_APP
gcc_compiled.:
.text
.align 2
.globl _main
_main:
adsf $0
movw $0,pr1
cvthw __iob+36,pr0
andw $32,pr0
mtstw pr0,pr0
beq L4
movw $1,pr1
L4:
mtstw pr1,pr1
beq L2
movw $5,pr0
jump L3
L2:
movw $7,pr0
L3:
movw pr0,tr0
call _exit
retd $0x0
Wild guesses as to what's wrong:
Compiling without -O produces correct results.
Examination of a core file with gdb reveals that __iob+34
is aligned on a 16-bit boundary, but not a 32-bit boundary.
Pyramids require 32-bit operands to be aligned on a 32-bit boundary.
GCC is not doing so, even though the machine description defines
STRICT_ALIGNMENT.
I haven't gone through all the compiler dump files to determine
which pass is causing this problem.
I can't see anything in gcc.texinfo where handling of alignment
has changed; has it?