RFA: Make IRA set current_function_is_leaf earlier

Richard Sandiford rdsandiford@googlemail.com
Sun Jan 4 21:44:00 GMT 2009


On some targets, FRAME_POINTER_REQUIRED needs to know whether the
function is a leaf function.  This was OK with the old allocator,
which set current_function_is_leaf before testing FRAME_POINTER_REQUIRED,
but IRA does it the other way around.  This caused a regression in
"gcc.c-torture/execute/pr20621-1.c compilation, -O1" on
mips64el-linux-gnu with -mabi=32/-mips16.

Local alloc had:

  regstat_init_n_sets_and_refs ();
  regstat_compute_ri ();

  /* If we are not optimizing, then this is the only place before
     register allocation where dataflow is done.  And that is needed
     to generate these warnings.  */
  if (warn_clobbered)
    generate_setjmp_warnings ();

  /* Determine if the current function is a leaf before running reload
     since this can impact optimizations done by the prologue and
     epilogue thus changing register elimination offsets.  */
  current_function_is_leaf = leaf_function_p ();

and all but the last statement are the same in IRA.  I couldn't see
any fundamental reason for not keeping the last statement here too.

Tested on mips64el-linux-gnu.  OK to apply?

Richard


gcc/
	* ira.c (ira): Set current_function_is_leaf earlier.

Index: gcc/ira.c
===================================================================
--- gcc/ira.c	2009-01-03 15:59:15.000000000 +0000
+++ gcc/ira.c	2009-01-03 16:02:58.000000000 +0000
@@ -1874,6 +1874,11 @@ ira (FILE *f)
   if (warn_clobbered)
     generate_setjmp_warnings ();
 
+  /* Determine if the current function is a leaf before running IRA
+     since this can impact optimizations done by the prologue and
+     epilogue thus changing register elimination offsets.  */
+  current_function_is_leaf = leaf_function_p ();
+
   rebuild_p = update_equiv_regs ();
 
 #ifndef IRA_NO_OBSTACK
@@ -1970,11 +1975,6 @@ ira (FILE *f)
   delete_trivially_dead_insns (get_insns (), max_reg_num ());
   max_regno = max_reg_num ();
   
-  /* Determine if the current function is a leaf before running IRA
-     since this can impact optimizations done by the prologue and
-     epilogue thus changing register elimination offsets.  */
-  current_function_is_leaf = leaf_function_p ();
-  
   /* And the reg_equiv_memory_loc array.  */
   VEC_safe_grow (rtx, gc, reg_equiv_memory_loc_vec, max_regno);
   memset (VEC_address (rtx, reg_equiv_memory_loc_vec), 0,



More information about the Gcc-patches mailing list