X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fcgraphbuild.c;h=bcc66c0eecd47de44e409839fe006288915901da;hb=6137cc9f21b973f99a8973268be7115e3fa10826;hp=d61def279ad44476ef37bec143c135055925bd08;hpb=7bfefa9d2c82e804ef4e59772f4060ac325bf99a;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index d61def279ad..bcc66c0eecd 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -33,13 +33,16 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" /* Walk tree and record all calls and references to functions/variables. - Called via walk_tree: TP is pointer to tree to be examined. */ + Called via walk_tree: TP is pointer to tree to be examined. + When DATA is non-null, record references to callgraph. + */ static tree -record_reference (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) +record_reference (tree *tp, int *walk_subtrees, void *data) { tree t = *tp; tree decl; + bool do_callgraph = data != NULL; switch (TREE_CODE (t)) { @@ -57,7 +60,7 @@ record_reference (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) /* Record dereferences to the functions. This makes the functions reachable unconditionally. */ decl = TREE_OPERAND (*tp, 0); - if (TREE_CODE (decl) == FUNCTION_DECL) + if (TREE_CODE (decl) == FUNCTION_DECL && do_callgraph) cgraph_mark_address_taken_node (cgraph_node (decl)); break; @@ -106,7 +109,8 @@ reset_inline_failed (struct cgraph_node *node) int compute_call_stmt_bb_frequency (tree decl, basic_block bb) { - int entry_freq = ENTRY_BLOCK_PTR->frequency; + int entry_freq = ENTRY_BLOCK_PTR_FOR_FUNCTION + (DECL_STRUCT_FUNCTION (decl))->frequency; int freq = bb->frequency; if (profile_status_for_function (DECL_STRUCT_FUNCTION (decl)) == PROFILE_ABSENT) @@ -202,7 +206,7 @@ struct gimple_opt_pass pass_build_cgraph_edges = { { GIMPLE_PASS, - NULL, /* name */ + "*build_cgraph_edges", /* name */ NULL, /* gate */ build_cgraph_edges, /* execute */ NULL, /* sub */ @@ -218,13 +222,15 @@ struct gimple_opt_pass pass_build_cgraph_edges = }; /* Record references to functions and other variables present in the - initial value of DECL, a variable. */ + initial value of DECL, a variable. + When ONLY_VARS is true, we mark needed only variables, not functions. */ void -record_references_in_initializer (tree decl) +record_references_in_initializer (tree decl, bool only_vars) { struct pointer_set_t *visited_nodes = pointer_set_create (); - walk_tree (&DECL_INITIAL (decl), record_reference, NULL, visited_nodes); + walk_tree (&DECL_INITIAL (decl), record_reference, + only_vars ? NULL : decl, visited_nodes); pointer_set_destroy (visited_nodes); } @@ -265,7 +271,7 @@ struct gimple_opt_pass pass_rebuild_cgraph_edges = { { GIMPLE_PASS, - NULL, /* name */ + "*rebuild_cgraph_edges", /* name */ NULL, /* gate */ rebuild_cgraph_edges, /* execute */ NULL, /* sub */ @@ -292,7 +298,7 @@ struct gimple_opt_pass pass_remove_cgraph_callee_edges = { { GIMPLE_PASS, - NULL, /* name */ + "*remove_cgraph_callee_edges", /* name */ NULL, /* gate */ remove_cgraph_callee_edges, /* execute */ NULL, /* sub */