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]

Enable -fomit-frame-pointer by default


Hi,
this patch enable omit-frame-pointer by default on i386 as discussed previously.  Just the i386.c
part cause regression on delayslot1.C testcase:

// PR target/12301
// Origin: Colin Hirsch <gcc@cohi.at>
// Testcase by Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de>

// This used to fail on SPARC because the reorg pass moved an insn
// across a function call that can throw internally, in order to put
// it in a delay slot.

// { dg-do run }
// { dg-options "-O" }

struct S{
  char *c;
  char data[100];
  S () : c (data) {};
  S (const S& s) {
    c = data;
    data[0] = s.c[0];
  }
};

S real_cast ()
{
  throw 3;  
}

S cast_helper(S& debug)
{
  try {
    return real_cast();
  }
  catch (int e) {
    throw debug;
  }
}

int main()
{
  S tmp;

  try {
    cast_helper (tmp);
  }                                        
  catch (S& e) {}

  return 0;
}

The problem is that reload misscompute ellimination offset of the EH landing pad.
It is apparently because it does not track the EH edges at all and because of code:

      /* If we know nothing about this label, set the desired offsets.  Note
	 that this sets the offset at a label to be the offset before a label
	 if we don't know anything about the label.  This is not correct for
	 the label after a BARRIER, but is the best guess we can make.  If
	 we guessed wrong, we will suppress an elimination that might have
	 been possible had we been able to guess correctly.  */

Reload really wants to make DFS walk of the CFG but the change is more involved
as the CFG is not up to date at the moment  (fixup_abnormal_edges has not beed
done yet) so I went for more conservative fix for now as I hope it will be
acceptable for 3.4 too.

Bootstrapped/regtested i686-pc-gnu-linux. OK?

2004-03-04  Jan Hubicka  <jh@suse.cz>
	* reload1.c (set_label_offsets): Follow EH edges.
	* i386.c (override_options): Enable -fomit-frame-pointer by default.
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.431
diff -c -3 -p -r1.431 reload1.c
*** reload1.c	3 Mar 2004 08:34:34 -0000	1.431
--- reload1.c	3 Mar 2004 23:40:25 -0000
*************** set_label_offsets (rtx x, rtx insn, int 
*** 2155,2162 ****
        /* Any labels mentioned in REG_LABEL notes can be branched to indirectly
  	 and hence must have all eliminations at their initial offsets.  */
        for (tem = REG_NOTES (x); tem; tem = XEXP (tem, 1))
! 	if (REG_NOTE_KIND (tem) == REG_LABEL)
! 	  set_label_offsets (XEXP (tem, 0), insn, 1);
        return;
  
      case PARALLEL:
--- 2155,2173 ----
        /* Any labels mentioned in REG_LABEL notes can be branched to indirectly
  	 and hence must have all eliminations at their initial offsets.  */
        for (tem = REG_NOTES (x); tem; tem = XEXP (tem, 1))
!         {
! 	  if (REG_NOTE_KIND (tem) == REG_LABEL)
! 	    set_label_offsets (XEXP (tem, 0), insn, 1);
! 	  if (REG_NOTE_KIND (tem) == REG_EH_REGION)
! 	    {
! 	      rtx handlers, i;
! 
! 	      handlers = reachable_handlers (insn);
! 
! 	      for (i = handlers; i; i = XEXP (i, 1))
! 		set_label_offsets (XEXP (i, 0), insn, 1);
! 	    }
! 	}
        return;
  
      case PARALLEL:
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.655
diff -c -3 -p -r1.655 i386.c
*** config/i386/i386.c	3 Mar 2004 08:34:49 -0000	1.655
--- config/i386/i386.c	3 Mar 2004 23:40:26 -0000
*************** override_options (void)
*** 1149,1160 ****
  
    int const pta_size = ARRAY_SIZE (processor_alias_table);
  
    /* Set the default values for switches whose default depends on TARGET_64BIT
       in case they weren't overwritten by command line options.  */
    if (TARGET_64BIT)
      {
-       if (flag_omit_frame_pointer == 2)
- 	flag_omit_frame_pointer = 1;
        if (flag_asynchronous_unwind_tables == 2)
  	flag_asynchronous_unwind_tables = 1;
        if (flag_pcc_struct_return == 2)
--- 1149,1160 ----
  
    int const pta_size = ARRAY_SIZE (processor_alias_table);
  
+   if (flag_omit_frame_pointer == 2)
+     flag_omit_frame_pointer = 1;
    /* Set the default values for switches whose default depends on TARGET_64BIT
       in case they weren't overwritten by command line options.  */
    if (TARGET_64BIT)
      {
        if (flag_asynchronous_unwind_tables == 2)
  	flag_asynchronous_unwind_tables = 1;
        if (flag_pcc_struct_return == 2)
*************** override_options (void)
*** 1162,1169 ****
      }
    else
      {
-       if (flag_omit_frame_pointer == 2)
- 	flag_omit_frame_pointer = 0;
        if (flag_asynchronous_unwind_tables == 2)
  	flag_asynchronous_unwind_tables = 0;
        if (flag_pcc_struct_return == 2)
--- 1162,1167 ----


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