[3.1 PATCH] Serious regression on s390

Ulrich Weigand weigand@immd1.informatik.uni-erlangen.de
Thu Apr 25 08:12:00 GMT 2002


[Re-sent from different address due to mail blocklist problems ...]

Hello Mark,

this patch fixes a serious regression introduced by a recent patch
to correctly handle global register variables:  if a fixed register
(e.g. the stack pointer) is defined as global register, it must be
restored in the epilog code anyway, otherwise we will crash.

I'm aware that it is questionable whether using a fixed register as
global register variable is allowed in the first place, but 
unfortunately existing code, in particular the libpthread library,
uses this trick to read the current value of the stack pointer.
To avoid breaking this, I'd like to add the following fix to 3.1.
(Otherwise all programs linked against a libpthread compiled with
3.1 will immediately crash.)

Mark, is this OK at this point?

Bye,
Ulrich

ChangeLog:

	* config/s390/s390.c (s390_emit_epilogue): Always restore fixed
	registers, even if they are used as global regs.


Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.27.2.6
diff -c -p -r1.27.2.6 s390.c
*** gcc/config/s390/s390.c	17 Apr 2002 15:59:45 -0000	1.27.2.6
--- gcc/config/s390/s390.c	25 Apr 2002 14:35:05 -0000
*************** s390_emit_epilogue ()
*** 3255,3261 ****
  	   i <= frame.last_save_gpr;
  	   i++)
  	{
! 	  if (global_regs[i])
  	    {
  	      addr = plus_constant (frame_pointer, 
  		     offset + i * UNITS_PER_WORD);
--- 3255,3261 ----
  	   i <= frame.last_save_gpr;
  	   i++)
  	{
! 	  if (global_regs[i] && !fixed_regs[i])
  	    {
  	      addr = plus_constant (frame_pointer, 
  		     offset + i * UNITS_PER_WORD);
-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de



More information about the Gcc-patches mailing list