This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to omit dwarf2 unwind info for leaves
- To: Andrew Haley <aph at pasanda dot cygnus dot co dot uk>
- Subject: Re: Patch to omit dwarf2 unwind info for leaves
- From: Jason Merrill <jason at cygnus dot com>
- Date: 09 Mar 2000 10:59:26 -0800
- Cc: gcc-patches at gcc dot gnu dot org
- References: <20000309093039.15190.qmail@pasanda.cygnus.co.uk>
This patch changes the behavior to depend on can_throw directly, for
greater precision.
2000-03-09 Jason Merrill <jason@casey.cygnus.com>
* except.c (can_throw): See through a SEQUENCE.
(nothrow_function_p): New fn.
* except.h: Declare it.
* function.c (current_function_nothrow): New var.
(prepare_function_start): Initialize it.
* output.h: Declare it.
* toplev.c (rest_of_compilation): Set it.
* dwarf2out.c (dwarf2out_begin_prologue): Use it.
Index: except.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/except.c,v
retrieving revision 1.120
diff -c -p -r1.120 except.c
*** except.c 2000/03/08 21:30:17 1.120
--- except.c 2000/03/09 18:29:07
*************** expand_fixup_region_end (cleanup)
*** 1646,1662 ****
}
/* If we are using the setjmp/longjmp EH codegen method, we emit a
! call to __sjthrow.
- Otherwise, we emit a call to __throw and note that we threw
- something, so we know we need to generate the necessary code for
- __throw.
-
- Before invoking throw, the __eh_pc variable must have been set up
- to contain the PC being thrown from. This address is used by
- __throw to determine which exception region (if any) is
- responsible for handling the exception. */
-
void
emit_throw ()
{
--- 1646,1653 ----
}
/* If we are using the setjmp/longjmp EH codegen method, we emit a
! call to __sjthrow. Otherwise, we emit a call to __throw. */
void
emit_throw ()
{
*************** static int
*** 2629,2634 ****
--- 2620,2629 ----
can_throw (insn)
rtx insn;
{
+ if (GET_CODE (insn) == INSN
+ && GET_CODE (PATTERN (insn)) == SEQUENCE)
+ insn = XVECEXP (PATTERN (insn), 0, 0);
+
/* Calls can always potentially throw exceptions, unless they have
a REG_EH_REGION note with a value of 0 or less. */
if (GET_CODE (insn) == CALL_INSN)
*************** can_throw (insn)
*** 2647,2652 ****
--- 2642,2665 ----
}
return 0;
+ }
+
+ /* Return nonzero if nothing in this function can throw. */
+
+ int
+ nothrow_function_p ()
+ {
+ rtx insn;
+
+ for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
+ if (can_throw (insn))
+ return 0;
+ for (insn = current_function_epilogue_delay_list; insn;
+ insn = XEXP (insn, 1))
+ if (can_throw (insn))
+ return 0;
+
+ return 1;
}
/* Scan a exception region looking for the matching end and then
Index: except.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/except.h,v
retrieving revision 1.37
diff -c -p -r1.37 except.h
*** except.h 2000/02/26 06:04:48 1.37
--- except.h 2000/03/09 18:29:08
*************** extern struct label_node *outer_context_
*** 427,432 ****
--- 427,436 ----
extern rtx exception_handler_labels;
+ /* Return nonzero if nothing in this function can throw. */
+
+ extern int nothrow_function_p PARAMS ((void));
+
/* Performs optimizations for exception handling, such as removing
unnecessary exception regions. Invoked from jump_optimize (). */
Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.172
diff -c -p -r1.172 function.c
*** function.c 2000/03/06 09:50:16 1.172
--- function.c 2000/03/09 18:29:12
*************** Boston, MA 02111-1307, USA. */
*** 107,112 ****
--- 107,117 ----
compiler passes. */
int current_function_is_leaf;
+ /* Nonzero if function being compiled doesn't contain any instructions
+ that can throw an exception. This is set prior to final. */
+
+ int current_function_nothrow;
+
/* Nonzero if function being compiled doesn't modify the stack pointer
(ignoring the prologue and epilogue). This is only valid after
life_analysis has run. */
*************** prepare_function_start ()
*** 5760,5765 ****
--- 5765,5771 ----
current_function_calls_alloca = 0;
current_function_contains_functions = 0;
current_function_is_leaf = 0;
+ current_function_nothrow = 0;
current_function_sp_is_unchanging = 0;
current_function_uses_only_leaf_regs = 0;
current_function_has_computed_jump = 0;
Index: output.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/output.h,v
retrieving revision 1.44
diff -c -p -r1.44 output.h
*** output.h 2000/03/07 20:39:05 1.44
--- output.h 2000/03/09 18:29:13
*************** extern FILE *asm_out_file;
*** 412,417 ****
--- 412,422 ----
extern int current_function_is_leaf;
+ /* Nonzero if function being compiled doesn't contain any instructions
+ that can throw an exception. This is set prior to final. */
+
+ extern int current_function_nothrow;
+
/* Nonzero if function being compiled doesn't modify the stack pointer
(ignoring the prologue and epilogue). This is only valid after
life_analysis has run. */
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.300
diff -c -p -r1.300 toplev.c
*** toplev.c 2000/03/07 20:39:05 1.300
--- toplev.c 2000/03/09 18:29:16
*************** rest_of_compilation (decl)
*** 3674,3682 ****
print_rtl_graph_with_bb (dump_base_name, ".20.stack", insns);
}
! if (ggc_p)
! ggc_collect ();
#endif
/* Now turn the rtl into assembler code. */
--- 3674,3684 ----
print_rtl_graph_with_bb (dump_base_name, ".20.stack", insns);
}
! if (ggc_p)
! ggc_collect ();
#endif
+
+ current_function_nothrow = nothrow_function_p ();
/* Now turn the rtl into assembler code. */
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.159
diff -c -p -r1.159 dwarf2out.c
*** dwarf2out.c 2000/03/08 23:05:30 1.159
--- dwarf2out.c 2000/03/09 18:29:22
*************** dwarf2out_begin_prologue ()
*** 1890,1897 ****
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;
}
--- 1890,1896 ----
fde->dw_fde_end = NULL;
fde->dw_fde_cfi = NULL;
! fde->nothrow = current_function_nothrow;
args_size = old_args_size = 0;
}