This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] S/390: fix usage of save_return_addr_p


Hi,

with the recent introduction of regs_ever_clobbered in the s390 back end
it may happen that s390_can_eliminate returns different values before and
after reload for the return address pointer. This caused an ICE in reload.

The problem is that the save_return_addr_p flag depends on the 
regs_ever_clobbered array which in turn is used in s390_can_eliminate to
decide whether the return address pointer can be eliminated. Hence
whenever reload uses r14 that flag changes as well as the possibility to
eliminate the return address pointer.

The attached patch uncouples save_return_addr_p and regs_ever_clobbered
in one direction. save_return_addr_p is not set anymore if regs_ever_clobbered
changes.

Now the save_return_addr_p flag is only set if we need to preserve a stack slot for
r14, the current function calls builtin_return_address(0) and we are on a esa mode
system what makes it necessary to use r14 in the branch/literal pool splitting
code.

Bootstrapped and testsuite run without regressions on s390 and s390x.

OK for mainline?

Bye,

-Andreas-


2005-08-11  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.c (s390_split_branches, s390_init_frame_layout): 
	Don't set save_return_addr_p.
	(s390_register_info): Make clobbered_regs not depending on
	save_return_addr_p.
	

Index: gcc-4.1/gcc/config/s390/s390.c
===================================================================
--- gcc-4.1.orig/gcc/config/s390/s390.c	2005-08-11 12:38:04.000000000 +0200
+++ gcc-4.1/gcc/config/s390/s390.c	2005-08-11 13:29:15.000000000 +0200
@@ -224,7 +224,10 @@ struct s390_frame_layout GTY (())
   /* Number of floating point registers f8-f15 which must be saved.  */
   int high_fprs;
 
-  /* Set if return address needs to be saved.  */
+  /* Set if return address needs to be saved.
+     This flag is set by s390_return_addr_rtx if it could not use
+     the initial value of r14 and therefore depends on r14 saved
+     to the stack.  */
   bool save_return_addr_p;
 
   /* Size of stack frame.  */
@@ -4405,10 +4408,6 @@ s390_split_branches (void)
       if (get_attr_length (insn) <= 4)
 	continue;
 
-      /* We are going to use the return register as scratch register,
-	 make sure it will be saved/restored by the prologue/epilogue.  */
-      cfun_frame_layout.save_return_addr_p = 1;
-
       if (!flag_pic)
 	{
 	  new_literal = 1;
@@ -5818,8 +5817,12 @@ s390_register_info (int clobbered_regs[]
       && REGNO (cfun->machine->base_reg) == BASE_REGNUM;
 
   clobbered_regs[RETURN_REGNUM]
-    = cfun->machine->split_branches_pending_p
-      || cfun_frame_layout.save_return_addr_p;
+    |= (cfun->machine->split_branches_pending_p
+	|| cfun_frame_layout.save_return_addr_p
+	|| TARGET_TPF_PROFILING
+	|| !current_function_is_leaf
+	|| current_function_stdarg
+	|| current_function_calls_eh_return);
 
   clobbered_regs[STACK_POINTER_REGNUM]
     = !current_function_is_leaf
@@ -6021,13 +6024,6 @@ s390_init_frame_layout (void)
   /* If return address register is explicitly used, we need to save it.  */
   s390_regs_ever_clobbered (clobbered_regs);
 
-  if (clobbered_regs[RETURN_REGNUM]
-      || !current_function_is_leaf
-      || TARGET_TPF_PROFILING
-      || current_function_stdarg
-      || current_function_calls_eh_return)
-    cfun_frame_layout.save_return_addr_p = true;
-
   /* On S/390 machines, we may need to perform branch splitting, which
      will require both base and return address register.  We have no
      choice but to assume we're going to need them until right at the


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]