arguments).
IS_VIRTUAL is true if SSA_NAME is created by a V_MAY_DEF or a
- V_MUST_DEF. */
+ V_MUST_DEF.
+
+ If NAMES_DEFINED_IN_BB is not NULL, it contains a bitmap of ssa names
+ that are defined before STMT in basic block BB. */
static bool
verify_use (basic_block bb, basic_block def_bb, tree ssa_name,
- tree stmt, bool check_abnormal, bool is_virtual)
+ tree stmt, bool check_abnormal, bool is_virtual,
+ bitmap names_defined_in_bb)
{
bool err = false;
def_bb->index, bb->index);
err = true;
}
+ else if (bb == def_bb
+ && names_defined_in_bb != NULL
+ && !bitmap_bit_p (names_defined_in_bb, SSA_NAME_VERSION (ssa_name)))
+ {
+ error ("Definition in block %i follows the use", def_bb->index);
+ err = true;
+ }
if (check_abnormal
&& !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ssa_name))
if (TREE_CODE (op) == SSA_NAME)
err = verify_use (e->src, definition_block[SSA_NAME_VERSION (op)], op,
phi, e->flags & EDGE_ABNORMAL,
- !is_gimple_reg (PHI_RESULT (phi)));
+ !is_gimple_reg (PHI_RESULT (phi)),
+ NULL);
if (e->dest != bb)
{
ssa_op_iter iter;
tree op;
enum dom_state orig_dom_state = dom_computed[CDI_DOMINATORS];
+ bitmap names_defined_in_bb = BITMAP_XMALLOC ();
timevar_push (TV_TREE_SSA_VERIFY);
/* Verify the arguments for every PHI node in the block. */
for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
- if (verify_phi_args (phi, bb, definition_block))
- goto err;
+ {
+ if (verify_phi_args (phi, bb, definition_block))
+ goto err;
+ bitmap_set_bit (names_defined_in_bb,
+ SSA_NAME_VERSION (PHI_RESULT (phi)));
+ }
/* Now verify all the uses and vuses in every statement of the block. */
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_VIRTUAL_USES)
{
if (verify_use (bb, definition_block[SSA_NAME_VERSION (op)],
- op, stmt, false, true))
+ op, stmt, false, true,
+ names_defined_in_bb))
goto err;
}
FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE)
{
if (verify_use (bb, definition_block[SSA_NAME_VERSION (op)],
- op, stmt, false, false))
+ op, stmt, false, false,
+ names_defined_in_bb))
goto err;
}
+
+ FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_ALL_DEFS)
+ {
+ bitmap_set_bit (names_defined_in_bb, SSA_NAME_VERSION (op));
+ }
}
+
+ /* Verify the uses in arguments of PHI nodes at the exits from the
+ block. */
+ for (e = bb->succ; e; e = e->succ_next)
+ {
+ for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
+ {
+ bool virtual = !is_gimple_reg (PHI_RESULT (phi));
+ op = PHI_ARG_DEF_FROM_EDGE (phi, e);
+ if (TREE_CODE (op) != SSA_NAME)
+ continue;
+
+ if (verify_use (bb, definition_block[SSA_NAME_VERSION (op)],
+ op, phi, false, virtual,
+ names_defined_in_bb))
+ goto err;
+ }
+ }
+
+ bitmap_clear (names_defined_in_bb);
}
/* Finally, verify alias information. */
else
dom_computed[CDI_DOMINATORS] = orig_dom_state;
+ BITMAP_XFREE (names_defined_in_bb);
timevar_pop (TV_TREE_SSA_VERIFY);
return;