diff options
Diffstat (limited to 'gcc/reorg.c')
-rw-r--r-- | gcc/reorg.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/gcc/reorg.c b/gcc/reorg.c index 97570e858dd..8d681685d69 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -2494,21 +2494,25 @@ fill_simple_delay_slots (int non_jumps_p) #endif } -/* Follow any unconditional jump at LABEL; +/* Follow any unconditional jump at LABEL, for the purpose of refirecting JUMP; return the ultimate label reached by any such chain of jumps. Return null if the chain ultimately leads to a return instruction. 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. */ + since that tells caller to avoid changing the insn. + If the returned label is obtained by following a REG_CROSSING_JUMP + jump, set *cp to (one of) the note(s), otherwise set it to NULL_RTX. */ static rtx -follow_jumps (rtx label) +follow_jumps (rtx label, rtx jump, rtx *cp) { rtx insn; rtx next; rtx value = label; int depth; + rtx crossing = NULL_RTX; + *cp = 0; for (depth = 0; (depth < 10 && (insn = next_active_insn (value)) != 0 @@ -2531,10 +2535,15 @@ follow_jumps (rtx label) || GET_CODE (PATTERN (tem)) == ADDR_DIFF_VEC)) break; + if (!targetm.can_follow_jump (jump, insn)) + break; + if (!crossing) + crossing = find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX); value = JUMP_LABEL (insn); } if (depth == 10) return label; + *cp = crossing; return value; } @@ -2974,6 +2983,7 @@ fill_slots_from_thread (rtx insn, rtx condition, rtx thread, if (new_thread != thread) { rtx label; + rtx crossing = NULL_RTX; gcc_assert (thread_if_true); @@ -2983,7 +2993,7 @@ fill_slots_from_thread (rtx insn, rtx condition, rtx thread, && redirect_with_delay_list_safe_p (insn, JUMP_LABEL (new_thread), delay_list)) - new_thread = follow_jumps (JUMP_LABEL (new_thread)); + new_thread = follow_jumps (JUMP_LABEL (new_thread), insn, &crossing); if (new_thread == 0) label = find_end_label (); @@ -2993,7 +3003,11 @@ fill_slots_from_thread (rtx insn, rtx condition, rtx thread, label = get_label_before (new_thread); if (label) - reorg_redirect_jump (insn, label); + { + reorg_redirect_jump (insn, label); + if (crossing) + set_unique_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX); + } } return delay_list; @@ -3327,6 +3341,7 @@ relax_delay_slots (rtx first) for (insn = first; insn; insn = next) { rtx other; + rtx crossing; next = next_active_insn (insn); @@ -3337,7 +3352,9 @@ relax_delay_slots (rtx first) && (condjump_p (insn) || condjump_in_parallel_p (insn)) && (target_label = JUMP_LABEL (insn)) != 0) { - target_label = skip_consecutive_labels (follow_jumps (target_label)); + target_label + = skip_consecutive_labels (follow_jumps (target_label, insn, + &crossing)); if (target_label == 0) target_label = find_end_label (); @@ -3349,7 +3366,11 @@ relax_delay_slots (rtx first) } if (target_label && target_label != JUMP_LABEL (insn)) - reorg_redirect_jump (insn, target_label); + { + reorg_redirect_jump (insn, target_label); + if (crossing) + set_unique_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX); + } /* See if this jump conditionally branches around an unconditional jump. If so, invert this jump and point it to the target of the @@ -3486,7 +3507,11 @@ relax_delay_slots (rtx first) { /* If this jump goes to another unconditional jump, thread it, but don't convert a jump into a RETURN here. */ - trial = skip_consecutive_labels (follow_jumps (target_label)); + rtx crossing; + + trial + = skip_consecutive_labels (follow_jumps (target_label, delay_insn, + &crossing)); if (trial == 0) trial = find_end_label (); @@ -3495,6 +3520,8 @@ 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); } /* If the first insn at TARGET_LABEL is redundant with a previous |