return false;
default:
- abort ();
+ gcc_unreachable ();
}
}
return false;
default:
- abort ();
+ gcc_unreachable ();
}
}
static void
make_label_edge (sbitmap *edge_cache, basic_block src, rtx label, int flags)
{
- if (!LABEL_P (label))
- abort ();
+ gcc_assert (LABEL_P (label));
/* If the label was never emitted, this insn is junk, but avoid a
crash trying to refer to BLOCK_FOR_INSN (label). This can happen
current_function_has_computed_jump = 0;
/* If we are partitioning hot and cold basic blocks into separate
- sections, we cannot assume there is no computed jump. */
+ sections, we cannot assume there is no computed jump (partitioning
+ sometimes requires the use of indirect jumps; see comments about
+ partitioning at the top of bb-reorder.c:partition_hot_cold_basic_blocks
+ for complete details). */
if (flag_reorder_blocks_and_partition)
current_function_has_computed_jump = 1;
FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
{
edge e;
+ edge_iterator ei;
- for (e = bb->succ; e ; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest != EXIT_BLOCK_PTR)
SET_BIT (edge_cache[bb->index], e->dest->index);
}
enum rtx_code code;
int force_fallthru = 0;
edge e;
+ edge_iterator ei;
if (LABEL_P (BB_HEAD (bb))
&& LABEL_ALT_ENTRY_P (BB_HEAD (bb)))
/* Otherwise, we have a plain conditional or unconditional jump. */
else
{
- if (! JUMP_LABEL (insn))
- abort ();
+ gcc_assert (JUMP_LABEL (insn));
make_label_edge (edge_cache, bb, JUMP_LABEL (insn), 0);
}
}
/* Find out if we can drop through to the next block. */
insn = NEXT_INSN (insn);
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
{
insn = 0;
break;
default:
- abort ();
+ gcc_unreachable ();
}
}
else if (bb_note)
delete_insn (bb_note);
- if (last_basic_block != n_basic_blocks)
- abort ();
+ gcc_assert (last_basic_block == n_basic_blocks);
clear_aux_for_blocks ();
}
compute_outgoing_frequencies (basic_block b)
{
edge e, f;
+ edge_iterator ei;
- if (b->succ && b->succ->succ_next && !b->succ->succ_next->succ_next)
+ if (EDGE_COUNT (b->succs) == 2)
{
rtx note = find_reg_note (BB_END (b), REG_BR_PROB, NULL);
int probability;
- if (!note)
- return;
-
- probability = INTVAL (XEXP (note, 0));
- e = BRANCH_EDGE (b);
- e->probability = probability;
- e->count = ((b->count * probability + REG_BR_PROB_BASE / 2)
- / REG_BR_PROB_BASE);
- f = FALLTHRU_EDGE (b);
- f->probability = REG_BR_PROB_BASE - probability;
- f->count = b->count - e->count;
+ if (note)
+ {
+ probability = INTVAL (XEXP (note, 0));
+ e = BRANCH_EDGE (b);
+ e->probability = probability;
+ e->count = ((b->count * probability + REG_BR_PROB_BASE / 2)
+ / REG_BR_PROB_BASE);
+ f = FALLTHRU_EDGE (b);
+ f->probability = REG_BR_PROB_BASE - probability;
+ f->count = b->count - e->count;
+ return;
+ }
}
- if (b->succ && !b->succ->succ_next)
+ if (EDGE_COUNT (b->succs) == 1)
{
- e = b->succ;
+ e = EDGE_SUCC (b, 0);
e->probability = REG_BR_PROB_BASE;
e->count = b->count;
+ return;
}
+ guess_outgoing_edge_probabilities (b);
+ if (b->count)
+ FOR_EACH_EDGE (e, ei, b->succs)
+ e->count = ((b->count * e->probability + REG_BR_PROB_BASE / 2)
+ / REG_BR_PROB_BASE);
}
/* Assume that someone emitted code with control flow instructions to the
/* Update branch probabilities. Expect only (un)conditional jumps
to be created with only the forward edges. */
- FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
- {
- edge e;
-
- if (STATE (bb) == BLOCK_ORIGINAL)
- continue;
- if (STATE (bb) == BLOCK_NEW)
- {
- bb->count = 0;
- bb->frequency = 0;
- for (e = bb->pred; e; e = e->pred_next)
- {
- bb->count += e->count;
- bb->frequency += EDGE_FREQUENCY (e);
- }
- }
+ if (profile_status != PROFILE_ABSENT)
+ FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
+ {
+ edge e;
+ edge_iterator ei;
+
+ if (STATE (bb) == BLOCK_ORIGINAL)
+ continue;
+ if (STATE (bb) == BLOCK_NEW)
+ {
+ bb->count = 0;
+ bb->frequency = 0;
+ FOR_EACH_EDGE (e, ei, bb->preds)
+ {
+ bb->count += e->count;
+ bb->frequency += EDGE_FREQUENCY (e);
+ }
+ }
- compute_outgoing_frequencies (bb);
- }
+ compute_outgoing_frequencies (bb);
+ }
FOR_EACH_BB (bb)
SET_STATE (bb, 0);
FOR_BB_BETWEEN (b, min, max->next_bb, next_bb)
{
edge e;
+ edge_iterator ei;
if (b != min)
{
b->count = 0;
b->frequency = 0;
- for (e = b->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, b->preds)
{
b->count += e->count;
b->frequency += EDGE_FREQUENCY (e);