+2007-06-06 Zdenek Dvorak <dvorakz@suse.cz>
+
+ * haifa-sched.c (restore_bb_notes): Clear bb field of the notes
+ emited outside of basic block.
+ * cfgbuild.c (find_bb_boundaries): Clear bb field for insns between
+ the created blocks.
+ * rtl.h (delete_insn_chain): Declaration changed.
+ * cfgrtl.c (delete_insn_chain): Add option to clear bb field for
+ non-removed insns.
+ (rtl_delete_block, rtl_merge_blocks): Pass true to delete_insn_chain.
+ (delete_insn_chain_and_edges, try_redirect_by_replacing_jump,
+ rtl_tidy_fallthru_edge, cfg_layout_merge_blocks): Pass false
+ to delete_insn_chain.
+ (rtl_verify_flow_info_1): Verify that the insns in header and footer
+ do not have bb field set.
+ (rtl_verify_flow_info): Verify that insns between basic blocks do not
+ have bb field set.
+ * recog.c (peephole2_optimize): Add argument to delete_insn_chain call.
+ * cfgcleanup.c (try_optimize_cfg): Ditto.
+
2007-06-06 Thomas Neumann <tneumann@users.sourceforge.net>
* lambda-code.c (struct lambda_lattice_s): Add a name to the struct.
{
basic_block orig_bb = bb;
rtx insn = BB_HEAD (bb);
- rtx end = BB_END (bb);
+ rtx end = BB_END (bb), x;
rtx table;
rtx flow_transfer_insn = NULL_RTX;
edge fallthru = NULL;
{
fallthru = split_block (bb, PREV_INSN (insn));
if (flow_transfer_insn)
- BB_END (bb) = flow_transfer_insn;
+ {
+ BB_END (bb) = flow_transfer_insn;
+
+ /* Clean up the bb field for the insns between the blocks. */
+ for (x = NEXT_INSN (flow_transfer_insn);
+ x != BB_HEAD (fallthru->dest);
+ x = NEXT_INSN (x))
+ if (!BARRIER_P (x))
+ set_block_for_insn (x, NULL);
+ }
bb = fallthru->dest;
remove_edge (fallthru);
{
fallthru = split_block (bb, PREV_INSN (insn));
BB_END (bb) = flow_transfer_insn;
+
+ /* Clean up the bb field for the insns between the blocks. */
+ for (x = NEXT_INSN (flow_transfer_insn);
+ x != BB_HEAD (fallthru->dest);
+ x = NEXT_INSN (x))
+ if (!BARRIER_P (x))
+ set_block_for_insn (x, NULL);
+
bb = fallthru->dest;
remove_edge (fallthru);
flow_transfer_insn = NULL_RTX;
return and barrier, or possibly other sequence not behaving like
ordinary jump, we need to take care and move basic block boundary. */
if (flow_transfer_insn)
- BB_END (bb) = flow_transfer_insn;
+ {
+ BB_END (bb) = flow_transfer_insn;
+
+ /* Clean up the bb field for the insns that do not belong to BB. */
+ x = flow_transfer_insn;
+ while (x != end)
+ {
+ x = NEXT_INSN (x);
+ if (!BARRIER_P (x))
+ set_block_for_insn (x, NULL);
+ }
+ }
/* We've possibly replaced the conditional jump by conditional jump
followed by cleanup at fallthru edge, so the outgoing edges may
}
/* Unlink a chain of insns between START and FINISH, leaving notes
- that must be paired. */
+ that must be paired. If CLEAR_BB is true, we set bb field for
+ insns that cannot be removed to NULL. */
void
-delete_insn_chain (rtx start, rtx finish)
+delete_insn_chain (rtx start, rtx finish, bool clear_bb)
{
rtx next;
else
next = delete_insn (start);
+ if (clear_bb && !INSN_DELETED_P (start))
+ set_block_for_insn (start, NULL);
+
if (start == finish)
break;
start = next;
&& BLOCK_FOR_INSN (last)
&& BB_END (BLOCK_FOR_INSN (last)) == last)
purge = true;
- delete_insn_chain (first, last);
+ delete_insn_chain (first, last, false);
if (purge)
purge_dead_edges (BLOCK_FOR_INSN (last));
}
/* Selectively delete the entire chain. */
BB_HEAD (b) = NULL;
- delete_insn_chain (insn, end);
+ delete_insn_chain (insn, end, true);
+
if (b->il.rtl->global_live_at_start)
{
FREE_REG_SET (b->il.rtl->global_live_at_start);
/* Delete everything marked above as well as crap that might be
hanging out between the two blocks. */
BB_HEAD (b) = NULL;
- delete_insn_chain (del_first, del_last);
+ delete_insn_chain (del_first, del_last, true);
/* Reassociate the insns of B with A. */
if (!b_empty)
{
rtx insn = src->il.rtl->footer;
- delete_insn_chain (kill_from, BB_END (src));
+ delete_insn_chain (kill_from, BB_END (src), false);
/* Remove barriers but keep jumptables. */
while (insn)
}
}
else
- delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)));
+ delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)),
+ false);
}
/* If this already is simplejump, redirect it. */
INSN_UID (insn), INSN_UID (BB_END (src)));
- delete_insn_chain (kill_from, insn);
+ delete_insn_chain (kill_from, insn, false);
/* Recognize a tablejump that we are converting to a
simple jump and remove its associated CODE_LABEL
and ADDR_VEC or ADDR_DIFF_VEC. */
if (tablejump_p (insn, &label, &table))
- delete_insn_chain (label, table);
+ delete_insn_chain (label, table, false);
barrier = next_nonnote_insn (BB_END (src));
if (!barrier || !BARRIER_P (barrier))
/* Selectively unlink the sequence. */
if (q != PREV_INSN (BB_HEAD (c)))
- delete_insn_chain (NEXT_INSN (q), PREV_INSN (BB_HEAD (c)));
+ delete_insn_chain (NEXT_INSN (q), PREV_INSN (BB_HEAD (c)), false);
e->flags |= EDGE_FALLTHRU;
}
bb->index);
err = 1;
}
+
+ for (insn = bb->il.rtl->header; insn; insn = NEXT_INSN (insn))
+ if (!BARRIER_P (insn)
+ && BLOCK_FOR_INSN (insn) != NULL)
+ {
+ error ("insn %d in header of bb %d has non-NULL basic block",
+ INSN_UID (insn), bb->index);
+ err = 1;
+ }
+ for (insn = bb->il.rtl->footer; insn; insn = NEXT_INSN (insn))
+ if (!BARRIER_P (insn)
+ && BLOCK_FOR_INSN (insn) != NULL)
+ {
+ error ("insn %d in footer of bb %d has non-NULL basic block",
+ INSN_UID (insn), bb->index);
+ err = 1;
+ }
}
/* Now check the basic blocks (boundaries etc.) */
rtx head = BB_HEAD (bb);
rtx end = BB_END (bb);
- /* Verify the end of the basic block is in the INSN chain. */
for (x = last_head; x != NULL_RTX; x = PREV_INSN (x))
- if (x == end)
- break;
+ {
+ /* Verify the end of the basic block is in the INSN chain. */
+ if (x == end)
+ break;
+
+ /* And that the code outside of basic blocks has NULL bb field. */
+ if (!BARRIER_P (x)
+ && BLOCK_FOR_INSN (x) != NULL)
+ {
+ error ("insn %d outside of basic blocks has non-NULL bb field",
+ INSN_UID (x));
+ err = 1;
+ }
+ }
if (!x)
{
err = 1;
}
- last_head = x;
+ last_head = PREV_INSN (x);
FOR_EACH_EDGE (e, ei, bb->succs)
if (e->flags & EDGE_FALLTHRU)
}
}
+ for (x = last_head; x != NULL_RTX; x = PREV_INSN (x))
+ {
+ /* Check that the code before the first basic block has NULL
+ bb field. */
+ if (!BARRIER_P (x)
+ && BLOCK_FOR_INSN (x) != NULL)
+ {
+ error ("insn %d outside of basic blocks has non-NULL bb field",
+ INSN_UID (x));
+ err = 1;
+ }
+ }
free (bb_info);
num_bb_notes = 0;
rtx first = BB_END (a), last;
last = emit_insn_after_noloc (b->il.rtl->header, BB_END (a));
- delete_insn_chain (NEXT_INSN (first), last);
+ delete_insn_chain (NEXT_INSN (first), last, false);
b->il.rtl->header = NULL;
}