Commit 387748de by Alan Modra Committed by Alan Modra

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
parent c225ba50
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> 2011-10-14 David S. Miller <davem@davemloft.net>
* config/sparc/sol2.h: Protect -m{cpu,tune}=native handling * config/sparc/sol2.h: Protect -m{cpu,tune}=native handling
...@@ -1273,7 +1273,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label) ...@@ -1273,7 +1273,7 @@ force_nonfallthru_and_redirect (edge e, basic_block target, rtx jump_label)
gcc_unreachable (); gcc_unreachable ();
#endif #endif
} }
JUMP_LABEL (BB_END (jump_block)) = jump_label; set_return_jump_label (BB_END (jump_block));
} }
else else
{ {
......
...@@ -5527,6 +5527,20 @@ emit_return_into_block (bool simple_p, basic_block bb) ...@@ -5527,6 +5527,20 @@ emit_return_into_block (bool simple_p, basic_block bb)
} }
#endif #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. */ /* Return true if BB has any active insns. */
static bool static bool
bb_active_p (basic_block bb) bb_active_p (basic_block bb)
...@@ -6062,7 +6076,7 @@ thread_prologue_and_epilogue_insns (void) ...@@ -6062,7 +6076,7 @@ thread_prologue_and_epilogue_insns (void)
emit_return_into_block (false, last_bb); emit_return_into_block (false, last_bb);
epilogue_end = BB_END (last_bb); epilogue_end = BB_END (last_bb);
if (JUMP_P (epilogue_end)) 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; single_succ_edge (last_bb)->flags &= ~EDGE_FALLTHRU;
goto epilogue_done; goto epilogue_done;
} }
...@@ -6127,15 +6141,7 @@ thread_prologue_and_epilogue_insns (void) ...@@ -6127,15 +6141,7 @@ thread_prologue_and_epilogue_insns (void)
inserted = true; inserted = true;
if (JUMP_P (returnjump)) if (JUMP_P (returnjump))
{ set_return_jump_label (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;
}
} }
else else
#endif #endif
......
...@@ -1086,6 +1086,7 @@ mark_jump_label_1 (rtx x, rtx insn, bool in_mem, bool is_target) ...@@ -1086,6 +1086,7 @@ mark_jump_label_1 (rtx x, rtx insn, bool in_mem, bool is_target)
return; return;
case RETURN: case RETURN:
case SIMPLE_RETURN:
if (is_target) if (is_target)
{ {
gcc_assert (JUMP_LABEL (insn) == NULL || JUMP_LABEL (insn) == x); 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) ...@@ -1408,7 +1409,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn)
int i; int i;
const char *fmt; const char *fmt;
if ((code == LABEL_REF && XEXP (x, 0) == olabel) if ((code == LABEL_REF && XEXP (x, 0) == olabel)
|| x == olabel) || x == olabel)
{ {
x = redirect_target (nlabel); x = redirect_target (nlabel);
......
...@@ -467,7 +467,7 @@ find_end_label (rtx kind) ...@@ -467,7 +467,7 @@ find_end_label (rtx kind)
/* The return we make may have delay slots too. */ /* The return we make may have delay slots too. */
rtx insn = gen_return (); rtx insn = gen_return ();
insn = emit_jump_insn (insn); insn = emit_jump_insn (insn);
JUMP_LABEL (insn) = ret_rtx; set_return_jump_label (insn);
emit_barrier (); emit_barrier ();
if (num_delay_slots (insn) > 0) if (num_delay_slots (insn) > 0)
obstack_ptr_grow (&unfilled_slots_obstack, insn); obstack_ptr_grow (&unfilled_slots_obstack, insn);
......
...@@ -2503,6 +2503,7 @@ extern int sibcall_epilogue_contains (const_rtx); ...@@ -2503,6 +2503,7 @@ extern int sibcall_epilogue_contains (const_rtx);
extern void mark_temp_addr_taken (rtx); extern void mark_temp_addr_taken (rtx);
extern void update_temp_slot_address (rtx, rtx); extern void update_temp_slot_address (rtx, rtx);
extern void maybe_copy_prologue_epilogue_insn (rtx, rtx); extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
extern void set_return_jump_label (rtx);
/* In stmt.c */ /* In stmt.c */
extern void expand_null_return (void); extern void expand_null_return (void);
......
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