diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-10 19:16:20 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-09-10 19:16:20 +0000 |
commit | ec1e35b278e6a4d1ee909d7bb8b625a6694c11a8 (patch) | |
tree | 56d08387c52a8a24e834f4ec5cb02b4cf7d17bf9 /gcc/cgraphunit.c | |
parent | 5732ea94e04f0a876241880220eb6cbfb08bae84 (diff) | |
download | gcc-ec1e35b278e6a4d1ee909d7bb8b625a6694c11a8.tar.gz |
* cgraph.h (struct cgraph_node): Rename lowered to analyzed.
* cgraphunit.c: Update to match.
(record_call_1): Rearrange. Call lang hook for language nodes.
(cgraph_analyze_function): Don't call lower_function.
* langhooks.h (struct lang_hooks_for_callgraph): Replace
lower_function with analyze_expr.
* langhooks-def.h: Update to match.
* langhooks.c (lhd_callgraph_analyze_expr): New.
* decl2.c (cxx_callgraph_analyze_expr): New, from corpse of
mark_member_pointers.
(lower_function): Remove.
* cp-tree.h: Update to match.
* cp-lang.c (LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR): New.
(LANG_HOOKS_CALLGRAPH_LOWER_FUNCTION): Remove.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71277 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r-- | gcc/cgraphunit.c | 98 |
1 files changed, 60 insertions, 38 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 02edb697d10..bb55d2d3e8c 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -165,7 +165,7 @@ cgraph_finalize_function (tree decl) memset (&node->local, 0, sizeof (node->local)); memset (&node->global, 0, sizeof (node->global)); memset (&node->rtl, 0, sizeof (node->rtl)); - node->lowered = false; + node->analyzed = false; if (node->output) abort (); while (node->callees) @@ -209,41 +209,66 @@ cgraph_finalize_function (tree decl) static tree record_call_1 (tree *tp, int *walk_subtrees, void *data) { - if (TREE_CODE (*tp) == VAR_DECL && TREE_STATIC (*tp)) - cgraph_varpool_mark_needed_node (cgraph_varpool_node (*tp)); - /* Record dereferences to the functions. This makes the functions - reachable unconditionally. */ - else if (TREE_CODE (*tp) == ADDR_EXPR && flag_unit_at_a_time) - { - tree decl = TREE_OPERAND (*tp, 0); - if (TREE_CODE (decl) == FUNCTION_DECL) - cgraph_mark_needed_node (cgraph_node (decl)); - } - else if (TREE_CODE (*tp) == CALL_EXPR) + tree t = *tp; + + switch (TREE_CODE (t)) { - tree decl = get_callee_fndecl (*tp); - if (decl && TREE_CODE (decl) == FUNCTION_DECL) + case VAR_DECL: + /* ??? Really, we should mark this decl as *potentially* referenced + by this function and re-examine whether the decl is actually used + after rtl has been generated. */ + if (TREE_STATIC (t)) + cgraph_varpool_mark_needed_node (cgraph_varpool_node (t)); + break; + + case ADDR_EXPR: + if (flag_unit_at_a_time) + { + /* Record dereferences to the functions. This makes the + functions reachable unconditionally. */ + tree decl = TREE_OPERAND (*tp, 0); + if (TREE_CODE (decl) == FUNCTION_DECL) + cgraph_mark_needed_node (cgraph_node (decl)); + } + break; + + case CALL_EXPR: + { + tree decl = get_callee_fndecl (*tp); + if (decl && TREE_CODE (decl) == FUNCTION_DECL) + { + if (DECL_BUILT_IN (decl)) + return NULL; + cgraph_record_call (data, decl); + + /* When we see a function call, we don't want to look at the + function reference in the ADDR_EXPR that is hanging from + the CALL_EXPR we're examining here, because we would + conclude incorrectly that the function's address could be + taken by something that is not a function call. So only + walk the function parameter list, skip the other subtrees. */ + + walk_tree (&TREE_OPERAND (*tp, 1), record_call_1, data, + visited_nodes); + *walk_subtrees = 0; + } + break; + } + + default: + /* Save some cycles by not walking types and declaration as we + won't find anything useful there anyway. */ + if (DECL_P (*tp) || TYPE_P (*tp)) { - if (DECL_BUILT_IN (decl)) - return NULL; - cgraph_record_call (data, decl); - - /* When we see a function call, we don't want to look at the - function reference in the ADDR_EXPR that is hanging from - the CALL_EXPR we're examining here, because we would - conclude incorrectly that the function's address could be - taken by something that is not a function call. So only - walk the function parameter list, skip the other subtrees. */ - - walk_tree (&TREE_OPERAND (*tp, 1), record_call_1, data, - visited_nodes); *walk_subtrees = 0; + break; } + + if ((unsigned int) TREE_CODE (t) >= LAST_AND_UNUSED_TREE_CODE) + return (*lang_hooks.callgraph.analyze_expr) (tp, walk_subtrees, data); + break; } - /* Save some cycles by not walking types and declaration as we won't find anything - usefull there anyway. */ - if (DECL_P (*tp) || TYPE_P (*tp)) - *walk_subtrees = 0; + return NULL; } @@ -267,10 +292,7 @@ cgraph_analyze_function (struct cgraph_node *node) { tree decl = node->decl; - if (lang_hooks.callgraph.lower_function) - (*lang_hooks.callgraph.lower_function) (decl); - - current_function_decl = node->decl; + current_function_decl = decl; /* First kill forward declaration so reverse inlining works properly. */ cgraph_create_edges (decl, DECL_SAVED_TREE (decl)); @@ -286,13 +308,13 @@ cgraph_analyze_function (struct cgraph_node *node) /* Inlining characteristics are maintained by the cgraph_mark_inline. */ node->global.insns = node->local.self_insns; - if (!DECL_EXTERNAL (node->decl)) + if (!DECL_EXTERNAL (decl)) { node->global.cloned_times = 1; node->global.will_be_output = true; } - node->lowered = true; + node->analyzed = true; current_function_decl = NULL; } @@ -341,7 +363,7 @@ cgraph_finalize_compilation_unit (void) if (!DECL_SAVED_TREE (decl)) continue; - if (node->lowered || !node->reachable || !DECL_SAVED_TREE (decl)) + if (node->analyzed || !node->reachable || !DECL_SAVED_TREE (decl)) abort (); cgraph_analyze_function (node); |