Patch to omit dwarf2 unwind info for leaves

Jason Merrill jason@cygnus.com
Wed Mar 8 15:04:00 GMT 2000


There's no reason to emit unwind information for leaf functions, since
only calls can throw.

2000-03-08  Jason Merrill  <jason@casey.cygnus.com>

	* dwarf2out.c (dw_fde_struct): Add 'nothrow'.
	(dwarf2out_begin_prologue): Set it.
	(output_call_frame_info): Don't emit EH unwind info for leaves.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.158
diff -c -p -r1.158 dwarf2out.c
*** dwarf2out.c	2000/03/05 22:25:36	1.158
--- dwarf2out.c	2000/03/08 22:58:56
*************** typedef struct dw_fde_struct
*** 129,134 ****
--- 129,135 ----
    char *dw_fde_current_label;
    char *dw_fde_end;
    dw_cfi_ref dw_fde_cfi;
+   int nothrow;
  }
  dw_fde_node;
  
*************** output_call_frame_info (for_eh)
*** 1624,1629 ****
--- 1625,1641 ----
    /* Do we want to include a pointer to the exception table?  */
    int eh_ptr = for_eh && exception_table_p ();
  
+   /* If we don't have any functions we'll want to unwind out of, don't
+      emit any EH unwind information.  */
+   if (for_eh)
+     {
+       for (i = 0; i < fde_table_in_use; ++i)
+ 	if (! fde_table[i].nothrow)
+ 	  goto found;
+       return;
+     found:;
+     }
+ 
    fputc ('\n', asm_out_file);
  
    /* We're going to be generating comments, so turn on app.  */
*************** output_call_frame_info (for_eh)
*** 1756,1761 ****
--- 1768,1777 ----
      {
        fde = &fde_table[i];
  
+       /* Don't emit EH unwind info for leaf functions.  */
+       if (for_eh && fde->nothrow)
+ 	continue;
+ 
        ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i*2);
        ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + i*2);
  #ifdef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
*************** dwarf2out_begin_prologue ()
*** 1873,1878 ****
--- 1889,1897 ----
    fde->dw_fde_current_label = NULL;
    fde->dw_fde_end = NULL;
    fde->dw_fde_cfi = NULL;
+ 
+   /* Normally, only calls can throw, so a leaf function will never throw.  */
+   fde->nothrow = (current_function_is_leaf && !asynchronous_exceptions);
  
    args_size = old_args_size = 0;
  }


More information about the Gcc-patches mailing list