Commit 9a08d230 by Richard Henderson Committed by Richard Henderson

re PR debug/49864 (ICE: in maybe_record_trace_start, at dwarf2cfi.c:2439)

PR target/49864
	* reg-notes.def (REG_ARGS_SIZE): New.
	* calls.c (emit_call_1): Emit REG_ARGS_SIZE for call_pop.
	(expand_call): Add REG_ARGS_SIZE to emit_stack_restore.
	* cfgcleanup.c (old_insns_match_p): Don't allow cross-jumping to
	different stack levels.
	* combine-stack-adj.c (adjust_frame_related_expr): Remove.
	(maybe_move_args_size_note): New.
	(combine_stack_adjustments_for_block): Use it.
	* combine.c (distribute_notes): Place REG_ARGS_SIZE.
	* dwarf2cfi.c (dw_cfi_row_struct): Remove args_size member.
	(dw_trace_info): Add beg_true_args_size, end_true_args_size,
	beg_delay_args_size, end_delay_args_size, eh_head, args_size_undefined.
	(cur_cfa): New.
	(queued_args_size): Remove.
	(add_cfi_args_size): Assert size is non-negative.
	(stack_adjust_offset, dwarf2out_args_size): Remove.
	(dwarf2out_stack_adjust, dwarf2out_notice_stack_adjust): Remove.
	(notice_args_size, notice_eh_throw): New.
	(dwarf2out_frame_debug_def_cfa): Use cur_cfa.
	(dwarf2out_frame_debug_adjust_cfa): Likewise.
	(dwarf2out_frame_debug_cfa_offset): Likewise.
	(dwarf2out_frame_debug_expr): Likewise.  Don't stack_adjust_offset.
	(dwarf2out_frame_debug): Don't handle non-frame-related-p insns.
	(change_cfi_row): Don't emit args_size.
	(maybe_record_trace_start_abnormal): Split out from ...
	(maybe_record_trace_start): Here.  Set args_size_undefined.
	(create_trace_edges): Update to match.
	(scan_trace): Handle REG_ARGS_SIZE.
	(connect_traces): Connect args_size between EH insns.
	* emit-rtl.c (try_split): Handle REG_ARGS_SIZE.
	* explow.c (suppress_reg_args_size): New.
	(adjust_stack_1): Split out from ...
	(adjust_stack): ... here.
	(anti_adjust_stack): Use it.
	(allocate_dynamic_stack_space): Suppress REG_ARGS_SIZE.
	* expr.c (mem_autoinc_base): New.
	(fixup_args_size_notes): New.
	(emit_single_push_insn_1): Rename from emit_single_push_insn.
	(emit_single_push_insn): New.  Generate REG_ARGS_SIZE.
	* recog.c (peep2_attempt): Handle REG_ARGS_SIZE.
	* reload1.c (reload_as_needed): Likewise.
	* rtl.h (fixup_args_size_notes): Declare.

From-SVN: r177218
parent cde7b553
2011-08-02 Richard Henderson <rth@redhat.com>
PR target/49864
* reg-notes.def (REG_ARGS_SIZE): New.
* calls.c (emit_call_1): Emit REG_ARGS_SIZE for call_pop.
(expand_call): Add REG_ARGS_SIZE to emit_stack_restore.
* cfgcleanup.c (old_insns_match_p): Don't allow cross-jumping to
different stack levels.
* combine-stack-adj.c (adjust_frame_related_expr): Remove.
(maybe_move_args_size_note): New.
(combine_stack_adjustments_for_block): Use it.
* combine.c (distribute_notes): Place REG_ARGS_SIZE.
* dwarf2cfi.c (dw_cfi_row_struct): Remove args_size member.
(dw_trace_info): Add beg_true_args_size, end_true_args_size,
beg_delay_args_size, end_delay_args_size, eh_head, args_size_undefined.
(cur_cfa): New.
(queued_args_size): Remove.
(add_cfi_args_size): Assert size is non-negative.
(stack_adjust_offset, dwarf2out_args_size): Remove.
(dwarf2out_stack_adjust, dwarf2out_notice_stack_adjust): Remove.
(notice_args_size, notice_eh_throw): New.
(dwarf2out_frame_debug_def_cfa): Use cur_cfa.
(dwarf2out_frame_debug_adjust_cfa): Likewise.
(dwarf2out_frame_debug_cfa_offset): Likewise.
(dwarf2out_frame_debug_expr): Likewise. Don't stack_adjust_offset.
(dwarf2out_frame_debug): Don't handle non-frame-related-p insns.
(change_cfi_row): Don't emit args_size.
(maybe_record_trace_start_abnormal): Split out from ...
(maybe_record_trace_start): Here. Set args_size_undefined.
(create_trace_edges): Update to match.
(scan_trace): Handle REG_ARGS_SIZE.
(connect_traces): Connect args_size between EH insns.
* emit-rtl.c (try_split): Handle REG_ARGS_SIZE.
* explow.c (suppress_reg_args_size): New.
(adjust_stack_1): Split out from ...
(adjust_stack): ... here.
(anti_adjust_stack): Use it.
(allocate_dynamic_stack_space): Suppress REG_ARGS_SIZE.
* expr.c (mem_autoinc_base): New.
(fixup_args_size_notes): New.
(emit_single_push_insn_1): Rename from emit_single_push_insn.
(emit_single_push_insn): New. Generate REG_ARGS_SIZE.
* recog.c (peep2_attempt): Handle REG_ARGS_SIZE.
* reload1.c (reload_as_needed): Likewise.
* rtl.h (fixup_args_size_notes): Declare.
2011-08-02 Paolo Carlini <paolo.carlini@oracle.com> 2011-08-02 Paolo Carlini <paolo.carlini@oracle.com>
PR bootstrap/49914 PR bootstrap/49914
......
...@@ -434,6 +434,8 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU ...@@ -434,6 +434,8 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU
rounded_stack_size_rtx = GEN_INT (rounded_stack_size); rounded_stack_size_rtx = GEN_INT (rounded_stack_size);
stack_pointer_delta -= n_popped; stack_pointer_delta -= n_popped;
add_reg_note (call_insn, REG_ARGS_SIZE, GEN_INT (stack_pointer_delta));
/* If popup is needed, stack realign must use DRAP */ /* If popup is needed, stack realign must use DRAP */
if (SUPPORTS_STACK_ALIGNMENT) if (SUPPORTS_STACK_ALIGNMENT)
crtl->need_drap = true; crtl->need_drap = true;
...@@ -3126,8 +3128,19 @@ expand_call (tree exp, rtx target, int ignore) ...@@ -3126,8 +3128,19 @@ expand_call (tree exp, rtx target, int ignore)
if (old_stack_level) if (old_stack_level)
{ {
rtx last, set;
emit_stack_restore (SAVE_BLOCK, old_stack_level); emit_stack_restore (SAVE_BLOCK, old_stack_level);
stack_pointer_delta = old_stack_pointer_delta; stack_pointer_delta = old_stack_pointer_delta;
/* ??? Is this assert warrented, given emit_stack_restore?
or should we just mark the last insn no matter what? */
last = get_last_insn ();
set = single_set (last);
gcc_assert (set != NULL);
gcc_assert (SET_DEST (set) == stack_pointer_rtx);
add_reg_note (last, REG_ARGS_SIZE, GEN_INT (stack_pointer_delta));
pending_stack_adjust = old_pending_adj; pending_stack_adjust = old_pending_adj;
old_stack_allocated = stack_pointer_delta - pending_stack_adjust; old_stack_allocated = stack_pointer_delta - pending_stack_adjust;
stack_arg_under_construction = old_stack_arg_under_construction; stack_arg_under_construction = old_stack_arg_under_construction;
......
...@@ -1078,6 +1078,16 @@ old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx i1, rtx i2) ...@@ -1078,6 +1078,16 @@ old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx i1, rtx i2)
if (NOTE_INSN_BASIC_BLOCK_P (i1) && NOTE_INSN_BASIC_BLOCK_P (i2)) if (NOTE_INSN_BASIC_BLOCK_P (i1) && NOTE_INSN_BASIC_BLOCK_P (i2))
return dir_both; return dir_both;
/* ??? Do not allow cross-jumping between different stack levels. */
p1 = find_reg_note (i1, REG_ARGS_SIZE, NULL);
p2 = find_reg_note (i2, REG_ARGS_SIZE, NULL);
if (p1)
p1 = XEXP (p1, 0);
if (p2)
p2 = XEXP (p2, 0);
if (!rtx_equal_p (p1, p2))
return dir_none;
p1 = PATTERN (i1); p1 = PATTERN (i1);
p2 = PATTERN (i2); p2 = PATTERN (i2);
......
...@@ -296,68 +296,22 @@ record_stack_refs (rtx *xp, void *data) ...@@ -296,68 +296,22 @@ record_stack_refs (rtx *xp, void *data)
return 0; return 0;
} }
/* Adjust or create REG_FRAME_RELATED_EXPR note when merging a stack /* If INSN has a REG_ARGS_SIZE note, move it to LAST. */
adjustment into a frame related insn. */
static void static void
adjust_frame_related_expr (rtx last_sp_set, rtx insn, maybe_move_args_size_note (rtx last, rtx insn)
HOST_WIDE_INT this_adjust)
{ {
rtx note = find_reg_note (last_sp_set, REG_FRAME_RELATED_EXPR, NULL_RTX); rtx note, last_note;
rtx new_expr = NULL_RTX;
if (note == NULL_RTX && RTX_FRAME_RELATED_P (insn)) note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX);
if (note == NULL)
return; return;
if (note last_note = find_reg_note (last, REG_ARGS_SIZE, NULL_RTX);
&& GET_CODE (XEXP (note, 0)) == SEQUENCE if (last_note)
&& XVECLEN (XEXP (note, 0), 0) >= 2) XEXP (last_note, 0) = XEXP (note, 0);
{
rtx expr = XEXP (note, 0);
rtx last = XVECEXP (expr, 0, XVECLEN (expr, 0) - 1);
int i;
if (GET_CODE (last) == SET
&& RTX_FRAME_RELATED_P (last) == RTX_FRAME_RELATED_P (insn)
&& SET_DEST (last) == stack_pointer_rtx
&& GET_CODE (SET_SRC (last)) == PLUS
&& XEXP (SET_SRC (last), 0) == stack_pointer_rtx
&& CONST_INT_P (XEXP (SET_SRC (last), 1)))
{
XEXP (SET_SRC (last), 1)
= GEN_INT (INTVAL (XEXP (SET_SRC (last), 1)) + this_adjust);
return;
}
new_expr = gen_rtx_SEQUENCE (VOIDmode,
rtvec_alloc (XVECLEN (expr, 0) + 1));
for (i = 0; i < XVECLEN (expr, 0); i++)
XVECEXP (new_expr, 0, i) = XVECEXP (expr, 0, i);
}
else
{
new_expr = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (2));
if (note)
XVECEXP (new_expr, 0, 0) = XEXP (note, 0);
else
{
rtx expr = copy_rtx (single_set_for_csa (last_sp_set));
XEXP (SET_SRC (expr), 1)
= GEN_INT (INTVAL (XEXP (SET_SRC (expr), 1)) - this_adjust);
RTX_FRAME_RELATED_P (expr) = 1;
XVECEXP (new_expr, 0, 0) = expr;
}
}
XVECEXP (new_expr, 0, XVECLEN (new_expr, 0) - 1)
= copy_rtx (single_set_for_csa (insn));
RTX_FRAME_RELATED_P (XVECEXP (new_expr, 0, XVECLEN (new_expr, 0) - 1))
= RTX_FRAME_RELATED_P (insn);
if (note)
XEXP (note, 0) = new_expr;
else else
add_reg_note (last_sp_set, REG_FRAME_RELATED_EXPR, new_expr); add_reg_note (last, REG_ARGS_SIZE, XEXP (note, 0));
} }
/* Subroutine of combine_stack_adjustments, called for each basic block. */ /* Subroutine of combine_stack_adjustments, called for each basic block. */
...@@ -431,9 +385,8 @@ combine_stack_adjustments_for_block (basic_block bb) ...@@ -431,9 +385,8 @@ combine_stack_adjustments_for_block (basic_block bb)
last_sp_adjust + this_adjust, last_sp_adjust + this_adjust,
this_adjust)) this_adjust))
{ {
if (RTX_FRAME_RELATED_P (last_sp_set)) maybe_move_args_size_note (last_sp_set, insn);
adjust_frame_related_expr (last_sp_set, insn,
this_adjust);
/* It worked! */ /* It worked! */
delete_insn (insn); delete_insn (insn);
last_sp_adjust += this_adjust; last_sp_adjust += this_adjust;
......
...@@ -13273,6 +13273,16 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2, ...@@ -13273,6 +13273,16 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2,
} }
break; break;
case REG_ARGS_SIZE:
{
/* ??? How to distribute between i3-i1. Assume i3 contains the
entire adjustment. Assert i3 contains at least some adjust. */
int old_size, args_size = INTVAL (XEXP (note, 0));
old_size = fixup_args_size_notes (PREV_INSN (i3), i3, args_size);
gcc_assert (old_size != args_size);
}
break;
case REG_NORETURN: case REG_NORETURN:
case REG_SETJMP: case REG_SETJMP:
/* These notes must remain with the call. It should not be /* These notes must remain with the call. It should not be
......
...@@ -3614,6 +3614,10 @@ try_split (rtx pat, rtx trial, int last) ...@@ -3614,6 +3614,10 @@ try_split (rtx pat, rtx trial, int last)
break; break;
#endif #endif
case REG_ARGS_SIZE:
fixup_args_size_notes (NULL_RTX, insn_last, INTVAL (XEXP (note, 0)));
break;
default: default:
break; break;
} }
......
...@@ -873,14 +873,45 @@ promote_decl_mode (const_tree decl, int *punsignedp) ...@@ -873,14 +873,45 @@ promote_decl_mode (const_tree decl, int *punsignedp)
} }
/* Controls the behaviour of {anti_,}adjust_stack. */
static bool suppress_reg_args_size;
/* A helper for adjust_stack and anti_adjust_stack. */
static void
adjust_stack_1 (rtx adjust, bool anti_p)
{
rtx temp, insn;
#ifndef STACK_GROWS_DOWNWARD
/* Hereafter anti_p means subtract_p. */
anti_p = !anti_p;
#endif
temp = expand_binop (Pmode,
anti_p ? sub_optab : add_optab,
stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
OPTAB_LIB_WIDEN);
if (temp != stack_pointer_rtx)
insn = emit_move_insn (stack_pointer_rtx, temp);
else
{
insn = get_last_insn ();
temp = single_set (insn);
gcc_assert (temp != NULL && SET_DEST (temp) == stack_pointer_rtx);
}
if (!suppress_reg_args_size)
add_reg_note (insn, REG_ARGS_SIZE, GEN_INT (stack_pointer_delta));
}
/* Adjust the stack pointer by ADJUST (an rtx for a number of bytes). /* Adjust the stack pointer by ADJUST (an rtx for a number of bytes).
This pops when ADJUST is positive. ADJUST need not be constant. */ This pops when ADJUST is positive. ADJUST need not be constant. */
void void
adjust_stack (rtx adjust) adjust_stack (rtx adjust)
{ {
rtx temp;
if (adjust == const0_rtx) if (adjust == const0_rtx)
return; return;
...@@ -889,17 +920,7 @@ adjust_stack (rtx adjust) ...@@ -889,17 +920,7 @@ adjust_stack (rtx adjust)
if (CONST_INT_P (adjust)) if (CONST_INT_P (adjust))
stack_pointer_delta -= INTVAL (adjust); stack_pointer_delta -= INTVAL (adjust);
temp = expand_binop (Pmode, adjust_stack_1 (adjust, false);
#ifdef STACK_GROWS_DOWNWARD
add_optab,
#else
sub_optab,
#endif
stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
OPTAB_LIB_WIDEN);
if (temp != stack_pointer_rtx)
emit_move_insn (stack_pointer_rtx, temp);
} }
/* Adjust the stack pointer by minus ADJUST (an rtx for a number of bytes). /* Adjust the stack pointer by minus ADJUST (an rtx for a number of bytes).
...@@ -908,8 +929,6 @@ adjust_stack (rtx adjust) ...@@ -908,8 +929,6 @@ adjust_stack (rtx adjust)
void void
anti_adjust_stack (rtx adjust) anti_adjust_stack (rtx adjust)
{ {
rtx temp;
if (adjust == const0_rtx) if (adjust == const0_rtx)
return; return;
...@@ -918,17 +937,7 @@ anti_adjust_stack (rtx adjust) ...@@ -918,17 +937,7 @@ anti_adjust_stack (rtx adjust)
if (CONST_INT_P (adjust)) if (CONST_INT_P (adjust))
stack_pointer_delta += INTVAL (adjust); stack_pointer_delta += INTVAL (adjust);
temp = expand_binop (Pmode, adjust_stack_1 (adjust, true);
#ifdef STACK_GROWS_DOWNWARD
sub_optab,
#else
add_optab,
#endif
stack_pointer_rtx, adjust, stack_pointer_rtx, 0,
OPTAB_LIB_WIDEN);
if (temp != stack_pointer_rtx)
emit_move_insn (stack_pointer_rtx, temp);
} }
/* Round the size of a block to be pushed up to the boundary required /* Round the size of a block to be pushed up to the boundary required
...@@ -1416,14 +1425,18 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, ...@@ -1416,14 +1425,18 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
} }
saved_stack_pointer_delta = stack_pointer_delta; saved_stack_pointer_delta = stack_pointer_delta;
suppress_reg_args_size = true;
if (flag_stack_check && STACK_CHECK_MOVING_SP) if (flag_stack_check && STACK_CHECK_MOVING_SP)
anti_adjust_stack_and_probe (size, false); anti_adjust_stack_and_probe (size, false);
else else
anti_adjust_stack (size); anti_adjust_stack (size);
/* Even if size is constant, don't modify stack_pointer_delta. /* Even if size is constant, don't modify stack_pointer_delta.
The constant size alloca should preserve The constant size alloca should preserve
crtl->preferred_stack_boundary alignment. */ crtl->preferred_stack_boundary alignment. */
stack_pointer_delta = saved_stack_pointer_delta; stack_pointer_delta = saved_stack_pointer_delta;
suppress_reg_args_size = false;
#ifdef STACK_GROWS_DOWNWARD #ifdef STACK_GROWS_DOWNWARD
emit_move_insn (target, virtual_stack_dynamic_rtx); emit_move_insn (target, virtual_stack_dynamic_rtx);
......
...@@ -3514,12 +3514,168 @@ push_block (rtx size, int extra, int below) ...@@ -3514,12 +3514,168 @@ push_block (rtx size, int extra, int below)
return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT), temp); return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT), temp);
} }
#ifdef PUSH_ROUNDING /* A utility routine that returns the base of an auto-inc memory, or NULL. */
static rtx
mem_autoinc_base (rtx mem)
{
if (MEM_P (mem))
{
rtx addr = XEXP (mem, 0);
if (GET_RTX_CLASS (GET_CODE (addr)) == RTX_AUTOINC)
return XEXP (addr, 0);
}
return NULL;
}
/* A utility routine used here, in reload, and in try_split. The insns
after PREV up to and including LAST are known to adjust the stack,
with a final value of END_ARGS_SIZE. Iterate backward from LAST
placing notes as appropriate. PREV may be NULL, indicating the
entire insn sequence prior to LAST should be scanned.
The set of allowed stack pointer modifications is small:
(1) One or more auto-inc style memory references (aka pushes),
(2) One or more addition/subtraction with the SP as destination,
(3) A single move insn with the SP as destination,
(4) A call_pop insn.
Insns in the sequence that do not modify the SP are ignored.
The return value is the amount of adjustment that can be trivially
verified, via immediate operand or auto-inc. If the adjustment
cannot be trivially extracted, the return value is INT_MIN. */
int
fixup_args_size_notes (rtx prev, rtx last, int end_args_size)
{
int args_size = end_args_size;
bool saw_unknown = false;
rtx insn;
for (insn = last; insn != prev; insn = PREV_INSN (insn))
{
rtx dest, set, pat;
HOST_WIDE_INT this_delta = 0;
int i;
if (!NONDEBUG_INSN_P (insn))
continue;
pat = PATTERN (insn);
set = NULL;
/* Look for a call_pop pattern. */
if (CALL_P (insn))
{
/* We're not supposed to see non-pop call patterns here. */
gcc_assert (GET_CODE (pat) == PARALLEL);
/* All call_pop have a stack pointer adjust in the parallel.
The call itself is always first, and the stack adjust is
usually last, so search from the end. */
for (i = XVECLEN (pat, 0) - 1; i > 0; --i)
{
set = XVECEXP (pat, 0, i);
if (GET_CODE (set) != SET)
continue;
dest = SET_DEST (set);
if (dest == stack_pointer_rtx)
break;
}
/* We'd better have found the stack pointer adjust. */
gcc_assert (i > 0);
/* Fall through to process the extracted SET and DEST
as if it was a standalone insn. */
}
else if (GET_CODE (pat) == SET)
set = pat;
else if ((set = single_set (insn)) != NULL)
;
else if (GET_CODE (pat) == PARALLEL)
{
/* ??? Some older ports use a parallel with a stack adjust
and a store for a PUSH_ROUNDING pattern, rather than a
PRE/POST_MODIFY rtx. Don't force them to update yet... */
/* ??? See h8300 and m68k, pushqi1. */
for (i = XVECLEN (pat, 0) - 1; i >= 0; --i)
{
set = XVECEXP (pat, 0, i);
if (GET_CODE (set) != SET)
continue;
dest = SET_DEST (set);
if (dest == stack_pointer_rtx)
break;
/* We do not expect an auto-inc of the sp in the parallel. */
gcc_checking_assert (mem_autoinc_base (dest)
!= stack_pointer_rtx);
gcc_checking_assert (mem_autoinc_base (SET_SRC (set))
!= stack_pointer_rtx);
}
if (i < 0)
continue;
}
else
continue;
dest = SET_DEST (set);
/* Look for direct modifications of the stack pointer. */
if (dest == stack_pointer_rtx)
{
gcc_assert (!saw_unknown);
/* Look for a trivial adjustment, otherwise assume nothing. */
if (GET_CODE (SET_SRC (set)) == PLUS
&& XEXP (SET_SRC (set), 0) == stack_pointer_rtx
&& CONST_INT_P (XEXP (SET_SRC (set), 1)))
this_delta = INTVAL (XEXP (SET_SRC (set), 1));
else
saw_unknown = true;
}
/* Otherwise only think about autoinc patterns. */
else if (mem_autoinc_base (dest) == stack_pointer_rtx)
{
rtx addr = XEXP (dest, 0);
gcc_assert (!saw_unknown);
switch (GET_CODE (addr))
{
case PRE_INC:
case POST_INC:
this_delta = GET_MODE_SIZE (GET_MODE (dest));
break;
case PRE_DEC:
case POST_DEC:
this_delta = -GET_MODE_SIZE (GET_MODE (dest));
break;
case PRE_MODIFY:
case POST_MODIFY:
addr = XEXP (addr, 1);
gcc_assert (GET_CODE (addr) == PLUS);
gcc_assert (XEXP (addr, 0) == stack_pointer_rtx);
gcc_assert (CONST_INT_P (XEXP (addr, 1)));
this_delta = INTVAL (XEXP (addr, 1));
break;
default:
gcc_unreachable ();
}
}
else
continue;
add_reg_note (insn, REG_ARGS_SIZE, GEN_INT (args_size));
#ifdef STACK_GROWS_DOWNWARD
this_delta = -this_delta;
#endif
args_size -= this_delta;
}
return saw_unknown ? INT_MIN : args_size;
}
#ifdef PUSH_ROUNDING
/* Emit single push insn. */ /* Emit single push insn. */
static void static void
emit_single_push_insn (enum machine_mode mode, rtx x, tree type) emit_single_push_insn_1 (enum machine_mode mode, rtx x, tree type)
{ {
rtx dest_addr; rtx dest_addr;
unsigned rounded_size = PUSH_ROUNDING (GET_MODE_SIZE (mode)); unsigned rounded_size = PUSH_ROUNDING (GET_MODE_SIZE (mode));
...@@ -3603,6 +3759,30 @@ emit_single_push_insn (enum machine_mode mode, rtx x, tree type) ...@@ -3603,6 +3759,30 @@ emit_single_push_insn (enum machine_mode mode, rtx x, tree type)
} }
emit_move_insn (dest, x); emit_move_insn (dest, x);
} }
/* Emit and annotate a single push insn. */
static void
emit_single_push_insn (enum machine_mode mode, rtx x, tree type)
{
int delta, old_delta = stack_pointer_delta;
rtx prev = get_last_insn ();
rtx last;
emit_single_push_insn_1 (mode, x, type);
last = get_last_insn ();
/* Notice the common case where we emitted exactly one insn. */
if (PREV_INSN (last) == prev)
{
add_reg_note (last, REG_ARGS_SIZE, GEN_INT (stack_pointer_delta));
return;
}
delta = fixup_args_size_notes (prev, last, stack_pointer_delta);
gcc_assert (delta == INT_MIN || delta == old_delta);
}
#endif #endif
/* Generate code to push X onto the stack, assuming it has mode MODE and /* Generate code to push X onto the stack, assuming it has mode MODE and
......
...@@ -3146,16 +3146,17 @@ static rtx ...@@ -3146,16 +3146,17 @@ static rtx
peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt)
{ {
int i; int i;
rtx last, note, before_try, x; rtx last, eh_note, as_note, before_try, x;
rtx old_insn, new_insn; rtx old_insn, new_insn;
bool was_call = false; bool was_call = false;
/* If we are splittind an RTX_FRAME_RELATED_P insn, do not allow it to /* If we are splitting an RTX_FRAME_RELATED_P insn, do not allow it to
match more than one insn, or to be split into more than one insn. */ match more than one insn, or to be split into more than one insn. */
old_insn = peep2_insn_data[peep2_current].insn; old_insn = peep2_insn_data[peep2_current].insn;
if (RTX_FRAME_RELATED_P (old_insn)) if (RTX_FRAME_RELATED_P (old_insn))
{ {
bool any_note = false; bool any_note = false;
rtx note;
if (match_len != 0) if (match_len != 0)
return NULL; return NULL;
...@@ -3236,6 +3237,7 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) ...@@ -3236,6 +3237,7 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt)
for (i = 0; i <= match_len; ++i) for (i = 0; i <= match_len; ++i)
{ {
int j; int j;
rtx note;
j = peep2_buf_position (peep2_current + i); j = peep2_buf_position (peep2_current + i);
old_insn = peep2_insn_data[j].insn; old_insn = peep2_insn_data[j].insn;
...@@ -3281,9 +3283,21 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) ...@@ -3281,9 +3283,21 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt)
break; break;
} }
i = peep2_buf_position (peep2_current + match_len); /* If we matched any instruction that had a REG_ARGS_SIZE, then
move those notes over to the new sequence. */
as_note = NULL;
for (i = match_len; i >= 0; --i)
{
int j = peep2_buf_position (peep2_current + i);
old_insn = peep2_insn_data[j].insn;
as_note = find_reg_note (old_insn, REG_ARGS_SIZE, NULL);
if (as_note)
break;
}
note = find_reg_note (peep2_insn_data[i].insn, REG_EH_REGION, NULL_RTX); i = peep2_buf_position (peep2_current + match_len);
eh_note = find_reg_note (peep2_insn_data[i].insn, REG_EH_REGION, NULL_RTX);
/* Replace the old sequence with the new. */ /* Replace the old sequence with the new. */
last = emit_insn_after_setloc (attempt, last = emit_insn_after_setloc (attempt,
...@@ -3293,7 +3307,7 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) ...@@ -3293,7 +3307,7 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt)
delete_insn_chain (insn, peep2_insn_data[i].insn, false); delete_insn_chain (insn, peep2_insn_data[i].insn, false);
/* Re-insert the EH_REGION notes. */ /* Re-insert the EH_REGION notes. */
if (note || (was_call && nonlocal_goto_handler_labels)) if (eh_note || (was_call && nonlocal_goto_handler_labels))
{ {
edge eh_edge; edge eh_edge;
edge_iterator ei; edge_iterator ei;
...@@ -3302,8 +3316,8 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) ...@@ -3302,8 +3316,8 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt)
if (eh_edge->flags & (EDGE_EH | EDGE_ABNORMAL_CALL)) if (eh_edge->flags & (EDGE_EH | EDGE_ABNORMAL_CALL))
break; break;
if (note) if (eh_note)
copy_reg_eh_region_note_backward (note, last, before_try); copy_reg_eh_region_note_backward (eh_note, last, before_try);
if (eh_edge) if (eh_edge)
for (x = last; x != before_try; x = PREV_INSN (x)) for (x = last; x != before_try; x = PREV_INSN (x))
...@@ -3336,6 +3350,10 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt) ...@@ -3336,6 +3350,10 @@ peep2_attempt (basic_block bb, rtx insn, int match_len, rtx attempt)
peep2_do_cleanup_cfg |= purge_dead_edges (bb); peep2_do_cleanup_cfg |= purge_dead_edges (bb);
} }
/* Re-insert the ARGS_SIZE notes. */
if (as_note)
fixup_args_size_notes (before_try, last, INTVAL (XEXP (as_note, 0)));
/* If we generated a jump instruction, it won't have /* If we generated a jump instruction, it won't have
JUMP_LABEL set. Recompute after we're done. */ JUMP_LABEL set. Recompute after we're done. */
for (x = last; x != before_try; x = PREV_INSN (x)) for (x = last; x != before_try; x = PREV_INSN (x))
......
...@@ -201,3 +201,8 @@ REG_NOTE (CROSSING_JUMP) ...@@ -201,3 +201,8 @@ REG_NOTE (CROSSING_JUMP)
/* This kind of note is generated at each to `setjmp', and similar /* This kind of note is generated at each to `setjmp', and similar
functions that can return twice. */ functions that can return twice. */
REG_NOTE (SETJMP) REG_NOTE (SETJMP)
/* Indicates the cumulative offset of the stack pointer accounting
for pushed arguments. This will only be generated when
ACCUMULATE_OUTGOING_ARGS is false. */
REG_NOTE (ARGS_SIZE)
...@@ -4548,7 +4548,7 @@ reload_as_needed (int live_known) ...@@ -4548,7 +4548,7 @@ reload_as_needed (int live_known)
#if defined (AUTO_INC_DEC) #if defined (AUTO_INC_DEC)
int i; int i;
#endif #endif
rtx x; rtx x, marker;
memset (spill_reg_rtx, 0, sizeof spill_reg_rtx); memset (spill_reg_rtx, 0, sizeof spill_reg_rtx);
memset (spill_reg_store, 0, sizeof spill_reg_store); memset (spill_reg_store, 0, sizeof spill_reg_store);
...@@ -4559,6 +4559,10 @@ reload_as_needed (int live_known) ...@@ -4559,6 +4559,10 @@ reload_as_needed (int live_known)
set_initial_elim_offsets (); set_initial_elim_offsets ();
/* Generate a marker insn that we will move around. */
marker = emit_note (NOTE_INSN_DELETED);
unlink_insn_chain (marker, marker);
for (chain = reload_insn_chain; chain; chain = chain->next) for (chain = reload_insn_chain; chain; chain = chain->next)
{ {
rtx prev = 0; rtx prev = 0;
...@@ -4631,7 +4635,10 @@ reload_as_needed (int live_known) ...@@ -4631,7 +4635,10 @@ reload_as_needed (int live_known)
rtx next = NEXT_INSN (insn); rtx next = NEXT_INSN (insn);
rtx p; rtx p;
/* ??? PREV can get deleted by reload inheritance.
Work around this by emitting a marker note. */
prev = PREV_INSN (insn); prev = PREV_INSN (insn);
reorder_insns_nobb (marker, marker, prev);
/* Now compute which reload regs to reload them into. Perhaps /* Now compute which reload regs to reload them into. Perhaps
reusing reload regs from previous insns, or else output reusing reload regs from previous insns, or else output
...@@ -4649,10 +4656,22 @@ reload_as_needed (int live_known) ...@@ -4649,10 +4656,22 @@ reload_as_needed (int live_known)
and that we moved the structure into). */ and that we moved the structure into). */
subst_reloads (insn); subst_reloads (insn);
prev = PREV_INSN (marker);
unlink_insn_chain (marker, marker);
/* Adjust the exception region notes for loads and stores. */ /* Adjust the exception region notes for loads and stores. */
if (cfun->can_throw_non_call_exceptions && !CALL_P (insn)) if (cfun->can_throw_non_call_exceptions && !CALL_P (insn))
fixup_eh_region_note (insn, prev, next); fixup_eh_region_note (insn, prev, next);
/* Adjust the location of REG_ARGS_SIZE. */
p = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX);
if (p)
{
remove_note (insn, p);
fixup_args_size_notes (prev, PREV_INSN (next),
INTVAL (XEXP (p, 0)));
}
/* If this was an ASM, make sure that all the reload insns /* If this was an ASM, make sure that all the reload insns
we have generated are valid. If not, give an error we have generated are valid. If not, give an error
and delete them. */ and delete them. */
......
...@@ -2471,6 +2471,7 @@ extern void emit_jump (rtx); ...@@ -2471,6 +2471,7 @@ extern void emit_jump (rtx);
/* In expr.c */ /* In expr.c */
extern rtx move_by_pieces (rtx, rtx, unsigned HOST_WIDE_INT, extern rtx move_by_pieces (rtx, rtx, unsigned HOST_WIDE_INT,
unsigned int, int); unsigned int, int);
extern int fixup_args_size_notes (rtx, rtx, int);
/* In cfgrtl.c */ /* In cfgrtl.c */
extern void print_rtl_with_bb (FILE *, const_rtx); extern void print_rtl_with_bb (FILE *, const_rtx);
......
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