aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2013-08-08 16:15:15 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2013-08-08 14:15:15 +0000
commit71cafea943fbb7a69a92c80e6dfdb5de119bfb33 (patch)
treea15a1a431d19e3655466a7906f95ba58df17e24a /gcc/cgraph.c
parent27d2e61268434dc682b81227e93ae9022d4d290f (diff)
downloadgcc-71cafea943fbb7a69a92c80e6dfdb5de119bfb33.zip
gcc-71cafea943fbb7a69a92c80e6dfdb5de119bfb33.tar.gz
gcc-71cafea943fbb7a69a92c80e6dfdb5de119bfb33.tar.bz2
cgraphbuild.c (build_cgraph_edges): Do not walk into debugs.
* cgraphbuild.c (build_cgraph_edges): Do not walk into debugs. (make_pass_rebuild_cgraph_edges): Also clear references. * cgraph.c (verify_cgraph_node): Add basic ipa-ref verifier. * ipa-inline-transform.c (inline_transform): Remove all references after inlining. * cgraphunit.c (expand_function): Remove all references after expansion. * ipa-ref.c (ipa_ref_has_aliases_p): Fix formatting. (ipa_find_reference): Rewrite to iterator. (remove_stmt_references): Likewise. (ipa_clear_stmts_in_references): New function. * ipa-ref.h (ipa_clear_stmts_in_references): Declare. * cgraphclones.c (cgraph_materialize_all_clones): Remove or clear references. * ipa-split.c (split_function): Remove references in split function. From-SVN: r201601
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c110
1 files changed, 65 insertions, 45 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index bb7016f..d217b4a 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2537,55 +2537,75 @@ verify_cgraph_node (struct cgraph_node *node)
{
if (this_cfun->cfg)
{
+ pointer_set_t *stmts = pointer_set_create ();
+ int i;
+ struct ipa_ref *ref;
+
/* Reach the trees by walking over the CFG, and note the
enclosing basic-blocks in the call edges. */
FOR_EACH_BB_FN (this_block, this_cfun)
- for (gsi = gsi_start_bb (this_block);
- !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gimple stmt = gsi_stmt (gsi);
- if (is_gimple_call (stmt))
- {
- struct cgraph_edge *e = cgraph_edge (node, stmt);
- tree decl = gimple_call_fndecl (stmt);
- if (e)
- {
- if (e->aux)
- {
- error ("shared call_stmt:");
- cgraph_debug_gimple_stmt (this_cfun, stmt);
- error_found = true;
- }
- if (!e->indirect_unknown_callee)
- {
- if (verify_edge_corresponds_to_fndecl (e, decl))
- {
- error ("edge points to wrong declaration:");
- debug_tree (e->callee->symbol.decl);
- fprintf (stderr," Instead of:");
- debug_tree (decl);
- error_found = true;
- }
- }
- else if (decl)
- {
- error ("an indirect edge with unknown callee "
- "corresponding to a call_stmt with "
- "a known declaration:");
- error_found = true;
- cgraph_debug_gimple_stmt (this_cfun, e->call_stmt);
- }
- e->aux = (void *)1;
- }
- else if (decl)
- {
- error ("missing callgraph edge for call stmt:");
- cgraph_debug_gimple_stmt (this_cfun, stmt);
- error_found = true;
- }
- }
+ {
+ for (gsi = gsi_start_phis (this_block);
+ !gsi_end_p (gsi); gsi_next (&gsi))
+ pointer_set_insert (stmts, gsi_stmt (gsi));
+ for (gsi = gsi_start_bb (this_block);
+ !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+ pointer_set_insert (stmts, stmt);
+ if (is_gimple_call (stmt))
+ {
+ struct cgraph_edge *e = cgraph_edge (node, stmt);
+ tree decl = gimple_call_fndecl (stmt);
+ if (e)
+ {
+ if (e->aux)
+ {
+ error ("shared call_stmt:");
+ cgraph_debug_gimple_stmt (this_cfun, stmt);
+ error_found = true;
+ }
+ if (!e->indirect_unknown_callee)
+ {
+ if (verify_edge_corresponds_to_fndecl (e, decl))
+ {
+ error ("edge points to wrong declaration:");
+ debug_tree (e->callee->symbol.decl);
+ fprintf (stderr," Instead of:");
+ debug_tree (decl);
+ error_found = true;
+ }
+ }
+ else if (decl)
+ {
+ error ("an indirect edge with unknown callee "
+ "corresponding to a call_stmt with "
+ "a known declaration:");
+ error_found = true;
+ cgraph_debug_gimple_stmt (this_cfun, e->call_stmt);
+ }
+ e->aux = (void *)1;
+ }
+ else if (decl)
+ {
+ error ("missing callgraph edge for call stmt:");
+ cgraph_debug_gimple_stmt (this_cfun, stmt);
+ error_found = true;
+ }
+ }
+ }
}
+ for (i = 0;
+ ipa_ref_list_reference_iterate (&node->symbol.ref_list, i, ref);
+ i++)
+ if (ref->stmt && !pointer_set_contains (stmts, ref->stmt))
+ {
+ error ("reference to dead statement");
+ cgraph_debug_gimple_stmt (this_cfun, ref->stmt);
+ error_found = true;
+ }
+ pointer_set_destroy (stmts);
}
else
/* No CFG available?! */