Commit 6020d360 by Jason Merrill Committed by Jason Merrill

final.c (final_scan_insn): Hand BARRIERs off to the dwarf2 code.

	* final.c (final_scan_insn): Hand BARRIERs off to the dwarf2 code.
	* dwarf2out.c (dwarf2out_frame_debug): Pass the whole insn along.
	(dwarf2out_stack_adjust): A BARRIER resets the args space to 0.

	* except.c (end_eh_unwinder): Subtract 1 from return address.
	* libgcc2.c (__throw): Likewise.
	(find_exception_handler): Don't change PC here.  Compare end with >.

From-SVN: r15554
parent feb5876a
Thu Sep 18 14:22:22 1997 Jason Merrill <jason@yorick.cygnus.com>
* final.c (final_scan_insn): Hand BARRIERs off to the dwarf2 code.
* dwarf2out.c (dwarf2out_frame_debug): Pass the whole insn along.
(dwarf2out_stack_adjust): A BARRIER resets the args space to 0.
* except.c (end_eh_unwinder): Subtract 1 from return address.
* libgcc2.c (__throw): Likewise.
(find_exception_handler): Don't change PC here. Compare end with >.
Thu Sep 18 10:43:07 1997 Nick Clifton <nickc@cygnus.com> Thu Sep 18 10:43:07 1997 Nick Clifton <nickc@cygnus.com>
* v850.c (compute_register_save_size): Correct register * v850.c (compute_register_save_size): Correct register
......
...@@ -913,44 +913,64 @@ static void ...@@ -913,44 +913,64 @@ static void
dwarf2out_stack_adjust (insn) dwarf2out_stack_adjust (insn)
rtx insn; rtx insn;
{ {
rtx src, dest;
enum rtx_code code;
long offset; long offset;
char *label; char *label;
if (GET_CODE (insn) != SET) if (GET_CODE (insn) == BARRIER)
return;
src = SET_SRC (insn);
dest = SET_DEST (insn);
if (dest == stack_pointer_rtx)
{ {
/* (set (reg sp) (plus (reg sp) (const_int))) */ /* When we see a BARRIER, we know to reset args_size to 0. Usually
code = GET_CODE (src); the compiler will have already emitted a stack adjustment, but
if (! (code == PLUS || code == MINUS) doesn't bother for calls to noreturn functions. */
|| XEXP (src, 0) != stack_pointer_rtx #ifdef STACK_GROWS_DOWNWARD
|| GET_CODE (XEXP (src, 1)) != CONST_INT) offset = -args_size;
return; #else
offset = args_size;
offset = INTVAL (XEXP (src, 1)); #endif
} }
else if (GET_CODE (dest) == MEM) else if (GET_CODE (PATTERN (insn)) == SET)
{ {
/* (set (mem (pre_dec (reg sp))) (foo)) */ rtx src, dest;
src = XEXP (dest, 0); enum rtx_code code;
code = GET_CODE (src);
insn = PATTERN (insn);
src = SET_SRC (insn);
dest = SET_DEST (insn);
if (dest == stack_pointer_rtx)
{
/* (set (reg sp) (plus (reg sp) (const_int))) */
code = GET_CODE (src);
if (! (code == PLUS || code == MINUS)
|| XEXP (src, 0) != stack_pointer_rtx
|| GET_CODE (XEXP (src, 1)) != CONST_INT)
return;
offset = INTVAL (XEXP (src, 1));
}
else if (GET_CODE (dest) == MEM)
{
/* (set (mem (pre_dec (reg sp))) (foo)) */
src = XEXP (dest, 0);
code = GET_CODE (src);
if (! (code == PRE_DEC || code == PRE_INC)
|| XEXP (src, 0) != stack_pointer_rtx)
return;
if (! (code == PRE_DEC || code == PRE_INC) offset = GET_MODE_SIZE (GET_MODE (dest));
|| XEXP (src, 0) != stack_pointer_rtx) }
else
return; return;
offset = GET_MODE_SIZE (GET_MODE (dest)); if (code == PLUS || code == PRE_INC)
offset = -offset;
} }
else else
return; return;
if (code == PLUS || code == PRE_INC) if (offset == 0)
offset = -offset; return;
if (cfa_reg == STACK_POINTER_REGNUM) if (cfa_reg == STACK_POINTER_REGNUM)
cfa_offset += offset; cfa_offset += offset;
...@@ -997,7 +1017,7 @@ dwarf2out_frame_debug (insn) ...@@ -997,7 +1017,7 @@ dwarf2out_frame_debug (insn)
if (! RTX_FRAME_RELATED_P (insn)) if (! RTX_FRAME_RELATED_P (insn))
{ {
dwarf2out_stack_adjust (PATTERN (insn)); dwarf2out_stack_adjust (insn);
return; return;
} }
......
...@@ -1668,6 +1668,8 @@ end_eh_unwinder () ...@@ -1668,6 +1668,8 @@ end_eh_unwinder ()
/* Get the address we need to use to determine what exception /* Get the address we need to use to determine what exception
handler should be invoked, and store it in __eh_pc. */ handler should be invoked, and store it in __eh_pc. */
return_val_rtx = eh_outer_context (return_val_rtx); return_val_rtx = eh_outer_context (return_val_rtx);
return_val_rtx = expand_binop (Pmode, sub_optab, return_val_rtx, GEN_INT (1),
NULL_RTX, 0, OPTAB_LIB_WIDEN);
emit_move_insn (eh_saved_pc_rtx, return_val_rtx); emit_move_insn (eh_saved_pc_rtx, return_val_rtx);
/* Either set things up so we do a return directly to __throw, or /* Either set things up so we do a return directly to __throw, or
......
...@@ -1590,6 +1590,12 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes) ...@@ -1590,6 +1590,12 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
if (NEXT_INSN (insn)) if (NEXT_INSN (insn))
ASM_OUTPUT_ALIGN_CODE (file); ASM_OUTPUT_ALIGN_CODE (file);
#endif #endif
#if defined (DWARF2_UNWIND_INFO) && !defined (ACCUMULATE_OUTGOING_ARGS)
/* If we push arguments, we need to check all insns for stack
adjustments. */
if (dwarf2out_do_frame ())
dwarf2out_frame_debug (insn);
#endif
break; break;
case CODE_LABEL: case CODE_LABEL:
......
...@@ -3337,15 +3337,11 @@ find_exception_handler (void *pc, exception_table *table) ...@@ -3337,15 +3337,11 @@ find_exception_handler (void *pc, exception_table *table)
int pos; int pos;
int best = -1; int best = -1;
/* We subtract 1 from PC to avoid hitting the beginning of the next
region. */
--pc;
/* We can't do a binary search because the table isn't guaranteed /* We can't do a binary search because the table isn't guaranteed
to be sorted from function to function. */ to be sorted from function to function. */
for (pos = 0; table[pos].exception_handler != (void *) -1; ++pos) for (pos = 0; table[pos].exception_handler != (void *) -1; ++pos)
{ {
if (table[pos].start <= pc && table[pos].end >= pc) if (table[pos].start <= pc && table[pos].end > pc)
{ {
/* This can apply. Make sure it is at least as small as /* This can apply. Make sure it is at least as small as
the previous best. */ the previous best. */
...@@ -3354,7 +3350,7 @@ find_exception_handler (void *pc, exception_table *table) ...@@ -3354,7 +3350,7 @@ find_exception_handler (void *pc, exception_table *table)
best = pos; best = pos;
} }
/* But it is sorted by starting PC within a function. */ /* But it is sorted by starting PC within a function. */
else if (best && table[pos].start > pc) else if (best >= 0 && table[pos].start > pc)
break; break;
} }
if (best != -1) if (best != -1)
...@@ -3686,8 +3682,9 @@ label: ...@@ -3686,8 +3682,9 @@ label:
break; break;
} }
/* Otherwise, we continue searching. */ /* Otherwise, we continue searching. We subtract 1 from PC to avoid
pc = get_return_addr (udata, sub_udata); hitting the beginning of the next region. */
pc = get_return_addr (udata, sub_udata) - 1;
} }
/* If we haven't found a handler by now, this is an unhandled /* If we haven't found a handler by now, this is an unhandled
...@@ -3736,7 +3733,7 @@ label: ...@@ -3736,7 +3733,7 @@ label:
put_reg (i, val, my_udata); put_reg (i, val, my_udata);
} }
pc = get_return_addr (udata, sub_udata); pc = get_return_addr (udata, sub_udata) - 1;
} }
#ifdef INCOMING_REGNO #ifdef INCOMING_REGNO
......
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