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]

Re: non-local goto optimization


Hi,

On Mon, 21 May 2007, Nathan Sidwell wrote:

> Eric Botcazou wrote:
> > > Do you have another suggestion as to how to do this?  I don't see one that
> > > is immediately obvious beyond having expand_builtin_unwind set a global.
> > 
> > Yes, that's a bit annoying.  I can think of a few hacks (setting/clearing
> > TREE_USED on the DECL of BUILT_IN_UNWIND_INIT) but it's a bit extreme.
> > 
> > So it seems that we really need a new flag in struct function after all.
> > But I would rather name it "calls_unwind_init" like a few others and invoke
> > the new has_nonexceptional_receiver predicate directly from reload.

This change screwed exception handling on m68k, m68k uses 
current_function_has_nonlocal_label to save the pic register. Since the 
condition in reload() changed, it's not set anymore in all cases.
I could now just update the condition or I could fix this once and for all 
and introduce a flag which tells the back end explicitly when to save 
additional fixed register in this case.

Bootstrapped and tested on i686-linux.

bye, Roman

200x-xx-xx  Roman Zippel <zippel@linux-m68k.org>

	* function.h (struct function): Add saves_all_register.
	(current_function_saves_all_register): New.
	* reload1.c (reload): Set current_function_saves_all_register.
	* config/i386/i386.c (ix86_save_reg): Use
	current_function_saves_all_register to save pic register.
	* config/m68k/m68k.c (m68k_save_reg): Likewise.


---
 gcc/config/i386/i386.c |    2 +-
 gcc/config/m68k/m68k.c |    2 +-
 gcc/function.h         |    5 +++++
 gcc/reload1.c          |    9 ++++++---
 4 files changed, 13 insertions(+), 5 deletions(-)

Index: gcc/gcc/config/i386/i386.c
===================================================================
--- gcc.orig/gcc/config/i386/i386.c
+++ gcc/gcc/config/i386/i386.c
@@ -5604,7 +5604,7 @@ ix86_save_reg (unsigned int regno, int m
       && regno == REAL_PIC_OFFSET_TABLE_REGNUM
       && (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM)
 	  || current_function_profile
-	  || current_function_calls_eh_return
+	  || current_function_saves_all_register
 	  || current_function_uses_const_pool))
     {
       if (ix86_select_alt_pic_regnum () != INVALID_REGNUM)
Index: gcc/gcc/config/m68k/m68k.c
===================================================================
--- gcc.orig/gcc/config/m68k/m68k.c
+++ gcc/gcc/config/m68k/m68k.c
@@ -769,7 +769,7 @@ m68k_save_reg (unsigned int regno, bool 
     {
       /* A function that receives a nonlocal goto must save all call-saved
 	 registers.  */
-      if (current_function_has_nonlocal_label)
+      if (current_function_saves_all_register)
 	return true;
       if (current_function_uses_pic_offset_table)
 	return true;
Index: gcc/gcc/function.h
===================================================================
--- gcc.orig/gcc/function.h
+++ gcc/gcc/function.h
@@ -415,6 +415,10 @@ struct function GTY(())
      function.  */
   unsigned int has_nonlocal_goto : 1;
 
+  /* Nonzero if function saves all registers, e.g. if it has a nonlocal
+     label that can reach the exit block via non-exceptional paths. */
+  unsigned int saves_all_register : 1;
+
   /* Nonzero if the current function is a thunk, i.e., a lightweight
      function implemented by the output_mi_thunk hook) that just
      adjusts one of its arguments and forwards to another
@@ -515,6 +519,7 @@ extern int trampolines_created;
 #define current_function_uses_const_pool (cfun->uses_const_pool)
 #define current_function_epilogue_delay_list (cfun->epilogue_delay_list)
 #define current_function_has_nonlocal_label (cfun->has_nonlocal_label)
+#define current_function_saves_all_register (cfun->saves_all_register)
 #define current_function_calls_unwind_init (cfun->calls_unwind_init)
 #define current_function_has_nonlocal_goto (cfun->has_nonlocal_goto)
 
Index: gcc/gcc/reload1.c
===================================================================
--- gcc.orig/gcc/reload1.c
+++ gcc/gcc/reload1.c
@@ -746,9 +746,12 @@ reload (rtx first, int global)
   if (current_function_calls_unwind_init
       || (current_function_has_nonlocal_label
 	  && has_nonexceptional_receiver ()))
-    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-      if (! call_used_regs[i] && ! fixed_regs[i] && ! LOCAL_REGNO (i))
-	df_set_regs_ever_live (i, true);
+    {
+      current_function_saves_all_register = 1;
+      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+	if (!call_used_regs[i] && !fixed_regs[i] && !LOCAL_REGNO (i))
+	  df_set_regs_ever_live (i, true);
+    }
 
   /* Find all the pseudo registers that didn't get hard regs
      but do have known equivalent constants or memory slots.


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