The attached source files demonstrate a bug with gcc-2.95.1 and gcc 3.2 on SPARCs. The bug is that if you compile one file with no special options (or with just `-mflat', or just `-fpic', but not both), and another file with `-mflat -fpic', and link the two together, then in the file compiled with no special options it treats register l7 as a callee-save register, but in the file compiled with `-mflat -fpic' it clobbers register l7 without saving it. The attached program should output "1,2,3,4,5,6,7,8,9,10", but on my system the program gets a Segmentation Fault instead.
Created attachment 4898 [details] test case part 1
Created attachment 4899 [details] test case part 2: x.c
Created attachment 4900 [details] test case part 3: y.c
Can you try 3.3.1 as 3.2 is old?
Confirmed with all GCC versions I tested.
Subject: Bug 12538 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2003-10-13 09:57:53 Modified files: gcc : ChangeLog gcc/config/sparc: sparc.c Log message: PR target/12538 * config/sparc/sparc.c (MUST_SAVE_REGISTER): Delete. (sparc_flat_must_save_register_p): New function to decide whether a register must be saved/restored in the function prologue/epilogue. (sparc_flat_compute_frame_size): Use it instead of MUST_SAVE_REGISTER. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1398&r2=2.1399 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sparc/sparc.c.diff?cvsroot=gcc&r1=1.263&r2=1.264
Fixed for GCC 3.4, see http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00889.html