From 6020d3605c14364b52b635a93ef2b93ac39108ba Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 18 Sep 1997 23:33:56 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 10 +++++++ gcc/dwarf2out.c | 72 +++++++++++++++++++++++++++++++------------------ gcc/except.c | 2 ++ gcc/final.c | 6 +++++ gcc/libgcc2.c | 15 +++++------ 5 files changed, 70 insertions(+), 35 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e235afba75..b84b5e321cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +Thu Sep 18 14:22:22 1997 Jason Merrill + + * 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 * v850.c (compute_register_save_size): Correct register diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1b7548d47d5..041f2e4a17c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -913,44 +913,64 @@ static void dwarf2out_stack_adjust (insn) rtx insn; { - rtx src, dest; - enum rtx_code code; long offset; char *label; - if (GET_CODE (insn) != SET) - return; - - src = SET_SRC (insn); - dest = SET_DEST (insn); - if (dest == stack_pointer_rtx) + if (GET_CODE (insn) == BARRIER) { - /* (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)); + /* When we see a BARRIER, we know to reset args_size to 0. Usually + the compiler will have already emitted a stack adjustment, but + doesn't bother for calls to noreturn functions. */ +#ifdef STACK_GROWS_DOWNWARD + offset = -args_size; +#else + offset = args_size; +#endif } - else if (GET_CODE (dest) == MEM) + else if (GET_CODE (PATTERN (insn)) == SET) { - /* (set (mem (pre_dec (reg sp))) (foo)) */ - src = XEXP (dest, 0); - code = GET_CODE (src); + rtx src, dest; + enum rtx_code code; + + 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) - || XEXP (src, 0) != stack_pointer_rtx) + offset = GET_MODE_SIZE (GET_MODE (dest)); + } + else return; - offset = GET_MODE_SIZE (GET_MODE (dest)); + if (code == PLUS || code == PRE_INC) + offset = -offset; } else return; - if (code == PLUS || code == PRE_INC) - offset = -offset; + if (offset == 0) + return; + if (cfa_reg == STACK_POINTER_REGNUM) cfa_offset += offset; @@ -997,7 +1017,7 @@ dwarf2out_frame_debug (insn) if (! RTX_FRAME_RELATED_P (insn)) { - dwarf2out_stack_adjust (PATTERN (insn)); + dwarf2out_stack_adjust (insn); return; } diff --git a/gcc/except.c b/gcc/except.c index 7929e9c890e..ae75175393b 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -1668,6 +1668,8 @@ end_eh_unwinder () /* Get the address we need to use to determine what exception handler should be invoked, and store it in __eh_pc. */ 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); /* Either set things up so we do a return directly to __throw, or diff --git a/gcc/final.c b/gcc/final.c index 48e1a0878f7..8e7675e15c9 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -1589,6 +1589,12 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes) is true. */ if (NEXT_INSN (insn)) ASM_OUTPUT_ALIGN_CODE (file); +#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; diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 6b3b7b41f38..2b9c6bc8864 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -3337,15 +3337,11 @@ find_exception_handler (void *pc, exception_table *table) int pos; 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 to be sorted from function to function. */ 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 the previous best. */ @@ -3354,7 +3350,7 @@ find_exception_handler (void *pc, exception_table *table) best = pos; } /* 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; } if (best != -1) @@ -3686,8 +3682,9 @@ label: break; } - /* Otherwise, we continue searching. */ - pc = get_return_addr (udata, sub_udata); + /* Otherwise, we continue searching. We subtract 1 from PC to avoid + 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 @@ -3736,7 +3733,7 @@ label: put_reg (i, val, my_udata); } - pc = get_return_addr (udata, sub_udata); + pc = get_return_addr (udata, sub_udata) - 1; } #ifdef INCOMING_REGNO -- 2.30.2