long proj = get_Proj_proj(p);
if (proj == pn_Load_res) {
- ir_node *ptr = get_Load_ptr(n);
+ ir_node *ptr = get_Load_ptr(n);
ir_entity *ent = get_ptr_entity(ptr);
+ ir_graph *irg = get_irn_irg(n);
- if (verify_entities && ent && get_irg_phase_state(current_ir_graph) == phase_high) {
+ if (verify_entities && ent && get_irg_phase_state(irg) == phase_high) {
/* do NOT check this for lowered phases, see comment on Store */
ASSERT_AND_RET_DBG(
(mode == get_type_mode(get_entity_type(ent))),
static int verify_node_Block(ir_node *n, ir_graph *irg)
{
int i;
- ir_node *mb = get_Block_MacroBlock(n);
-
- ASSERT_AND_RET(is_Block(mb) || is_Bad(mb), "Block node with wrong MacroBlock", 0);
-
- if (is_Block(mb) && mb != n) {
- ir_node *pred;
-
- /* Blocks with more than one predecessor must be header blocks */
- ASSERT_AND_RET(get_Block_n_cfgpreds(n) == 1, "partBlock with more than one predecessor", 0);
- if (get_irg_phase_state(irg) != phase_backend) {
- pred = get_Block_cfgpred(n, 0);
- if (is_Proj(pred)) {
- /* the predecessor MUST be a regular Proj */
- ir_node *frag_op = get_Proj_pred(pred);
- ASSERT_AND_RET(
- is_fragile_op(frag_op) && get_Proj_proj(pred) == pn_Generic_X_regular,
- "partBlock with non-regular predecessor", 0);
- } else {
- /* We allow Jmps to be predecessors of partBlocks. This can happen due to optimization
- of fragile nodes during construction. It does not violate our assumption of dominance
- so let it. */
- ASSERT_AND_RET(is_Jmp(pred) || is_Bad(pred),
- "partBlock with non-regular predecessor", 0);
- }
- } else {
- /* relax in backend: Bound nodes are probably lowered into conditional jumps */
- }
- }
for (i = get_Block_n_cfgpreds(n) - 1; i >= 0; --i) {
ir_node *pred = get_Block_cfgpred(n, i);
ASSERT_AND_RET(
- is_Bad(pred) || (get_irn_mode(pred) == mode_X),
+ is_Bad(pred) || (get_irn_mode(pred) == mode_X),
"Block node must have a mode_X predecessor", 0);
}
ASSERT_AND_RET(mymode == mode_T, "Store node", 0);
target = get_ptr_entity(get_Store_ptr(n));
- if (verify_entities && target && get_irg_phase_state(current_ir_graph) == phase_high) {
+ if (verify_entities && target && get_irg_phase_state(irg) == phase_high) {
/*
* If lowered code, any Sels that add 0 may be removed, causing
* an direct access to entities of array or compound type.
*/
static int check_dominance_for_node(ir_node *use)
{
- if (is_Block(use)) {
- ir_node *mbh = get_Block_MacroBlock(use);
-
- if (mbh != use) {
- /* must be a partBlock */
- if (is_Block(mbh)) {
- ASSERT_AND_RET(block_dominates(mbh, use), "MacroBlock header must dominate a partBlock", 0);
- }
- }
- }
/* This won't work for blocks and the end node */
- else if (use != get_irg_end(current_ir_graph) && use != current_ir_graph->anchor) {
+ if (!is_Block(use) && !is_End(use) && !is_Anchor(use)) {
int i;
ir_node *bl = get_nodes_block(use);
ir_node *def = get_irn_n(use, i);
ir_node *def_bl = get_nodes_block(def);
ir_node *use_bl = bl;
+ ir_graph *irg;
/* ignore dead definition blocks, will be removed */
if (is_Block_dead(def_bl) || get_Block_dom_depth(def_bl) == -1)
if (is_Block_dead(use_bl) || get_Block_dom_depth(use_bl) == -1)
continue;
+ irg = get_irn_irg(use);
ASSERT_AND_RET_DBG(
block_dominates(def_bl, use_bl),
"the definition of a value used violates the dominance property", 0,
ir_fprintf(stderr,
"graph %+F: %+F of %+F must dominate %+F of user %+F input %d\n",
- current_ir_graph, def_bl, def, use_bl, use, i
+ irg, def_bl, def, use_bl, use, i
);
);
}
int irn_verify(ir_node *n)
{
#ifdef DEBUG_libfirm
- return irn_verify_irg(n, current_ir_graph);
+ return irn_verify_irg(n, get_irn_irg(n));
#else
(void)n;
return 1;
*/
static void verify_wrap(ir_node *node, void *env)
{
- int *res = env;
- *res = irn_verify_irg(node, current_ir_graph);
+ int *res = (int*)env;
+ *res = irn_verify_irg(node, get_irn_irg(node));
}
/**
*/
static void verify_wrap_ssa(ir_node *node, void *env)
{
- int *res = env;
+ int *res = (int*)env;
- *res = irn_verify_irg(node, current_ir_graph);
+ *res = irn_verify_irg(node, get_irn_irg(node));
if (*res) {
*res = check_dominance_for_node(node);
}
{
int res = 1;
#ifdef DEBUG_libfirm
- ir_graph *rem;
-
- rem = current_ir_graph;
- current_ir_graph = irg;
#ifndef NDEBUG
last_irg_error = NULL;
fprintf(stderr, "irg_verify: Verifying graph %p failed\n", (void *)irg);
}
- current_ir_graph = rem;
#else
(void)irg;
(void)flags;
return res;
}
-struct pass_t {
+typedef struct pass_t {
ir_graph_pass_t pass;
unsigned flags;
-};
+} pass_t;
/**
* Wrapper to irg_verify to be run as an ir_graph pass.
*/
static int irg_verify_wrapper(ir_graph *irg, void *context)
{
- struct pass_t *pass = context;
+ pass_t *pass = (pass_t*)context;
irg_verify(irg, pass->flags);
/* do NOT rerun the pass if verify is ok :-) */
return 0;
/* Creates an ir_graph pass for irg_verify(). */
ir_graph_pass_t *irg_verify_pass(const char *name, unsigned flags)
{
- struct pass_t *pass = XMALLOCZ(struct pass_t);
+ pass_t *pass = XMALLOCZ(pass_t);
def_graph_pass_constructor(
&pass->pass, name ? name : "irg_verify", irg_verify_wrapper);
*/
static void check_bads(ir_node *node, void *env)
{
- verify_bad_env_t *venv = env;
+ verify_bad_env_t *venv = (verify_bad_env_t*)env;
int i, arity = get_irn_arity(node);
+ ir_graph *irg = get_irn_irg(node);
if (is_Block(node)) {
if ((venv->flags & BAD_CF) == 0) {
fprintf(stderr, "irg_verify_bads: Block %ld has Bad predecessor\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
- dump_ir_graph(current_ir_graph, "-assert");
+ dump_ir_graph(irg, "-assert");
assert(0 && "Bad CF detected");
}
}
fprintf(stderr, "irg_verify_bads: node %ld has Bad Block\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
- dump_ir_graph(current_ir_graph, "-assert");
+ dump_ir_graph(irg, "-assert");
assert(0 && "Bad CF detected");
}
}
fprintf(stderr, "irg_verify_bads: node %ld is a Tuple\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
- dump_ir_graph(current_ir_graph, "-assert");
+ dump_ir_graph(irg, "-assert");
assert(0 && "Tuple detected");
}
}
fprintf(stderr, "irg_verify_bads: Phi %ld has Bad Input\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
- dump_ir_graph(current_ir_graph, "-assert");
+ dump_ir_graph(irg, "-assert");
assert(0 && "Bad CF detected");
}
}
fprintf(stderr, "irg_verify_bads: node %ld has Bad Input\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
- dump_ir_graph(current_ir_graph, "-assert");
+ dump_ir_graph(irg, "-assert");
assert(0 && "Bad NON-CF detected");
}
}