From 1668aabc227d71870526e434415a6800cdeeba2f Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Mon, 23 Jun 2003 23:11:44 +0200 Subject: cgraph.c (cgraph_nodes_queue): Declare. * cgraph.c (cgraph_nodes_queue): Declare. (eq_node): Take identifier as p2. (cgraph_node): Update htab_find_slot_with_hash call. (cgraph_node_for_identifier): New. (cgraph_mark_needed_node): Move here from cgraphunit.c. * cgraph.h (cgraph_nodes_queue): Declare. (cgraph_node_for_identifier): Declare. * cgraphunit.c (cgraph_finalize_function): Collect entry points here instead of in cgraph_finalize_compilation_unit; constructors and destructors are entry points. (cgraph_finalize_compilation_unit): Reorganize debug outout; examine nested functions after lowerng; call collect_functions hook. (cgraph_mark_local_functions): DECL_COMDAT functions are not local. (cgraph_finalize_compilation_unit): Do not collect entry points. * varasm.c: Include cgraph.h (assemble_name): Mark referenced identifier as needed. * cgraphunit.c (record_call_1): Use get_callee_fndecl. From-SVN: r68390 --- gcc/cgraph.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'gcc/cgraph.c') diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 82e367f2929..b5753a12831 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -48,6 +48,9 @@ static htab_t cgraph_hash = 0; /* The linked list of cgraph nodes. */ struct cgraph_node *cgraph_nodes; +/* Queue of cgraph nodes scheduled to be lowered. */ +struct cgraph_node *cgraph_nodes_queue; + /* Number of nodes in existence. */ int cgraph_n_nodes; @@ -79,7 +82,7 @@ eq_node (p1, p2) const void *p2; { return ((DECL_ASSEMBLER_NAME (((struct cgraph_node *) p1)->decl)) == - DECL_ASSEMBLER_NAME ((tree) p2)); + (tree) p2); } /* Return cgraph node assigned to DECL. Create new one when needed. */ @@ -100,7 +103,8 @@ cgraph_node (decl) } slot = - (struct cgraph_node **) htab_find_slot_with_hash (cgraph_hash, decl, + (struct cgraph_node **) htab_find_slot_with_hash (cgraph_hash, + DECL_ASSEMBLER_NAME (decl), htab_hash_pointer (DECL_ASSEMBLER_NAME (decl)), 1); @@ -125,6 +129,30 @@ cgraph_node (decl) return node; } +/* Try to find existing function for identifier ID. */ +struct cgraph_node * +cgraph_node_for_identifier (id) + tree id; +{ + struct cgraph_node **slot; + + if (TREE_CODE (id) != IDENTIFIER_NODE) + abort (); + + if (!cgraph_hash) + { + cgraph_hash = htab_create (10, hash_node, eq_node, NULL); + VARRAY_TREE_INIT (known_fns, 32, "known_fns"); + } + + slot = + (struct cgraph_node **) htab_find_slot_with_hash (cgraph_hash, id, + htab_hash_pointer (id), 0); + if (!slot) + return NULL; + return *slot; +} + /* Create edge from CALLER to CALLEE in the cgraph. */ static struct cgraph_edge * @@ -194,6 +222,28 @@ cgraph_remove_node (node) /* Do not free the structure itself so the walk over chain can continue. */ } +/* Notify finalize_compilation_unit that given node is reachable + or needed. */ +void +cgraph_mark_needed_node (node, needed) + struct cgraph_node *node; + int needed; +{ + if (needed) + { + node->needed = 1; + } + if (!node->reachable) + { + node->reachable = 1; + if (DECL_SAVED_TREE (node->decl)) + { + node->aux = cgraph_nodes_queue; + cgraph_nodes_queue = node; + } + } +} + /* Record call from CALLER to CALLEE */ -- cgit v1.2.1