This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: non-local goto optimization
Hi,
On Fri, 6 Jul 2007, Eric Botcazou wrote:
> What about renaming calls_unwind_init to saves_all_registers and have the
> following in reload?
>
> if (current_function_has_nonlocal_label && has_nonexceptional_receiver ())
> current_function_saves_all_registers = 1;
>
> if (current_function_saves_all_registers)
> 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);
I like that. :)
Retested on i686-linux, cross build of m68k-linux and I checked that all
register are saved now in unwind-dw2.o.
bye, Roman
200x-xx-xx Roman Zippel <zippel@linux-m68k.org>
* function.h (struct function): Rename calls_unwind_init
to saves_all_register.
(current_function_saves_all_register): Renamed from
current_function_calls_unwind_init.
* reload1.c (reload): Set current_function_saves_all_register.
* except.c (expand_builtin_unwind_init): Likewise.
* 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/except.c | 2 +-
gcc/function.h | 9 +++++----
gcc/reload1.c | 8 +++++---
5 files changed, 13 insertions(+), 10 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
@@ -408,9 +408,10 @@ struct function GTY(())
from nested functions. */
unsigned int has_nonlocal_label : 1;
- /* Nonzero if function calls builtin_unwind_init. */
- unsigned int calls_unwind_init : 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 function being compiled has nonlocal gotos to parent
function. */
unsigned int has_nonlocal_goto : 1;
@@ -515,7 +516,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_calls_unwind_init (cfun->calls_unwind_init)
+#define current_function_saves_all_register (cfun->saves_all_register)
#define current_function_has_nonlocal_goto (cfun->has_nonlocal_goto)
#define return_label (cfun->x_return_label)
Index: gcc/gcc/reload1.c
===================================================================
--- gcc.orig/gcc/reload1.c
+++ gcc/gcc/reload1.c
@@ -743,9 +743,11 @@ reload (rtx first, int global)
/* A function that has a nonlocal label that can reach the exit
block via non-exceptional paths must save all call-saved
registers. */
- if (current_function_calls_unwind_init
- || (current_function_has_nonlocal_label
- && has_nonexceptional_receiver ()))
+ if (current_function_has_nonlocal_label
+ && has_nonexceptional_receiver ())
+ current_function_saves_all_register = 1;
+
+ if (current_function_saves_all_register)
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);
Index: gcc/gcc/except.c
===================================================================
--- gcc.orig/gcc/except.c
+++ gcc/gcc/except.c
@@ -2863,7 +2863,7 @@ expand_builtin_unwind_init (void)
{
/* Set this so all the registers get saved in our frame; we need to be
able to copy the saved values for any registers from frames we unwind. */
- current_function_calls_unwind_init = 1;
+ current_function_saves_all_register = 1;
#ifdef SETUP_FRAME_ADDRESSES
SETUP_FRAME_ADDRESSES ();