PROP_cfg, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- TODO_verify_stmts /* todo_flags_finish */
+ TODO_verify_stmts, /* todo_flags_finish */
+ 0 /* letter */
};
/* Search the CFG for any computed gotos. If found, factor them to a
create_block_annotation (basic_block bb)
{
/* Verify that the tree_annotations field is clear. */
- if (bb->tree_annotations)
- abort ();
+ gcc_assert (!bb->tree_annotations);
bb->tree_annotations = ggc_alloc_cleared (sizeof (struct bb_ann_d));
}
{
basic_block bb;
- if (e)
- abort ();
+ gcc_assert (!e);
/* Create and initialize a new basic block. */
bb = alloc_block ();
{
tree last = last_stmt (bb);
-#if defined ENABLE_CHECKING
- if (last == NULL_TREE)
- abort();
-#endif
-
+ gcc_assert (last);
switch (TREE_CODE (last))
{
case GOTO_EXPR:
break;
default:
- abort ();
+ gcc_unreachable ();
}
}
{
tree last = last_stmt (bb), op;
- if (last == NULL_TREE)
- abort ();
-
+ gcc_assert (last);
switch (TREE_CODE (last))
{
case CALL_EXPR:
break;
default:
- abort ();
+ gcc_unreachable ();
}
}
basic_block then_bb, else_bb;
tree then_label, else_label;
-#if defined ENABLE_CHECKING
- if (entry == NULL_TREE || TREE_CODE (entry) != COND_EXPR)
- abort ();
-#endif
+ gcc_assert (entry);
+ gcc_assert (TREE_CODE (entry) == COND_EXPR);
/* Entry basic blocks for each component. */
then_label = GOTO_DESTINATION (COND_EXPR_THEN (entry));
tree base_case, base_label, base_high, type;
base_case = TREE_VEC_ELT (labels, i);
- if (! base_case)
- abort ();
-
+ gcc_assert (base_case);
base_label = CASE_LABEL (base_case);
/* Discard cases that have the same destination as the
/* Ensure that B follows A. */
move_block_after (b, a);
- if (!(a->succ->flags & EDGE_FALLTHRU))
- abort ();
-
- if (last_stmt (a)
- && stmt_ends_bb_p (last_stmt (a)))
- abort ();
+ gcc_assert (a->succ->flags & EDGE_FALLTHRU);
+ gcc_assert (!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a)));
/* Remove labels from B and set bb_for_stmt to A for other statements. */
for (bsi = bsi_start (b); !bsi_end_p (bsi);)
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- TODO_dump_func /* todo_flags_finish */
+ TODO_dump_func, /* todo_flags_finish */
+ 0 /* letter */
};
continue;
}
- /* Invalidate the var if we encounter something that could modify it. */
+ /* Invalidate the var if we encounter something that could modify it.
+ Likewise for the value it was previously set to. Note that we only
+ consider values that are either a VAR_DECL or PARM_DECL so we
+ can test for conflict very simply. */
if (TREE_CODE (stmt) == ASM_EXPR
|| (TREE_CODE (stmt) == MODIFY_EXPR
- && TREE_OPERAND (stmt, 0) == var))
+ && (TREE_OPERAND (stmt, 0) == var
+ || TREE_OPERAND (stmt, 0) == val)))
return;
bsi_next (&bsi);
break;
default:
- abort ();
+ gcc_unreachable ();
}
taken_edge = find_taken_edge (bb, val);
/* Given a control block BB and a predicate VAL, return the edge that
will be taken out of the block. If VAL does not match a unique
- edge, NULL is returned. */
+ edge, NULL is returned. */
edge
find_taken_edge (basic_block bb, tree val)
stmt = last_stmt (bb);
-#if defined ENABLE_CHECKING
- if (stmt == NULL_TREE || !is_ctrl_stmt (stmt))
- abort ();
-#endif
+ gcc_assert (stmt);
+ gcc_assert (is_ctrl_stmt (stmt));
/* If VAL is a predicate of the form N RELOP N, where N is an
SSA_NAME, we can always determine its truth value (except when
dest_bb = label_to_block (CASE_LABEL (taken_case));
e = find_edge (bb, dest_bb);
- if (!e)
- abort ();
+ gcc_assert (e);
return e;
}
n1 = phi_arg_from_edge (phi, e1);
n2 = phi_arg_from_edge (phi, e2);
-#ifdef ENABLE_CHECKING
- if (n1 < 0 || n2 < 0)
- abort ();
-#endif
+ gcc_assert (n1 >= 0);
+ gcc_assert (n2 >= 0);
val1 = PHI_ARG_DEF (phi, n1);
val2 = PHI_ARG_DEF (phi, n2);
{
tree call;
-#if defined ENABLE_CHECKING
- if (t == NULL)
- abort ();
-#endif
-
+ gcc_assert (t);
call = get_call_expr_in (t);
if (call)
{
else if (e->flags & EDGE_FALSE_VALUE)
COND_EXPR_ELSE (stmt) = build_empty_stmt ();
else
- abort ();
+ gcc_unreachable ();
e->flags |= EDGE_FALLTHRU;
}
{
/* Remove the RETURN_EXPR if we may fall though to the exit
instead. */
- if (!bb->succ
- || bb->succ->succ_next
- || bb->succ->dest != EXIT_BLOCK_PTR)
- abort ();
+ gcc_assert (bb->succ);
+ gcc_assert (!bb->succ->succ_next);
+ gcc_assert (bb->succ->dest == EXIT_BLOCK_PTR);
if (bb->next_bb == EXIT_BLOCK_PTR
&& !TREE_OPERAND (stmt, 0))
if (!e || e->dest == bb->next_bb)
continue;
- if (e->dest == EXIT_BLOCK_PTR)
- abort ();
-
+ gcc_assert (e->dest != EXIT_BLOCK_PTR);
label = tree_block_label (e->dest);
stmt = build1 (GOTO_EXPR, void_type_node, label);
VARRAY_GROW (label_to_block_map, 3 * uid / 2);
}
else
- {
-#ifdef ENABLE_CHECKING
- /* We're moving an existing label. Make sure that we've
- removed it from the old block. */
- if (bb && VARRAY_BB (label_to_block_map, uid))
- abort ();
-#endif
- }
+ /* We're moving an existing label. Make sure that we've
+ removed it from the old block. */
+ gcc_assert (!bb || !VARRAY_BB (label_to_block_map, uid));
VARRAY_BB (label_to_block_map, uid) = bb;
}
}
}
+/* Finds iterator for STMT. */
+
+extern block_stmt_iterator
+stmt_for_bsi (tree stmt)
+{
+ block_stmt_iterator bsi;
+
+ for (bsi = bsi_start (bb_for_stmt (stmt)); !bsi_end_p (bsi); bsi_next (&bsi))
+ if (bsi_stmt (bsi) == stmt)
+ return bsi;
+
+ gcc_unreachable ();
+}
/* Insert statement (or statement list) T before the statement
pointed-to by iterator I. M specifies how to update iterator I
tree op = TREE_OPERAND (tmp, 0);
if (!is_gimple_val (op))
{
- if (TREE_CODE (op) != MODIFY_EXPR)
- abort ();
+ gcc_assert (TREE_CODE (op) == MODIFY_EXPR);
bsi_insert_before (bsi, op, BSI_NEW_STMT);
TREE_OPERAND (tmp, 0) = TREE_OPERAND (op, 0);
}
block_stmt_iterator bsi;
basic_block new_bb = NULL;
- if (PENDING_STMT (e))
- abort ();
+ gcc_assert (!PENDING_STMT (e));
if (tree_find_edge_insert_loc (e, &bsi, &new_bb))
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
int i, num_elem;
/* Abnormal edges cannot be split. */
- if (edge_in->flags & EDGE_ABNORMAL)
- abort ();
+ gcc_assert (!(edge_in->flags & EDGE_ABNORMAL));
src = edge_in->src;
dest = edge_in->dest;
after_bb = edge_in->src;
new_bb = create_empty_bb (after_bb);
+ new_bb->frequency = EDGE_FREQUENCY (edge_in);
+ new_bb->count = edge_in->count;
new_edge = make_edge (new_bb, dest, EDGE_FALLTHRU);
+ new_edge->probability = REG_BR_PROB_BASE;
+ new_edge->count = edge_in->count;
/* Find all the PHI arguments on the original edge, and change them to
the new edge. Do it before redirection, so that the argument does not
}
}
- if (!redirect_edge_and_branch (edge_in, new_bb))
- abort ();
-
- if (PENDING_STMT (edge_in))
- abort ();
+ e = redirect_edge_and_branch (edge_in, new_bb);
+ gcc_assert (e);
+ gcc_assert (!PENDING_STMT (edge_in));
return new_bb;
}
tree lab = CASE_LABEL (TREE_VEC_ELT (vec, i));
basic_block label_bb = label_to_block (lab);
- if (label_bb->aux && label_bb->aux != (void *)1)
- abort ();
+ gcc_assert (!label_bb->aux || label_bb->aux == (void *)1);
label_bb->aux = (void *)1;
}
forwardable. */
for (e = bb->succ; e; e = next)
{
+ int freq;
+ gcov_type count;
next = e->succ_next;
/* If the edge is abnormal or its destination is not
|| !tree_forwarder_block_p (e->dest))
continue;
+ count = e->count;
+ freq = EDGE_FREQUENCY (e);
+
/* Now walk through as many forwarder block as possible to
find the ultimate destination we want to thread our jump
to. */
break;
bb_ann (dest)->forwardable = 0;
+ dest->frequency -= freq;
+ if (dest->frequency < 0)
+ dest->frequency = 0;
+ dest->count -= count;
+ if (dest->count < 0)
+ dest->count = 0;
+ dest->succ->count -= count;
+ if (dest->succ->count < 0)
+ dest->succ->count = 0;
}
/* Reset the forwardable marks to 1. */
for (phi = phi_nodes (dest); phi; phi = PHI_CHAIN (phi))
{
arg = phi_arg_from_edge (phi, last);
- if (arg < 0)
- abort ();
+ gcc_assert (arg >= 0);
add_phi_arg (&phi, PHI_ARG_DEF (phi, arg), e);
}
}
case GOTO_EXPR:
/* No non-abnormal edges should lead from a non-simple goto, and
simple ones should be represented implicitly. */
- abort ();
+ gcc_unreachable ();
case SWITCH_EXPR:
{
default:
/* Otherwise it must be a fallthru edge, and we don't need to
do anything besides redirecting it. */
- if (!(e->flags & EDGE_FALLTHRU))
- abort ();
+ gcc_assert (e->flags & EDGE_FALLTHRU);
break;
}
tree_redirect_edge_and_branch_force (edge e, basic_block dest)
{
e = tree_redirect_edge_and_branch (e, dest);
- if (!e)
- abort ();
+ gcc_assert (e);
return NULL;
}
#ifdef ENABLE_CHECKING
if (stmt == last_stmt)
for (e = bb->succ; e; e = e->succ_next)
- if (e->dest == EXIT_BLOCK_PTR)
- abort ();
+ gcc_assert (e->dest != EXIT_BLOCK_PTR);
#endif
/* Note that the following may create a new basic block
PROP_no_crit_edges, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- TODO_dump_func, /* todo_flags_finish */
+ TODO_dump_func, /* todo_flags_finish */
+ 0 /* letter */
};
\f
0, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
- 0 /* todo_flags_finish */
+ 0, /* todo_flags_finish */
+ 0 /* letter */
};
#include "gt-tree-cfg.h"