projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add some localopts for shifting over the mode size
[libfirm]
/
ir
/
ir
/
irverify.c
diff --git
a/ir/ir/irverify.c
b/ir/ir/irverify.c
index
51d6c3a
..
b1169a4
100644
(file)
--- a/
ir/ir/irverify.c
+++ b/
ir/ir/irverify.c
@@
-757,10
+757,11
@@
static int verify_node_Block(ir_node *n, ir_graph *irg)
int i;
for (i = get_Block_n_cfgpreds(n) - 1; i >= 0; --i) {
int i;
for (i = get_Block_n_cfgpreds(n) - 1; i >= 0; --i) {
- ir_node *pred = get_Block_cfgpred(n, i);
+ ir_node *pred = get_Block_cfgpred(n, i);
+ ir_node *skipped_pred = skip_Proj(skip_Tuple(pred));
ASSERT_AND_RET(get_irn_mode(pred) == mode_X,
"Block node must have a mode_X predecessor", 0);
ASSERT_AND_RET(get_irn_mode(pred) == mode_X,
"Block node must have a mode_X predecessor", 0);
- ASSERT_AND_RET(is_cfop(skip
_Proj(skip_Tuple(pred))), "Block predecessor must be a cfop
", 0);
+ ASSERT_AND_RET(is_cfop(skip
ped_pred) || is_Bad(skipped_pred), "Block predecessor must be a cfop (or Bad)
", 0);
}
if (n == get_irg_start_block(irg)) {
}
if (n == get_irg_start_block(irg)) {
@@
-1825,6
+1826,7
@@
typedef struct check_cfg_env_t {
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;
@@
-1836,6
+1838,10
@@
static int check_block_cfg(ir_node *block, check_cfg_env_t *env)
int n_cfgpreds;
int i;
int n_cfgpreds;
int i;
+ 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) {
@@
-1933,6
+1939,12
@@
static void assert_branch(ir_node *node, void *data)
}
}
}
}
+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
*/
@@
-1941,9
+1953,13
@@
static int check_cfg(ir_graph *irg)
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 */
@@
-1964,6
+1980,7
@@
static int check_cfg(ir_graph *irg)
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;
}
@@
-1983,7
+2000,7
@@
int irg_verify(ir_graph *irg, unsigned flags)
last_irg_error = NULL;
#endif /* NDEBUG */
last_irg_error = NULL;
#endif /* NDEBUG */
- if (!check_cfg(irg))
+ if (
pinned &&
!check_cfg(irg))
res = 0;
if (res == 1 && (flags & VERIFY_ENFORCE_SSA) && pinned)
res = 0;
if (res == 1 && (flags & VERIFY_ENFORCE_SSA) && pinned)
@@
-2092,7
+2109,7
@@
static void check_bads(ir_node *node, void *env)
fprintf(stderr, "irg_verify_bads: Block %ld has Bad predecessor\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
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(irg, "
-
assert");
+ dump_ir_graph(irg, "assert");
assert(0 && "Bad CF detected");
}
}
assert(0 && "Bad CF detected");
}
}
@@
-2109,7
+2126,7
@@
static void check_bads(ir_node *node, void *env)
fprintf(stderr, "irg_verify_bads: node %ld has Bad Block\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
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(irg, "
-
assert");
+ dump_ir_graph(irg, "assert");
assert(0 && "Bad CF detected");
}
}
assert(0 && "Bad CF detected");
}
}
@@
-2123,7
+2140,7
@@
static void check_bads(ir_node *node, void *env)
fprintf(stderr, "irg_verify_bads: node %ld is a Tuple\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
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(irg, "
-
assert");
+ dump_ir_graph(irg, "assert");
assert(0 && "Tuple detected");
}
}
assert(0 && "Tuple detected");
}
}
@@
-2144,7
+2161,7
@@
static void check_bads(ir_node *node, void *env)
fprintf(stderr, "irg_verify_bads: Phi %ld has Bad Input\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
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(irg, "
-
assert");
+ dump_ir_graph(irg, "assert");
assert(0 && "Bad CF detected");
}
}
assert(0 && "Bad CF detected");
}
}
@@
-2158,7
+2175,7
@@
static void check_bads(ir_node *node, void *env)
fprintf(stderr, "irg_verify_bads: node %ld has Bad Input\n", get_irn_node_nr(node));
}
if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
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(irg, "
-
assert");
+ dump_ir_graph(irg, "assert");
assert(0 && "Bad NON-CF detected");
}
}
assert(0 && "Bad NON-CF detected");
}
}