#include "target.h"
#include "cfgloop.h"
#include "ggc.h"
+#include "tree-pass.h"
static int can_delete_note_p (rtx);
static int can_delete_label_p (rtx);
{
basic_block newbb = rtl_create_basic_block (head, end, after);
- initialize_bb_rbi (newbb);
return newbb;
}
\f
BLOCK_FOR_INSN (insn) = NULL;
}
+struct tree_opt_pass pass_free_cfg =
+{
+ NULL, /* name */
+ NULL, /* gate */
+ free_bb_for_insn, /* execute */
+ NULL, /* sub */
+ NULL, /* next */
+ 0, /* static_pass_number */
+ 0, /* tv_id */
+ 0, /* properties_required */
+ 0, /* properties_provided */
+ PROP_cfg, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ 0, /* todo_flags_finish */
+ 0 /* letter */
+};
+
/* Return RTX to emit after when we want to emit code on the entry of function. */
rtx
entry_of_function (void)
{
- return (n_basic_blocks ? BB_HEAD (ENTRY_BLOCK_PTR->next_bb) : get_insns ());
+ return (n_basic_blocks > NUM_FIXED_BLOCKS ?
+ BB_HEAD (ENTRY_BLOCK_PTR->next_bb) : get_insns ());
}
/* Update insns block within BB. */
/* If there was a CODE_LABEL beginning B, delete it. */
if (LABEL_P (b_head))
{
+ /* This might have been an EH label that no longer has incoming
+ EH edges. Update data structures to match. */
+ maybe_remove_eh_handler (b_head);
+
/* Detect basic blocks with nothing but a label. This can happen
in particular at the end of a function. */
if (b_head == b_end)
/* Selectively unlink whole insn chain. */
if (in_cfglayout)
{
- rtx insn = src->rbi->footer;
+ rtx insn = src->il.rtl->footer;
delete_insn_chain (kill_from, BB_END (src));
if (PREV_INSN (insn))
NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
else
- src->rbi->footer = NEXT_INSN (insn);
+ src->il.rtl->footer = NEXT_INSN (insn);
if (NEXT_INSN (insn))
PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
}
by creating a basic block afterwards to redirect fallthru edge. */
if (e->src != ENTRY_BLOCK_PTR && e->dest != EXIT_BLOCK_PTR
&& any_condjump_p (BB_END (e->src))
- /* When called from cfglayout, fallthru edges do not
- necessarily go to the next block. */
- && e->src->next_bb == e->dest
&& JUMP_LABEL (BB_END (e->src)) == BB_HEAD (e->dest))
{
rtx note;
regset killed;
rtx save_regs = NULL_RTX;
unsigned regno;
- int noccmode;
enum machine_mode mode;
reg_set_iterator rsi;
-#ifdef AVOID_CCMODE_COPIES
- noccmode = true;
-#else
- noccmode = false;
-#endif
-
killed = ALLOC_REG_SET (®_obstack);
for (x = insn; x; x = NEXT_INSN (x))
if (mode == VOIDmode)
return false;
- if (noccmode && mode == CCmode)
+ /* Avoid copying in CCmode if we can't. */
+ if (!can_copy_p (mode))
return false;
save_regs = alloc_EXPR_LIST (0,
&& e->src != ENTRY_BLOCK_PTR
&& e->dest != EXIT_BLOCK_PTR))
{
- error ("Fallthru edge crosses section boundary (bb %i)",
+ error ("fallthru edge crosses section boundary (bb %i)",
e->src->index);
err = 1;
}
if (n_eh && GET_CODE (PATTERN (BB_END (bb))) != RESX
&& !find_reg_note (BB_END (bb), REG_EH_REGION, NULL_RTX))
{
- error ("Missing REG_EH_REGION note in the end of bb %i", bb->index);
+ error ("missing REG_EH_REGION note in the end of bb %i", bb->index);
err = 1;
}
if (n_branch
|| (n_branch > 1 && (any_uncondjump_p (BB_END (bb))
|| any_condjump_p (BB_END (bb))))))
{
- error ("Too many outgoing branch edges from bb %i", bb->index);
+ error ("too many outgoing branch edges from bb %i", bb->index);
err = 1;
}
if (n_fallthru && any_uncondjump_p (BB_END (bb)))
{
- error ("Fallthru edge after unconditional jump %i", bb->index);
+ error ("fallthru edge after unconditional jump %i", bb->index);
err = 1;
}
if (n_branch != 1 && any_uncondjump_p (BB_END (bb)))
{
- error ("Wrong amount of branch edges after unconditional jump %i", bb->index);
+ error ("wrong amount of branch edges after unconditional jump %i", bb->index);
err = 1;
}
if (n_branch != 1 && any_condjump_p (BB_END (bb))
&& JUMP_LABEL (BB_END (bb)) == BB_HEAD (fallthru->dest))
{
- error ("Wrong amount of branch edges after conditional jump %i", bb->index);
+ error ("wrong amount of branch edges after conditional jump %i", bb->index);
err = 1;
}
if (n_call && !CALL_P (BB_END (bb)))
{
- error ("Call edges for non-call insn in bb %i", bb->index);
+ error ("call edges for non-call insn in bb %i", bb->index);
err = 1;
}
if (n_abnormal
|| any_condjump_p (BB_END (bb))
|| any_uncondjump_p (BB_END (bb))))
{
- error ("Abnormal edges for no purpose in bb %i", bb->index);
+ error ("abnormal edges for no purpose in bb %i", bb->index);
err = 1;
}
curr_bb = NULL;
}
- if (num_bb_notes != n_basic_blocks)
+ if (num_bb_notes != n_basic_blocks - NUM_FIXED_BLOCKS)
internal_error
("number of bb notes in insn chain (%d) != n_basic_blocks (%d)",
num_bb_notes, n_basic_blocks);
/* Cleanup abnormal edges caused by exceptions or non-local gotos. */
for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
{
+ /* There are three types of edges we need to handle correctly here: EH
+ edges, abnormal call EH edges, and abnormal call non-EH edges. The
+ latter can appear when nonlocal gotos are used. */
if (e->flags & EDGE_EH)
{
- if (can_throw_internal (BB_END (bb)))
+ if (can_throw_internal (BB_END (bb))
+ /* If this is a call edge, verify that this is a call insn. */
+ && (! (e->flags & EDGE_ABNORMAL_CALL)
+ || CALL_P (BB_END (bb))))
{
ei_next (&ei);
continue;
rtx insn = insnp;
basic_block new_bb = rtl_split_block (bb, insn);
- new_bb->rbi->footer = bb->rbi->footer;
- bb->rbi->footer = NULL;
+ new_bb->il.rtl->footer = bb->il.rtl->footer;
+ bb->il.rtl->footer = NULL;
return new_bb;
}
{
rtx insn, next, prev = PREV_INSN (BB_HEAD (bb)), *to, remaints;
- if (bb->rbi->header)
+ if (bb->il.rtl->header)
{
next = BB_HEAD (bb);
if (prev)
- NEXT_INSN (prev) = bb->rbi->header;
+ NEXT_INSN (prev) = bb->il.rtl->header;
else
- set_first_insn (bb->rbi->header);
- PREV_INSN (bb->rbi->header) = prev;
- insn = bb->rbi->header;
+ set_first_insn (bb->il.rtl->header);
+ PREV_INSN (bb->il.rtl->header) = prev;
+ insn = bb->il.rtl->header;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
NEXT_INSN (insn) = next;
PREV_INSN (next) = insn;
}
next = NEXT_INSN (BB_END (bb));
- if (bb->rbi->footer)
+ if (bb->il.rtl->footer)
{
- insn = bb->rbi->footer;
+ insn = bb->il.rtl->footer;
while (insn)
{
if (BARRIER_P (insn))
if (PREV_INSN (insn))
NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn);
else
- bb->rbi->footer = NEXT_INSN (insn);
+ bb->il.rtl->footer = NEXT_INSN (insn);
if (NEXT_INSN (insn))
PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn);
}
break;
insn = NEXT_INSN (insn);
}
- if (bb->rbi->footer)
+ if (bb->il.rtl->footer)
{
insn = BB_END (bb);
- NEXT_INSN (insn) = bb->rbi->footer;
- PREV_INSN (bb->rbi->footer) = insn;
+ NEXT_INSN (insn) = bb->il.rtl->footer;
+ PREV_INSN (bb->il.rtl->footer) = insn;
while (NEXT_INSN (insn))
insn = NEXT_INSN (insn);
NEXT_INSN (insn) = next;
}
}
if (bb->next_bb != EXIT_BLOCK_PTR)
- to = &bb->next_bb->rbi->header;
+ to = &bb->next_bb->il.rtl->header;
else
to = &cfg_layout_function_footer;
- bb->rbi = NULL;
-
rtl_delete_block (bb);
if (prev)
/* If there was a CODE_LABEL beginning B, delete it. */
if (LABEL_P (BB_HEAD (b)))
- delete_insn (BB_HEAD (b));
+ {
+ /* This might have been an EH label that no longer has incoming
+ EH edges. Update data structures to match. */
+ maybe_remove_eh_handler (BB_HEAD (b));
+
+ delete_insn (BB_HEAD (b));
+ }
/* We should have fallthru edge in a, or we can do dummy redirection to get
it cleaned up. */
gcc_assert (!JUMP_P (BB_END (a)));
/* Possible line number notes should appear in between. */
- if (b->rbi->header)
+ if (b->il.rtl->header)
{
rtx first = BB_END (a), last;
- last = emit_insn_after_noloc (b->rbi->header, BB_END (a));
+ last = emit_insn_after_noloc (b->il.rtl->header, BB_END (a));
delete_insn_chain (NEXT_INSN (first), last);
- b->rbi->header = NULL;
+ b->il.rtl->header = NULL;
}
/* In the case basic blocks are not adjacent, move them around. */
}
/* Possible tablejumps and barriers should appear after the block. */
- if (b->rbi->footer)
+ if (b->il.rtl->footer)
{
- if (!a->rbi->footer)
- a->rbi->footer = b->rbi->footer;
+ if (!a->il.rtl->footer)
+ a->il.rtl->footer = b->il.rtl->footer;
else
{
- rtx last = a->rbi->footer;
+ rtx last = a->il.rtl->footer;
while (NEXT_INSN (last))
last = NEXT_INSN (last);
- NEXT_INSN (last) = b->rbi->footer;
- PREV_INSN (b->rbi->footer) = last;
+ NEXT_INSN (last) = b->il.rtl->footer;
+ PREV_INSN (b->il.rtl->footer) = last;
}
- b->rbi->footer = NULL;
+ b->il.rtl->footer = NULL;
}
a->il.rtl->global_live_at_end = b->il.rtl->global_live_at_end;
int last_bb = last_basic_block;
bool check_last_block = false;
- if (n_basic_blocks == 0)
+ if (n_basic_blocks == NUM_FIXED_BLOCKS)
return 0;
if (! blocks)
calls since there is no way that we can determine if they will
return or not... */
- for (i = 0; i < last_bb; i++)
+ for (i = NUM_FIXED_BLOCKS; i < last_bb; i++)
{
basic_block bb = BASIC_BLOCK (i);
rtx insn;