summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ceb8c85)
This also ensures the invariant that at least 1 block in an endless
loop is kept.
int i;
for (i = 0; i < arity; i++) {
ir_node *pred = get_irn_n(node, i);
int i;
for (i = 0; i < arity; i++) {
ir_node *pred = get_irn_n(node, i);
- if (!is_Block(pred)) {
- pred = get_nodes_block(pred);
- }
- /* this walker is also used during optimize_graph_df where we can
- * temporarily have Bad as block inputs */
- if (is_Bad(pred))
continue;
irg_block_walk_2(pred, pre, post, env);
}
continue;
irg_block_walk_2(pred, pre, post, env);
}
pmap *branch_nodes; /**< map blocks to their branching nodes,
map mode_X nodes to the blocks they branch to */
int res;
pmap *branch_nodes; /**< map blocks to their branching nodes,
map mode_X nodes to the blocks they branch to */
int res;
+ ir_nodeset_t reachable_blocks;
ir_nodeset_t kept_nodes;
ir_nodeset_t true_projs;
ir_nodeset_t false_projs;
ir_nodeset_t kept_nodes;
ir_nodeset_t true_projs;
ir_nodeset_t false_projs;
+ ASSERT_AND_RET_DBG(ir_nodeset_contains(&env->reachable_blocks, block),
+ "Block is not reachable by blockwalker (endless loop with no kept block?)", 0,
+ ir_printf("block %+F\n", block));
+
n_cfgpreds = get_Block_n_cfgpreds(block);
branch_nodes = env->branch_nodes;
for (i = 0; i < n_cfgpreds; ++i) {
n_cfgpreds = get_Block_n_cfgpreds(block);
branch_nodes = env->branch_nodes;
for (i = 0; i < n_cfgpreds; ++i) {
+static void collect_reachable_blocks(ir_node *block, void *data)
+{
+ ir_nodeset_t *reachable_blocks = (ir_nodeset_t*) data;
+ ir_nodeset_insert(reachable_blocks, block);
+}
+
/**
* Checks CFG well-formedness
*/
/**
* Checks CFG well-formedness
*/
check_cfg_env_t env;
env.branch_nodes = pmap_create(); /**< map blocks to branch nodes */
env.res = 1;
check_cfg_env_t env;
env.branch_nodes = pmap_create(); /**< map blocks to branch nodes */
env.res = 1;
+ ir_nodeset_init(&env.reachable_blocks);
ir_nodeset_init(&env.true_projs);
ir_nodeset_init(&env.false_projs);
ir_nodeset_init(&env.true_projs);
ir_nodeset_init(&env.false_projs);
+ irg_block_walk_graph(irg, collect_reachable_blocks, NULL,
+ &env.reachable_blocks);
+
/* note that we do not use irg_walk_block because it will miss these
* invalid blocks without a jump instruction which we want to detect
* here */
/* note that we do not use irg_walk_block because it will miss these
* invalid blocks without a jump instruction which we want to detect
* here */
ir_nodeset_destroy(&env.false_projs);
ir_nodeset_destroy(&env.true_projs);
ir_nodeset_destroy(&env.kept_nodes);
ir_nodeset_destroy(&env.false_projs);
ir_nodeset_destroy(&env.true_projs);
ir_nodeset_destroy(&env.kept_nodes);
+ ir_nodeset_destroy(&env.reachable_blocks);
pmap_destroy(env.branch_nodes);
return env.res;
}
pmap_destroy(env.branch_nodes);
return env.res;
}