Bug 12538 - %l7 is call-clobbered with -mflat -fpic
Summary: %l7 is call-clobbered with -mflat -fpic
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.0
Assignee: Eric Botcazou
Depends on:
Reported: 2003-10-08 09:38 UTC by Fergus Henderson
Modified: 2003-10-13 10:01 UTC (History)
1 user (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work:
Known to fail:
Last reconfirmed: 2003-10-09 07:40:47

test case part 1 (126 bytes, text/plain)
2003-10-08 09:40 UTC, Fergus Henderson
test case part 2: x.c (144 bytes, text/plain)
2003-10-08 09:42 UTC, Fergus Henderson
test case part 3: y.c (140 bytes, text/plain)
2003-10-08 09:42 UTC, Fergus Henderson

Note You need to log in before you can comment on or make changes to this bug.
Description Fergus Henderson 2003-10-08 09:38:24 UTC
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.
Comment 1 Fergus Henderson 2003-10-08 09:40:55 UTC
Created attachment 4898 [details]
test case part 1
Comment 2 Fergus Henderson 2003-10-08 09:42:06 UTC
Created attachment 4899 [details]
test case part 2: x.c
Comment 3 Fergus Henderson 2003-10-08 09:42:40 UTC
Created attachment 4900 [details]
test case part 3: y.c
Comment 4 Andrew Pinski 2003-10-08 15:29:13 UTC
Can you try 3.3.1 as 3.2 is old?
Comment 5 Eric Botcazou 2003-10-09 07:40:47 UTC
Confirmed with all GCC versions I tested.
Comment 6 GCC Commits 2003-10-13 09:57:57 UTC
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.


Comment 7 Eric Botcazou 2003-10-13 10:01:47 UTC
Fixed for GCC 3.4, see http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00889.html