re PR rtl-optimization/49941 (segmentation fault in redirect_jump_2)

PR rtl-optimization/49941
	* jump.c (mark_jump_label_1): Set JUMP_LABEL for simple_return jumps.

	* rtl.h (set_return_jump_label): Declare.
	* function.c (set_return_jump_label): New function, extracted..
	(thread_prologue_and_epilogue_insns): ..from here.  Use it in
	another instance to set return jump_label.
	* cfgrtl.c (force_nonfallthru_and_redirect): Use set_return_jump_label.
	* reorg.c (find_end_label): Likewise.

From-SVN: r180027
This commit is contained in:
Alan Modra 2011-10-15 21:02:33 +10:30 committed by Alan Modra
parent c225ba500b
commit 387748de2f
6 changed files with 33 additions and 13 deletions

View File

@ -1,3 +1,15 @@
2011-10-15 Alan Modra <amodra@gmail.com>
PR rtl-optimization/49941
* jump.c (mark_jump_label_1): Set JUMP_LABEL for simple_return jumps.
* rtl.h (set_return_jump_label): Declare.
* function.c (set_return_jump_label): New function, extracted..
(thread_prologue_and_epilogue_insns): ..from here. Use it in
another instance to set return jump_label.
* cfgrtl.c (force_nonfallthru_and_redirect): Use set_return_jump_label.
* reorg.c (find_end_label): Likewise.
2011-10-14 David S. Miller <davem@davemloft.net>
* config/sparc/sol2.h: Protect -m{cpu,tune}=native handling

View File

@ -1273,7 +1273,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
gcc_unreachable ();
#endif
}
JUMP_LABEL (BB_END (jump_block)) = jump_label;
set_return_jump_label (BB_END (jump_block));
}
else
{

View File

@ -5527,6 +5527,20 @@ emit_return_into_block (bool simple_p, basic_block bb)
}
#endif
/* Set JUMP_LABEL for a return insn. */
void
set_return_jump_label (rtx returnjump)
{
rtx pat = PATTERN (returnjump);
if (GET_CODE (pat) == PARALLEL)
pat = XVECEXP (pat, 0, 0);
if (ANY_RETURN_P (pat))
JUMP_LABEL (returnjump) = pat;
else
JUMP_LABEL (returnjump) = ret_rtx;
}
/* Return true if BB has any active insns. */
static bool
bb_active_p (basic_block bb)
@ -6062,7 +6076,7 @@ thread_prologue_and_epilogue_insns (void)
emit_return_into_block (false, last_bb);
epilogue_end = BB_END (last_bb);
if (JUMP_P (epilogue_end))
JUMP_LABEL (epilogue_end) = ret_rtx;
set_return_jump_label (epilogue_end);
single_succ_edge (last_bb)->flags &= ~EDGE_FALLTHRU;
goto epilogue_done;
}
@ -6127,15 +6141,7 @@ thread_prologue_and_epilogue_insns (void)
inserted = true;
if (JUMP_P (returnjump))
{
rtx pat = PATTERN (returnjump);
if (GET_CODE (pat) == PARALLEL)
pat = XVECEXP (pat, 0, 0);
if (ANY_RETURN_P (pat))
JUMP_LABEL (returnjump) = pat;
else
JUMP_LABEL (returnjump) = ret_rtx;
}
set_return_jump_label (returnjump);
}
else
#endif

View File

@ -1086,6 +1086,7 @@ mark_jump_label_1 (rtx x, rtx insn, bool in_mem, bool is_target)
return;
case RETURN:
case SIMPLE_RETURN:
if (is_target)
{
gcc_assert (JUMP_LABEL (insn) == NULL || JUMP_LABEL (insn) == x);
@ -1408,7 +1409,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn)
int i;
const char *fmt;
if ((code == LABEL_REF && XEXP (x, 0) == olabel)
if ((code == LABEL_REF && XEXP (x, 0) == olabel)
|| x == olabel)
{
x = redirect_target (nlabel);

View File

@ -467,7 +467,7 @@ find_end_label (rtx kind)
/* The return we make may have delay slots too. */
rtx insn = gen_return ();
insn = emit_jump_insn (insn);
JUMP_LABEL (insn) = ret_rtx;
set_return_jump_label (insn);
emit_barrier ();
if (num_delay_slots (insn) > 0)
obstack_ptr_grow (&unfilled_slots_obstack, insn);

View File

@ -2503,6 +2503,7 @@ extern int sibcall_epilogue_contains (const_rtx);
extern void mark_temp_addr_taken (rtx);
extern void update_temp_slot_address (rtx, rtx);
extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
extern void set_return_jump_label (rtx);
/* In stmt.c */
extern void expand_null_return (void);