Commit e701eb4d by Jason Merrill Committed by Jason Merrill

./: * libgcc2.c (__throw): Use __builtin_return_addr instead of __eh_pc.

	* except.c: Lose outer_context_label_stack.
 	(expand_eh_region_end): Rethrow from outer_context here.
	(expand_fixup_region_end): Let expand_eh_region_end do the rethrow.
	(expand_internal_throw): Take no args.
	(expand_internal_throw_indirect): Lose.
	(expand_leftover_cleanups, expand_start_all_catch): Use expand_rethrow.
	(expand_start_all_catch): Start a rethrow region.
	(expand_end_all_catch): End it.
	(expand_rethrow): New fn.
	* except.h: Reflect above changes.

cp/:	* except.c (expand_end_catch_block): Lose rethrow region.
	(expand_start_catch_block): Likewise.
	(expand_end_catch_block): Don't expand_leftover_cleanups.

From-SVN: r16937
parent a1e343dd
Wed Dec 3 12:01:56 1997 Jason Merrill <jason@yorick.cygnus.com>
* libgcc2.c (__throw): Use __builtin_return_addr instead of __eh_pc.
* except.c: Lose outer_context_label_stack.
(expand_eh_region_end): Rethrow from outer_context here.
(expand_fixup_region_end): Let expand_eh_region_end do the rethrow.
(expand_internal_throw): Take no args.
(expand_internal_throw_indirect): Lose.
(expand_leftover_cleanups, expand_start_all_catch): Use expand_rethrow.
(expand_start_all_catch): Start a rethrow region.
(expand_end_all_catch): End it.
(expand_rethrow): New fn.
* except.h: Reflect above changes.
* flow.c: Revert change of Nov 27.
Thu Dec 4 00:24:09 1997 Jeffrey A Law (law@cygnus.com) Thu Dec 4 00:24:09 1997 Jeffrey A Law (law@cygnus.com)
* i386/t-sol2 (CRTSTUFF_T_CFLAGS): Turn on the optimizer. * i386/t-sol2 (CRTSTUFF_T_CFLAGS): Turn on the optimizer.
......
...@@ -280,7 +280,7 @@ LIBGCC2 = libgcc2.a ...@@ -280,7 +280,7 @@ LIBGCC2 = libgcc2.a
# #
# -fexceptions is necessary for eh.o now that the exceptions are # -fexceptions is necessary for eh.o now that the exceptions are
# the default for g++ only. # the default for g++ only.
LIBGCC2_DEBUG_CFLAGS = -g1 LIBGCC2_DEBUG_CFLAGS = -g
LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -fexceptions @inhibit_libc@ LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -fexceptions @inhibit_libc@
# Additional options to use when compiling libgcc2.a. # Additional options to use when compiling libgcc2.a.
......
Wed Dec 3 20:02:39 1997 Jason Merrill <jason@yorick.cygnus.com>
* except.c (expand_end_catch_block): Lose rethrow region.
(expand_start_catch_block): Likewise.
(expand_end_catch_block): Don't expand_leftover_cleanups.
Wed Dec 3 13:24:04 1997 Benjamin Kosnik <bkoz@rhino.cygnus.com> Wed Dec 3 13:24:04 1997 Benjamin Kosnik <bkoz@rhino.cygnus.com>
* pt.c (tsubst): Remove tree_cons call (places redundant info into * pt.c (tsubst): Remove tree_cons call (places redundant info into
......
...@@ -185,10 +185,13 @@ static tree Unwind; ...@@ -185,10 +185,13 @@ static tree Unwind;
========================================================================= */ ========================================================================= */
#ifndef DWARF2_UNWIND_INFO
/* Holds the pc for doing "throw" */ /* Holds the pc for doing "throw" */
static tree saved_pc; static tree saved_pc;
extern int throw_used; extern int throw_used;
#endif
extern rtx catch_clauses; extern rtx catch_clauses;
extern tree const_ptr_type_node; extern tree const_ptr_type_node;
...@@ -255,12 +258,14 @@ init_exception_processing () ...@@ -255,12 +258,14 @@ init_exception_processing ()
pop_lang_context (); pop_lang_context ();
#ifndef DWARF2_UNWIND_INFO
d = build_decl (VAR_DECL, get_identifier ("__eh_pc"), ptr_type_node); d = build_decl (VAR_DECL, get_identifier ("__eh_pc"), ptr_type_node);
TREE_PUBLIC (d) = 1; TREE_PUBLIC (d) = 1;
DECL_EXTERNAL (d) = 1; DECL_EXTERNAL (d) = 1;
DECL_ARTIFICIAL (d) = 1; DECL_ARTIFICIAL (d) = 1;
cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0); cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
saved_pc = d; saved_pc = d;
#endif
/* If we use setjmp/longjmp EH, arrange for all cleanup actions to /* If we use setjmp/longjmp EH, arrange for all cleanup actions to
be protected with __terminate. */ be protected with __terminate. */
...@@ -520,17 +525,6 @@ expand_start_catch_block (declspecs, declarator) ...@@ -520,17 +525,6 @@ expand_start_catch_block (declspecs, declarator)
if (! doing_eh (1)) if (! doing_eh (1))
return; return;
/* If we are not doing setjmp/longjmp EH, because we are reordered
out of line, we arrange to rethrow in the outer context so as to
skip through the terminate region we are nested in, should we
encounter an exception in the catch handler. We also need to do
this because we are not physically within the try block, if any,
that contains this catch block.
Matches the end in expand_end_catch_block. */
if (! exceptions_via_longjmp)
expand_eh_region_start ();
/* Create a binding level for the eh_info and the exception object /* Create a binding level for the eh_info and the exception object
cleanup. */ cleanup. */
pushlevel (0); pushlevel (0);
...@@ -655,36 +649,11 @@ expand_end_catch_block () ...@@ -655,36 +649,11 @@ expand_end_catch_block ()
expand_end_bindings (getdecls (), kept_level_p (), 0); expand_end_bindings (getdecls (), kept_level_p (), 0);
poplevel (kept_level_p (), 1, 0); poplevel (kept_level_p (), 1, 0);
if (! exceptions_via_longjmp)
{
/* If we are not doing setjmp/longjmp EH, we need an extra
region around the whole catch block to skip through the
terminate region we are nested in. */
tree t = make_node (RTL_EXPR);
TREE_TYPE (t) = void_type_node;
RTL_EXPR_RTL (t) = const0_rtx;
TREE_SIDE_EFFECTS (t) = 1;
do_pending_stack_adjust ();
start_sequence_for_rtl_expr (t);
expand_internal_throw (outer_context_label_stack->u.rlabel);
do_pending_stack_adjust ();
RTL_EXPR_SEQUENCE (t) = get_insns ();
end_sequence ();
/* For the rethrow region. */
expand_eh_region_end (t);
}
/* Fall to outside the try statement when done executing handler and /* Fall to outside the try statement when done executing handler and
we fall off end of handler. This is jump Lresume in the we fall off end of handler. This is jump Lresume in the
documentation. */ documentation. */
expand_goto (top_label_entry (&caught_return_label_stack)); expand_goto (top_label_entry (&caught_return_label_stack));
expand_leftover_cleanups ();
/* label we emit to jump to if this catch block didn't match. */ /* label we emit to jump to if this catch block didn't match. */
/* This the closing } in the `if (eq) {' of the documentation. */ /* This the closing } in the `if (eq) {' of the documentation. */
emit_label (pop_label_entry (&false_label_stack)); emit_label (pop_label_entry (&false_label_stack));
...@@ -1318,18 +1287,7 @@ expand_throw (exp) ...@@ -1318,18 +1287,7 @@ expand_throw (exp)
expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL); expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL);
} }
if (exceptions_via_longjmp) expand_internal_throw ();
emit_throw ();
else
{
/* This is the label that represents where in the code we were, when
we got an exception. This needs to be updated when we rethrow an
exception, so that the matching routine knows to search out. */
label = gen_label_rtx ();
emit_label (label);
expand_internal_throw (label);
}
} }
/* Build a throw expression. */ /* Build a throw expression. */
......
...@@ -192,10 +192,9 @@ extern void add_partial_entry PROTO((tree handler)); ...@@ -192,10 +192,9 @@ extern void add_partial_entry PROTO((tree handler));
extern void end_protect_partials PROTO((void)); extern void end_protect_partials PROTO((void));
/* An internal throw with a direct CONTEXT we want to throw /* An internal throw. */
from. CONTEXT must be a label. */
extern void expand_internal_throw PROTO((rtx context)); extern void expand_internal_throw PROTO((void));
/* Called from expand_exception_blocks and expand_end_catch_block to /* Called from expand_exception_blocks and expand_end_catch_block to
expand and pending handlers. */ expand and pending handlers. */
...@@ -227,11 +226,6 @@ extern void check_exception_handler_labels PROTO((void)); ...@@ -227,11 +226,6 @@ extern void check_exception_handler_labels PROTO((void));
extern struct label_node *caught_return_label_stack; extern struct label_node *caught_return_label_stack;
/* Keeps track of the label used as the context of a throw to rethrow an
exception to the outer exception region. */
extern struct label_node *outer_context_label_stack;
/* A random area used for purposes elsewhere. */ /* A random area used for purposes elsewhere. */
extern struct label_node *false_label_stack; extern struct label_node *false_label_stack;
......
...@@ -472,15 +472,10 @@ find_basic_blocks (f, nonlocal_label_list) ...@@ -472,15 +472,10 @@ find_basic_blocks (f, nonlocal_label_list)
/* If we encounter a CALL_INSN, note which exception handler it /* If we encounter a CALL_INSN, note which exception handler it
might pass control to. might pass control to.
Because we do rethrows by loading the address of a label into
__eh_pc and throwing, we need to treat labels as potentially
jumping to exception handlers.
If doing asynchronous exceptions, record the active EH handler If doing asynchronous exceptions, record the active EH handler
for every insn, since most insns can throw. */ for every insn, since most insns can throw. */
else if (eh_note else if (eh_note
&& (asynchronous_exceptions && (asynchronous_exceptions
|| code == CODE_LABEL
|| (GET_CODE (insn) == CALL_INSN || (GET_CODE (insn) == CALL_INSN
&& ! find_reg_note (insn, REG_RETVAL, NULL_RTX)))) && ! find_reg_note (insn, REG_RETVAL, NULL_RTX))))
active_eh_handler[INSN_UID (insn)] = XEXP (eh_note, 0); active_eh_handler[INSN_UID (insn)] = XEXP (eh_note, 0);
...@@ -574,11 +569,7 @@ find_basic_blocks (f, nonlocal_label_list) ...@@ -574,11 +569,7 @@ find_basic_blocks (f, nonlocal_label_list)
associated insns aren't marked dead, so we make associated insns aren't marked dead, so we make
the block in question live and create an edge from the block in question live and create an edge from
this insn to the label. This is not strictly this insn to the label. This is not strictly
correct, but it is close enough for now. correct, but it is close enough for now. */
We also need to mark the CODE_LABEL as reaching
its exception handler for nested exceptions to
to work. */
for (note = REG_NOTES (insn); for (note = REG_NOTES (insn);
note; note;
note = XEXP (note, 1)) note = XEXP (note, 1))
...@@ -590,14 +581,6 @@ find_basic_blocks (f, nonlocal_label_list) ...@@ -590,14 +581,6 @@ find_basic_blocks (f, nonlocal_label_list)
mark_label_ref (gen_rtx (LABEL_REF, mark_label_ref (gen_rtx (LABEL_REF,
VOIDmode, x), VOIDmode, x),
insn, 0); insn, 0);
/* If the CODE_LABEL has an active exception
handler, then make an edge to the exception
handler from this insn. */
if (active_eh_handler[INSN_UID (x)])
mark_label_ref (gen_rtx (LABEL_REF, VOIDmode,
active_eh_handler[INSN_UID (x)]),
insn, 0);
} }
} }
......
...@@ -3154,8 +3154,6 @@ __sjpopnthrow () ...@@ -3154,8 +3154,6 @@ __sjpopnthrow ()
/* This value identifies the place from which an exception is being /* This value identifies the place from which an exception is being
thrown. */ thrown. */
void *__eh_pc;
#ifdef EH_TABLE_LOOKUP #ifdef EH_TABLE_LOOKUP
EH_TABLE_LOOKUP EH_TABLE_LOOKUP
...@@ -3212,6 +3210,8 @@ find_exception_handler (void *pc, exception_table *table) ...@@ -3212,6 +3210,8 @@ find_exception_handler (void *pc, exception_table *table)
/* Support code for exception handling using inline unwinders or /* Support code for exception handling using inline unwinders or
__unwind_function. */ __unwind_function. */
void *__eh_pc;
#ifndef EH_TABLE_LOOKUP #ifndef EH_TABLE_LOOKUP
typedef struct exception_table_node { typedef struct exception_table_node {
exception_table *table; exception_table *table;
...@@ -3489,7 +3489,7 @@ in_reg_window (int reg, frame_state *udata) ...@@ -3489,7 +3489,7 @@ in_reg_window (int reg, frame_state *udata)
void void
__throw () __throw ()
{ {
void *pc, *handler, *retaddr; void *pc, *handler, *retaddr, *__eh_pc;
frame_state ustruct, ustruct2; frame_state ustruct, ustruct2;
frame_state *udata = &ustruct; frame_state *udata = &ustruct;
frame_state *sub_udata = &ustruct2; frame_state *sub_udata = &ustruct2;
...@@ -3524,6 +3524,7 @@ label: ...@@ -3524,6 +3524,7 @@ label:
__builtin_unwind_init (); __builtin_unwind_init ();
/* Now reset pc to the right throw point. */ /* Now reset pc to the right throw point. */
__eh_pc = __builtin_extract_return_addr (__builtin_return_address (0)) - 1;
pc = __eh_pc; pc = __eh_pc;
handler = 0; handler = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment