reg-notes.def (CROSSING_JUMP): Likewise.

gcc/
	* reg-notes.def (CROSSING_JUMP): Likewise.
	* rtl.h (rtx_def): Update comment for jump flag.
	(CROSSING_JUMP_P): Define.
	* cfgcleanup.c (try_forward_edges, try_optimize_cfg): Use it instead
	of a REG_CROSSING_JUMP note.
	* cfghooks.c (tidy_fallthru_edges): Likewise.
	* cfgrtl.c (fixup_partition_crossing, rtl_verify_edges): Likewise.
	* emit-rtl.c (try_split): Likewise.
	* haifa-sched.c (sched_create_recovery_edges): Likewise.
	* ifcvt.c (find_if_case_1, find_if_case_2): Likewise.
	* jump.c (redirect_jump_2): Likewise.
	* reorg.c (follow_jumps, fill_slots_from_thread): Likewise.
	(relax_delay_slots): Likewise.
	* config/arc/arc.md (jump_i, cbranchsi4_scratch, *bbit): Likewise.
	(bbit_di): Likewise.
	* config/arc/arc.c (arc_reorg, arc_can_follow_jump): Likewise.
	* config/sh/sh.md (jump_compact): Likewise.
	* bb-reorder.c (rotate_loop): Likewise.
	(pass_duplicate_computed_gotos::execute): Likewise.
	(add_reg_crossing_jump_notes): Rename to...
	(update_crossing_jump_flags): ...this.
	(pass_partition_blocks::execute): Update accordingly.

From-SVN: r210603
This commit is contained in:
Richard Sandiford 2014-05-19 06:49:58 +00:00 committed by Richard Sandiford
parent a65d5b87d1
commit 339ba33b4f
15 changed files with 89 additions and 65 deletions

View File

@ -1,3 +1,28 @@
2014-05-19 Richard Sandiford <rdsandiford@googlemail.com>
* reg-notes.def (CROSSING_JUMP): Likewise.
* rtl.h (rtx_def): Update comment for jump flag.
(CROSSING_JUMP_P): Define.
* cfgcleanup.c (try_forward_edges, try_optimize_cfg): Use it instead
of a REG_CROSSING_JUMP note.
* cfghooks.c (tidy_fallthru_edges): Likewise.
* cfgrtl.c (fixup_partition_crossing, rtl_verify_edges): Likewise.
* emit-rtl.c (try_split): Likewise.
* haifa-sched.c (sched_create_recovery_edges): Likewise.
* ifcvt.c (find_if_case_1, find_if_case_2): Likewise.
* jump.c (redirect_jump_2): Likewise.
* reorg.c (follow_jumps, fill_slots_from_thread): Likewise.
(relax_delay_slots): Likewise.
* config/arc/arc.md (jump_i, cbranchsi4_scratch, *bbit): Likewise.
(bbit_di): Likewise.
* config/arc/arc.c (arc_reorg, arc_can_follow_jump): Likewise.
* config/sh/sh.md (jump_compact): Likewise.
* bb-reorder.c (rotate_loop): Likewise.
(pass_duplicate_computed_gotos::execute): Likewise.
(add_reg_crossing_jump_notes): Rename to...
(update_crossing_jump_flags): ...this.
(pass_partition_blocks::execute): Update accordingly.
2014-05-19 Richard Sandiford <rdsandiford@googlemail.com>
* tree.h: Remove extraneous template <>.

View File

@ -425,8 +425,7 @@ rotate_loop (edge back_edge, struct trace *trace, int trace_n)
/* Duplicate HEADER if it is a small block containing cond jump
in the end. */
if (any_condjump_p (BB_END (header)) && copy_bb_p (header, 0)
&& !find_reg_note (BB_END (header), REG_CROSSING_JUMP,
NULL_RTX))
&& !CROSSING_JUMP_P (BB_END (header)))
copy_bb (header, single_succ_edge (prev_bb), prev_bb, trace_n);
}
}
@ -2194,10 +2193,10 @@ fix_crossing_unconditional_branches (void)
}
}
/* Add REG_CROSSING_JUMP note to all crossing jump insns. */
/* Update CROSSING_JUMP_P flags on all jump insns. */
static void
add_reg_crossing_jump_notes (void)
update_crossing_jump_flags (void)
{
basic_block bb;
edge e;
@ -2205,12 +2204,15 @@ add_reg_crossing_jump_notes (void)
FOR_EACH_BB_FN (bb, cfun)
FOR_EACH_EDGE (e, ei, bb->succs)
if ((e->flags & EDGE_CROSSING)
&& JUMP_P (BB_END (e->src))
/* Some notes were added during fix_up_fall_thru_edges, via
force_nonfallthru_and_redirect. */
&& !find_reg_note (BB_END (e->src), REG_CROSSING_JUMP, NULL_RTX))
add_reg_note (BB_END (e->src), REG_CROSSING_JUMP, NULL_RTX);
if (e->flags & EDGE_CROSSING)
{
if (JUMP_P (BB_END (bb))
/* Some flags were added during fix_up_fall_thru_edges, via
force_nonfallthru_and_redirect. */
&& !CROSSING_JUMP_P (BB_END (bb)))
CROSSING_JUMP_P (BB_END (bb)) = 1;
break;
}
}
/* Reorder basic blocks. The main entry point to this file. FLAGS is
@ -2454,7 +2456,7 @@ pass_duplicate_computed_gotos::execute (function *fun)
continue;
/* Only consider blocks that can be duplicated. */
if (find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX)
if (CROSSING_JUMP_P (BB_END (bb))
|| !can_duplicate_block_p (bb))
continue;
@ -2507,7 +2509,7 @@ pass_duplicate_computed_gotos::execute (function *fun)
/* Don't duplicate a partition crossing edge, which requires difficult
fixup. */
if (find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX))
if (JUMP_P (BB_END (bb)) && CROSSING_JUMP_P (BB_END (bb)))
continue;
new_bb = duplicate_block (single_succ (bb), single_succ_edge (bb), bb);
@ -2710,7 +2712,7 @@ pass_partition_blocks::execute (function *fun)
if (!HAS_LONG_UNCOND_BRANCH)
fix_crossing_unconditional_branches ();
add_reg_crossing_jump_notes ();
update_crossing_jump_flags ();
/* Clear bb->aux fields that the above routines were using. */
clear_aux_for_blocks ();

View File

@ -419,7 +419,7 @@ try_forward_edges (int mode, basic_block b)
partition boundaries). See the comments at the top of
bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
if (find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX))
if (JUMP_P (BB_END (b)) && CROSSING_JUMP_P (BB_END (b)))
return false;
for (ei = ei_start (b->succs); (e = ei_safe_edge (ei)); )
@ -457,7 +457,8 @@ try_forward_edges (int mode, basic_block b)
details. */
if (first != EXIT_BLOCK_PTR_FOR_FN (cfun)
&& find_reg_note (BB_END (first), REG_CROSSING_JUMP, NULL_RTX))
&& JUMP_P (BB_END (first))
&& CROSSING_JUMP_P (BB_END (first)))
return changed;
while (counter < n_basic_blocks_for_fn (cfun))
@ -2797,7 +2798,7 @@ try_optimize_cfg (int mode)
if (single_succ_p (b)
&& single_succ (b) != EXIT_BLOCK_PTR_FOR_FN (cfun)
&& onlyjump_p (BB_END (b))
&& !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX)
&& !CROSSING_JUMP_P (BB_END (b))
&& try_redirect_by_replacing_jump (single_succ_edge (b),
single_succ (b),
(mode & CLEANUP_CFGLAYOUT) != 0))

View File

@ -965,7 +965,7 @@ tidy_fallthru_edges (void)
s = single_succ_edge (b);
if (! (s->flags & EDGE_COMPLEX)
&& s->dest == c
&& !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX))
&& !(JUMP_P (BB_END (b)) && CROSSING_JUMP_P (BB_END (b))))
tidy_fallthru_edge (s);
}
}

View File

@ -1325,8 +1325,6 @@ redirect_branch_edge (edge e, basic_block target)
static void
fixup_partition_crossing (edge e)
{
rtx note;
if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun) || e->dest
== EXIT_BLOCK_PTR_FOR_FN (cfun))
return;
@ -1337,10 +1335,9 @@ fixup_partition_crossing (edge e)
if (BB_PARTITION (e->src) != BB_PARTITION (e->dest))
{
e->flags |= EDGE_CROSSING;
note = find_reg_note (BB_END (e->src), REG_CROSSING_JUMP, NULL_RTX);
if (JUMP_P (BB_END (e->src))
&& !note)
add_reg_note (BB_END (e->src), REG_CROSSING_JUMP, NULL_RTX);
&& !CROSSING_JUMP_P (BB_END (e->src)))
CROSSING_JUMP_P (BB_END (e->src)) = 1;
}
else if (BB_PARTITION (e->src) == BB_PARTITION (e->dest))
{
@ -1348,8 +1345,7 @@ fixup_partition_crossing (edge e)
/* Remove the section crossing note from jump at end of
src if it exists, and if no other successors are
still crossing. */
note = find_reg_note (BB_END (e->src), REG_CROSSING_JUMP, NULL_RTX);
if (note)
if (JUMP_P (BB_END (e->src)) && CROSSING_JUMP_P (BB_END (e->src)))
{
bool has_crossing_succ = false;
edge e2;
@ -1361,7 +1357,7 @@ fixup_partition_crossing (edge e)
break;
}
if (!has_crossing_succ)
remove_note (BB_END (e->src), note);
CROSSING_JUMP_P (BB_END (e->src)) = 0;
}
}
}
@ -2460,8 +2456,7 @@ rtl_verify_edges (void)
e->src->index);
err = 1;
}
if (JUMP_P (BB_END (bb))
&& !find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX))
if (JUMP_P (BB_END (bb)) && !CROSSING_JUMP_P (BB_END (bb)))
{
error ("No region crossing jump at section boundary in bb %i",
bb->index);
@ -2496,7 +2491,8 @@ rtl_verify_edges (void)
}
if (!has_crossing_edge
&& find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX))
&& JUMP_P (BB_END (bb))
&& CROSSING_JUMP_P (BB_END (bb)))
{
print_rtl_with_bb (stderr, get_insns (), TDF_RTL | TDF_BLOCKS | TDF_DETAILS);
error ("Region crossing jump across same section in bb %i",

View File

@ -6051,7 +6051,7 @@ arc_reorg (void)
continue;
/* Now check if the jump is beyond the s9 range. */
if (find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX))
if (CROSSING_JUMP_P (insn))
continue;
offset = branch_dest (insn) - INSN_ADDRESSES (INSN_UID (insn));
@ -9206,7 +9206,7 @@ arc_decl_pretend_args (tree decl)
/* Without this, gcc.dg/tree-prof/bb-reorg.c fails to assemble
when compiling with -O2 -freorder-blocks-and-partition -fprofile-use
-D_PROFILE_USE; delay branch scheduling then follows a REG_CROSSING_JUMP
-D_PROFILE_USE; delay branch scheduling then follows a crossing jump
to redirect two breqs. */
static bool
@ -9216,7 +9216,7 @@ arc_can_follow_jump (const_rtx follower, const_rtx followee)
union { const_rtx c; rtx r; } u;
u.c = follower;
if (find_reg_note (followee, REG_CROSSING_JUMP, NULL_RTX))
if (CROSSING_JUMP_P (followee))
switch (get_attr_type (u.r))
{
case TYPE_BRCC:

View File

@ -3480,7 +3480,7 @@
(define_insn "jump_i"
[(set (pc) (label_ref (match_operand 0 "" "")))]
"!TARGET_LONG_CALLS_SET || !find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)"
"!TARGET_LONG_CALLS_SET || !CROSSING_JUMP_P (insn)"
"b%!%* %^%l0%&"
[(set_attr "type" "uncond_branch")
(set (attr "iscompact")
@ -3496,7 +3496,7 @@
(eq_attr "delay_slot_filled" "yes")
(const_int 4)
(match_test "find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)")
(match_test "CROSSING_JUMP_P (insn)")
(const_int 4)
(ior (lt (minus (match_dup 0) (pc)) (const_int -512))
@ -4589,7 +4589,7 @@
"(reload_completed
|| (TARGET_EARLY_CBRANCHSI
&& brcc_nolimm_operator (operands[0], VOIDmode)))
&& !find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)"
&& !CROSSING_JUMP_P (insn)"
"*
switch (get_attr_length (insn))
{
@ -4653,7 +4653,7 @@
(label_ref (match_operand 0 "" ""))
(pc)))
(clobber (reg:CC_ZN CC_REG))]
"!find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)"
"!CROSSING_JUMP_P (insn)"
{
switch (get_attr_length (insn))
{
@ -4693,7 +4693,7 @@
(label_ref (match_operand 0 "" ""))
(pc)))
(clobber (reg:CC_ZN CC_REG))]
"!find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)"
"!CROSSING_JUMP_P (insn)"
"#"
""
[(parallel

View File

@ -8804,7 +8804,7 @@ label:
(define_insn "jump_compact"
[(set (pc)
(label_ref (match_operand 0 "" "")))]
"TARGET_SH1 && !find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)"
"TARGET_SH1 && !CROSSING_JUMP_P (insn)"
{
/* The length is 16 if the delay slot is unfilled. */
if (get_attr_length(insn) > 4)

View File

@ -3590,11 +3590,13 @@ try_split (rtx pat, rtx trial, int last)
may have introduced invalid RTL sharing, so unshare the sequence now. */
unshare_all_rtl_in_chain (seq);
/* Mark labels. */
/* Mark labels and copy flags. */
for (insn = insn_last; insn ; insn = PREV_INSN (insn))
{
if (JUMP_P (insn))
{
if (JUMP_P (trial))
CROSSING_JUMP_P (insn) = CROSSING_JUMP_P (trial);
mark_jump_label (PATTERN (insn), insn, 0);
njumps++;
if (probability != -1
@ -3671,7 +3673,6 @@ try_split (rtx pat, rtx trial, int last)
break;
case REG_NON_LOCAL_GOTO:
case REG_CROSSING_JUMP:
for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn))
{
if (JUMP_P (insn))

View File

@ -7653,7 +7653,7 @@ sched_create_recovery_edges (basic_block first_bb, basic_block rec,
{
/* We don't need the same note for the check because
any_condjump_p (check) == true. */
add_reg_note (jump, REG_CROSSING_JUMP, NULL_RTX);
CROSSING_JUMP_P (jump) = 1;
}
edge_flags = EDGE_CROSSING;
}

View File

@ -3877,12 +3877,14 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
if ((BB_END (then_bb)
&& find_reg_note (BB_END (then_bb), REG_CROSSING_JUMP, NULL_RTX))
&& JUMP_P (BB_END (then_bb))
&& CROSSING_JUMP_P (BB_END (then_bb)))
|| (BB_END (test_bb)
&& find_reg_note (BB_END (test_bb), REG_CROSSING_JUMP, NULL_RTX))
&& JUMP_P (BB_END (test_bb))
&& CROSSING_JUMP_P (BB_END (test_bb)))
|| (BB_END (else_bb)
&& find_reg_note (BB_END (else_bb), REG_CROSSING_JUMP,
NULL_RTX)))
&& JUMP_P (BB_END (else_bb))
&& CROSSING_JUMP_P (BB_END (else_bb))))
return FALSE;
/* THEN has one successor. */
@ -4000,12 +4002,14 @@ find_if_case_2 (basic_block test_bb, edge then_edge, edge else_edge)
bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
if ((BB_END (then_bb)
&& find_reg_note (BB_END (then_bb), REG_CROSSING_JUMP, NULL_RTX))
&& JUMP_P (BB_END (then_bb))
&& CROSSING_JUMP_P (BB_END (then_bb)))
|| (BB_END (test_bb)
&& find_reg_note (BB_END (test_bb), REG_CROSSING_JUMP, NULL_RTX))
&& JUMP_P (BB_END (test_bb))
&& CROSSING_JUMP_P (BB_END (test_bb)))
|| (BB_END (else_bb)
&& find_reg_note (BB_END (else_bb), REG_CROSSING_JUMP,
NULL_RTX)))
&& JUMP_P (BB_END (else_bb))
&& CROSSING_JUMP_P (BB_END (else_bb))))
return FALSE;
/* ELSE has one successor. */

View File

@ -1590,11 +1590,7 @@ redirect_jump_2 (rtx jump, rtx olabel, rtx nlabel, int delete_unused,
label and are now changing it into a direct conditional return.
The jump is no longer crossing in that case. */
if (ANY_RETURN_P (nlabel))
{
note = find_reg_note (jump, REG_CROSSING_JUMP, NULL_RTX);
if (note)
remove_note (jump, note);
}
CROSSING_JUMP_P (jump) = 0;
if (!ANY_RETURN_P (olabel)
&& --LABEL_NUSES (olabel) == 0 && delete_unused > 0

View File

@ -188,11 +188,6 @@ REG_NOTE (NORETURN)
computed goto. */
REG_NOTE (NON_LOCAL_GOTO)
/* Indicates that a jump crosses between hot and cold sections in a
(partitioned) assembly or .o file, and therefore should not be
reduced to a simpler jump by optimizations. */
REG_NOTE (CROSSING_JUMP)
/* This kind of note is generated at each to `setjmp', and similar
functions that can return twice. */
REG_NOTE (SETJMP)

View File

@ -2289,8 +2289,8 @@ fill_simple_delay_slots (int non_jumps_p)
If LABEL is not followed by a jump, return LABEL.
If the chain loops or we can't find end, return LABEL,
since that tells caller to avoid changing the insn.
If the returned label is obtained by following a REG_CROSSING_JUMP
jump, set *CROSSING to true, otherwise set it to false. */
If the returned label is obtained by following a crossing jump,
set *CROSSING to true, otherwise set it to false. */
static rtx
follow_jumps (rtx label, rtx jump, bool *crossing)
@ -2330,8 +2330,7 @@ follow_jumps (rtx label, rtx jump, bool *crossing)
if (!targetm.can_follow_jump (jump, insn))
break;
if (!*crossing)
*crossing
= find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX) != NULL_RTX;
*crossing = CROSSING_JUMP_P (jump);
value = this_label;
}
if (depth == 10)
@ -2800,7 +2799,7 @@ fill_slots_from_thread (rtx insn, rtx condition, rtx thread,
{
reorg_redirect_jump (insn, label);
if (crossing)
set_unique_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX);
CROSSING_JUMP_P (insn) = 1;
}
}
@ -3175,7 +3174,7 @@ relax_delay_slots (rtx first)
{
reorg_redirect_jump (insn, target_label);
if (crossing)
set_unique_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX);
CROSSING_JUMP_P (insn) = 1;
}
/* See if this jump conditionally branches around an unconditional
@ -3320,7 +3319,7 @@ relax_delay_slots (rtx first)
reorg_redirect_jump (delay_insn, trial);
target_label = trial;
if (crossing)
set_unique_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX);
CROSSING_JUMP_P (insn) = 1;
}
/* If the first insn at TARGET_LABEL is redundant with a previous

View File

@ -276,6 +276,7 @@ struct GTY((chain_next ("RTX_NEXT (&%h)"),
/* 1 in a MEM if we should keep the alias set for this mem unchanged
when we access a component.
1 in a JUMP_INSN if it is a crossing jump.
1 in a CALL_INSN if it is a sibling call.
1 in a SET that is for a return.
In a CODE_LABEL, part of the two-bit alternate entry field.
@ -942,6 +943,10 @@ extern void rtl_check_failed_flag (const char *, const_rtx, const char *,
#define INSN_DELETED_P(RTX) \
(RTL_INSN_CHAIN_FLAG_CHECK ("INSN_DELETED_P", (RTX))->volatil)
/* 1 if JUMP RTX is a crossing jump. */
#define CROSSING_JUMP_P(RTX) \
(RTL_FLAG_CHECK1 ("CROSSING_JUMP_P", (RTX), JUMP_INSN)->jump)
/* 1 if RTX is a call to a const function. Built from ECF_CONST and
TREE_READONLY. */
#define RTL_CONST_CALL_P(RTX) \