diff options
author | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-07-24 12:07:13 +0000 |
---|---|---|
committer | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-07-24 12:07:13 +0000 |
commit | 415d1b9a7810774124b32b9dc3990c81ba96efaa (patch) | |
tree | 4dd09f8eb18392a620ad92b028d01fbda5d27ee7 /gcc/cgraph.c | |
parent | a0792f1ef98b4610cc0a20de07c5f891e4c345a1 (diff) | |
download | gcc-415d1b9a7810774124b32b9dc3990c81ba96efaa.tar.gz |
IPA C++ refactoring 1/N
* cgraph.h (symtab_node):
(void register_symbol (void)): created from symtab_register_node
(void remove (void)): created from symtab_remove_node
(void dump (FILE *f)): created from dump_symtab_node
(void DEBUG_FUNCTION debug (void)): created from debug_symtab_node
(void DEBUG_FUNCTION verify (void)): created from verify_symtab_node
(struct ipa_ref *add_reference (symtab_node *referred_node,
enum ipa_ref_use use_type)): created from add_reference
(struct ipa_ref *add_reference (symtab_node *referred_node,
enum ipa_ref_use use_type, gimple stmt)): created from add_reference
(struct ipa_ref *maybe_add_reference (tree val, enum ipa_ref_use use_type,
gimple stmt)): created from maybe_add_reference
(bool semantically_equivalent_p (symtab_node *target)): created from
symtab_semantically_equivalent_p
(void remove_from_same_comdat_group (void)): created from
remove_from_same_comdat_group
(void add_to_same_comdat_group (symtab_node *old_node)): created from
symtab_add_to_same_comdat_group
(void dissolve_same_comdat_group_list (void)): created from
symtab_dissolve_same_comdat_group_list
(bool used_from_object_file_p (void)): created from symtab_used_from_object_file_p
(symtab_node *ultimate_alias_target (enum availability *avail = NULL)):
created from symtab_alias_ultimate_target
(inline symtab_node *next_defined_symbol (void)): created from
symtab_next_defined_symbol
(bool resolve_alias (symtab_node *target)): created from
symtab_resolve_alias
(bool call_for_symbol_and_aliases (bool (*callback) (symtab_node *, void *),
void *data, bool include_overwrite)): created from symtab_for_node_and_aliases
(symtab_node *noninterposable_alias (void)): created from symtab_nonoverwritable_alias
(inline symtab_node *get_alias_target (void)): created from symtab_alias_target
(void set_section (const char *section)): created from set_section_1
(enum availability get_availability (void)): created from symtab_node_availability
(void make_decl_local (void)): created from symtab_make_decl_local
(bool real_symbol_p (void)): created from symtab_read_node
(can_be_discarded_p (void)): created from symtab_can_be_discarded
(inline bool comdat_local_p (void)): created from symtab_comdat_local_p
(inline bool in_same_comdat_group_p (symtab_node *target)): created from
symtab_in_same_comdat_p;
(bool address_taken_from_non_vtable_p (void)): created from
address_taken_from_non_vtable_p
(static inline symtab_node *get (const_tree decl)): created from symtab_get_node
(static void dump_table (FILE *)): created from dump_symtab
(static inline DEBUG_FUNCTION void debug_symtab (void)): created from debug_symtab
(static DEBUG_FUNCTION void verify_symtab_nodes (void)): created from verify_symtab
(static bool used_from_object_file_p_worker (symtab_node *node)): created from
symtab_used_from_object_file_p
(void dump_base (FILE *)): created from dump_symtab_base
(bool DEBUG_FUNCTION verify_base (void)): created from verify_symtab_base
(void unregister (void)): created from symtab_unregister_node
(struct symbol_priority_map *priority_info (void)): created from symtab_priority_info
(static bool set_implicit_section (symtab_node *n, void *)): created from set_implicit_section
(static bool noninterposable_alias (symtab_node *node, void *data)): created from
symtab_nonoverwritable_alias_1
* cgraph.h (cgraph_node):
(bool remove_symbol_and_inline_clones (cgraph_node *forbidden_node = NULL)):
created from cgraph_remove_node_and_inline_clones
(void record_stmt_references (gimple stmt)): created from ipa_record_stmt_references
(void set_call_stmt_including_clones (gimple old_stmt, gimple new_stmt,
bool update_speculative = true)): created from cgraph_set_call_stmt_including_clones
(cgraph_node *function_symbol (enum availability *avail = NULL)):
created from cgraph_function_node
(cgraph_node *create_clone (tree decl, gcov_type count, int freq, bool update_original,
vec<cgraph_edge *> redirect_callers, bool call_duplication_hook,
struct cgraph_node *new_inlined_to, bitmap args_to_skip)):
created from cgraph_create_clone
(cgraph_node *create_virtual_clone (vec<cgraph_edge *> redirect_callers,
vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip, const char * suffix)):
created from cgraph_create_virtual_clone
(cgraph_node *find_replacement (void)): created from cgraph_find_replacement_node
(cgraph_node *create_version_clone (tree new_decl, vec<cgraph_edge *> redirect_callers,
bitmap bbs_to_copy)): created from cgraph_copy_node_for_versioning
(cgraph_node *create_version_clone_with_body (vec<cgraph_edge *> redirect_callers,
vec<ipa_replace_map *, va_gc> *tree_map, bitmap args_to_skip, bool skip_return,
bitmap bbs_to_copy, basic_block new_entry_block, const char *clone_name)):
created from cgraph_function_version_info
(struct cgraph_function_version_info *insert_new_function_version (void)):
created from insert_new_cgraph_node_version
(struct cgraph_function_version_info *function_version (void)): created from
get_cgraph_node_version
(void analyze (void)): created from analyze_function
(cgraph_node * create_thunk (tree alias, tree, bool this_adjusting,
HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value, tree virtual_offset,
tree real_alias) cgraph_add_thunk
(inline cgraph_node *get_alias_target (void)): created from cgraph_alias_target
(cgraph_node *ultimate_alias_target (availability *availability = NULL)):
created from cgraph_function_or_thunk_node
(bool expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)):
created from expand_thunk
(void reset (void)): created from cgraph_reset_node
(void create_wrapper (cgraph_node *target)): created from cgraph_make_wrapper
(void DEBUG_FUNCTION verify_node (void)): created from verify_cgraph_node
(void remove (void)): created from cgraph_remove_node
(void dump (FILE *f)): created from dump_cgraph_node
(void DEBUG_FUNCTION debug (void)): created from debug_cgraph_node
(bool get_body (void)): created from cgraph_get_body
(void release_body (void)): created from cgraph_release_function_body
(void unnest (void)): created from cgraph_unnest_node
(void make_local (void)): created from cgraph_make_node_local
(void mark_address_taken (void)): created from cgraph_mark_address_taken_node
(struct cgraph_edge *create_edge (cgraph_node *callee, gimple call_stmt,
gcov_type count, int freq)): created from cgraph_create_edge
(struct cgraph_edge *create_indirect_edge (gimple call_stmt, int ecf_flags,
gcov_type count, int freq)): created from cgraph_create_indirect_edge
(void create_edge_including_clones (struct cgraph_node *callee, gimple old_stmt,
gimple stmt, gcov_type count, int freq, cgraph_inline_failed_t reason)):
created from cgraph_create_edge_including_clones
(cgraph_edge *get_edge (gimple call_stmt)): created from cgraph_edge
(vec<cgraph_edge *> collect_callers (void)): created from collect_callers_of_node
(void remove_callers (void)): created from cgraph_node_remove_callers
(void remove_callees (void)): created from cgraph_node_remove_callees
(enum availability get_availability (void)): created from cgraph_function_body_availability
(void set_nothrow_flag (bool nothrow)): created from cgraph_set_nothrow_flag
(void set_const_flag (bool readonly, bool looping)): created from cgraph_set_const_flag
(void set_pure_flag (bool pure, bool looping)): created from cgraph_set_pure_flag
(void call_duplication_hooks (cgraph_node *node2)): created from
cgraph_call_node_duplication_hooks
(bool call_for_symbol_and_aliases (bool (*callback) (cgraph_node *, void *),
void *data, bool include_overwritable)): created from cgraph_for_node_and_aliases
(bool call_for_symbol_thunks_and_aliases (bool (*callback) (cgraph_node *node, void *data),
void *data, bool include_overwritable)): created from cgraph_for_node_thunks_and_aliases
(void call_function_insertion_hooks (void)):
created from cgraph_call_function_insertion_hooks
(inline void mark_force_output (void)): created from cgraph_mark_force_output_node
(bool local_p (void)): created from cgraph_local_node
(bool can_be_local_p (void)): created from cgraph_node_can_be_local_p
(bool cannot_return_p (void)): created from cgraph_node_cannot_return
(bool only_called_directly_p (void)): created from cgraph_only_called_directly_p
(inline bool only_called_directly_or_aliased_p (void)):
created from cgraph_only_called_directly_or_aliased_p
(bool will_be_removed_from_program_if_no_direct_calls_p (void)):
created from cgraph_will_be_removed_from_program_if_no_direct_calls
(bool can_remove_if_no_direct_calls_and_refs_p (void)):
created from cgraph_can_remove_if_no_direct_calls_and_refs_p
(bool can_remove_if_no_direct_calls_p (void)):
created from cgraph_can_remove_if_no_direct_calls_p
(inline bool has_gimple_body_p (void)):
created from cgraph_function_with_gimple_body_p
(bool optimize_for_size_p (void)): created from cgraph_optimize_for_size_p
(static void dump_cgraph (FILE *f)): created from dump_cgraph
(static inline void debug_cgraph (void)): created from debug_cgraph
(static void record_function_versions (tree decl1, tree decl2)):
created from record_function_versions
(static void delete_function_version (tree decl)):
created from delete_function_version
(static void add_new_function (tree fndecl, bool lowered)):
created from cgraph_add_new_function
(static inline cgraph_node *get (const_tree decl)): created from cgraph_get_node
(static cgraph_node * create (tree decl)): created from cgraph_create_node
(static cgraph_node * create_empty (void)): created from cgraph_create_empty_node
(static cgraph_node * get_create (tree)): created from cgraph_get_create_node
(static cgraph_node *get_for_asmname (tree asmname)):
created from cgraph_node_for_asm
(static cgraph_node * create_same_body_alias (tree alias, tree decl)):
created from cgraph_same_body_alias
(static bool used_from_object_file_p_worker (cgraph_node *node,
void *): new function
(static bool non_local_p (cgraph_node *node, void *)):
created from cgraph_non_local_node_p_1
(static void DEBUG_FUNCTION verify_cgraph_nodes (void)):
created from verify_cgraph
(static bool make_local (cgraph_node *node, void *)):
created from cgraph_make_node_local
(static cgraph_node *create_alias (tree alias, tree target)):
created from cgraph_create_function_alias
(static cgraph_edge * create_edge (cgraph_node *caller, cgraph_node *callee,
gimple call_stmt, gcov_type count, int freq, bool indir_unknown_callee)):
created from cgraph_create_edge_1
* cgraph.h (varpool_node):
(void remove (void)): created from varpool_remove_node
(void dump (FILE *f)): created from dump_varpool_node
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212982 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 857 |
1 files changed, 418 insertions, 439 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 14e3b3dcdfd..a5d07496f0a 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -67,7 +67,6 @@ along with GCC; see the file COPYING3. If not see /* FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this. */ #include "tree-pass.h" -static void cgraph_node_remove_callers (struct cgraph_node *node); static inline void cgraph_edge_remove_caller (struct cgraph_edge *e); static inline void cgraph_edge_remove_callee (struct cgraph_edge *e); @@ -175,11 +174,11 @@ static GTY(()) struct cgraph_function_version_info * /* Get the cgraph_function_version_info node corresponding to node. */ struct cgraph_function_version_info * -get_cgraph_node_version (struct cgraph_node *node) +cgraph_node::function_version (void) { struct cgraph_function_version_info *ret; struct cgraph_function_version_info key; - key.this_node = node; + key.this_node = this; if (cgraph_fnver_htab == NULL) return NULL; @@ -193,13 +192,13 @@ get_cgraph_node_version (struct cgraph_node *node) /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab corresponding to cgraph_node NODE. */ struct cgraph_function_version_info * -insert_new_cgraph_node_version (struct cgraph_node *node) +cgraph_node::insert_new_function_version (void) { void **slot; version_info_node = NULL; version_info_node = ggc_cleared_alloc<cgraph_function_version_info> (); - version_info_node->this_node = node; + version_info_node->this_node = this; if (cgraph_fnver_htab == NULL) cgraph_fnver_htab = htab_create_ggc (2, cgraph_fnver_htab_hash, @@ -214,15 +213,15 @@ insert_new_cgraph_node_version (struct cgraph_node *node) /* Remove the cgraph_function_version_info and cgraph_node for DECL. This DECL is a duplicate declaration. */ void -delete_function_version (tree decl) +cgraph_node::delete_function_version (tree decl) { - struct cgraph_node *decl_node = cgraph_get_node (decl); + struct cgraph_node *decl_node = cgraph_node::get (decl); struct cgraph_function_version_info *decl_v = NULL; if (decl_node == NULL) return; - decl_v = get_cgraph_node_version (decl_node); + decl_v = decl_node->function_version (); if (decl_v == NULL) return; @@ -236,33 +235,33 @@ delete_function_version (tree decl) if (cgraph_fnver_htab != NULL) htab_remove_elt (cgraph_fnver_htab, decl_v); - cgraph_remove_node (decl_node); + decl_node->remove (); } /* Record that DECL1 and DECL2 are semantically identical function versions. */ void -record_function_versions (tree decl1, tree decl2) +cgraph_node::record_function_versions (tree decl1, tree decl2) { - struct cgraph_node *decl1_node = cgraph_get_create_node (decl1); - struct cgraph_node *decl2_node = cgraph_get_create_node (decl2); + struct cgraph_node *decl1_node = cgraph_node::get_create (decl1); + struct cgraph_node *decl2_node = cgraph_node::get_create (decl2); struct cgraph_function_version_info *decl1_v = NULL; struct cgraph_function_version_info *decl2_v = NULL; struct cgraph_function_version_info *before; struct cgraph_function_version_info *after; gcc_assert (decl1_node != NULL && decl2_node != NULL); - decl1_v = get_cgraph_node_version (decl1_node); - decl2_v = get_cgraph_node_version (decl2_node); + decl1_v = decl1_node->function_version (); + decl2_v = decl2_node->function_version (); if (decl1_v != NULL && decl2_v != NULL) return; if (decl1_v == NULL) - decl1_v = insert_new_cgraph_node_version (decl1_node); + decl1_v = decl1_node->insert_new_function_version (); if (decl2_v == NULL) - decl2_v = insert_new_cgraph_node_version (decl2_node); + decl2_v = decl2_node->insert_new_function_version (); /* Chain decl2_v and decl1_v. All semantically identical versions will be chained together. */ @@ -282,7 +281,7 @@ record_function_versions (tree decl1, tree decl2) /* Macros to access the next item in the list of free cgraph nodes and edges. */ -#define NEXT_FREE_NODE(NODE) cgraph ((NODE)->next) +#define NEXT_FREE_NODE(NODE) dyn_cast<cgraph_node *> ((NODE)->next) #define SET_NEXT_FREE_NODE(NODE,NODE2) ((NODE))->next = NODE2 #define NEXT_FREE_EDGE(EDGE) (EDGE)->prev_caller @@ -399,12 +398,12 @@ cgraph_remove_function_insertion_hook (struct cgraph_node_hook_list *entry) /* Call all node insertion hooks. */ void -cgraph_call_function_insertion_hooks (struct cgraph_node *node) +cgraph_node::call_function_insertion_hooks (void) { struct cgraph_node_hook_list *entry = first_cgraph_function_insertion_hook; while (entry) { - entry->hook (node, entry->data); + entry->hook (this, entry->data); entry = entry->next; } } @@ -482,13 +481,12 @@ cgraph_remove_node_duplication_hook (struct cgraph_2node_hook_list *entry) /* Call all node duplication hooks. */ void -cgraph_call_node_duplication_hooks (struct cgraph_node *node1, - struct cgraph_node *node2) +cgraph_node::call_duplication_hooks (struct cgraph_node *node2) { struct cgraph_2node_hook_list *entry = first_cgraph_node_duplicated_hook; while (entry) { - entry->hook (node1, node2, entry->data); + entry->hook (this, node2, entry->data); entry = entry->next; } } @@ -516,8 +514,8 @@ cgraph_allocate_node (void) /* Allocate new callgraph node and insert it into basic data structures. */ -struct cgraph_node * -cgraph_create_empty_node (void) +cgraph_node * +cgraph_node::create_empty (void) { struct cgraph_node *node = cgraph_allocate_node (); @@ -530,18 +528,18 @@ cgraph_create_empty_node (void) /* Return cgraph node assigned to DECL. Create new one when needed. */ -struct cgraph_node * -cgraph_create_node (tree decl) +cgraph_node * +cgraph_node::create (tree decl) { - struct cgraph_node *node = cgraph_create_empty_node (); + struct cgraph_node *node = cgraph_node::create_empty (); gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); node->decl = decl; - symtab_register_node (node); + node->register_symbol (); if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL) { - node->origin = cgraph_get_create_node (DECL_CONTEXT (decl)); + node->origin = cgraph_node::get_create (DECL_CONTEXT (decl)); node->next_nested = node->origin->nested; node->origin->nested = node; } @@ -551,15 +549,15 @@ cgraph_create_node (tree decl) /* Try to find a call graph node for declaration DECL and if it does not exist or if it corresponds to an inline clone, create a new one. */ -struct cgraph_node * -cgraph_get_create_node (tree decl) +cgraph_node * +cgraph_node::get_create (tree decl) { - struct cgraph_node *first_clone = cgraph_get_node (decl); + struct cgraph_node *first_clone = cgraph_node::get (decl); if (first_clone && !first_clone->global.inlined_to) return first_clone; - struct cgraph_node *node = cgraph_create_node (decl); + struct cgraph_node *node = cgraph_node::create (decl); if (first_clone) { first_clone->clone_of = node; @@ -581,15 +579,15 @@ cgraph_get_create_node (tree decl) /* Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing the function body is associated with (not necessarily cgraph_node (DECL). */ -struct cgraph_node * -cgraph_create_function_alias (tree alias, tree target) +cgraph_node * +cgraph_node::create_alias (tree alias, tree target) { - struct cgraph_node *alias_node; + cgraph_node *alias_node; gcc_assert (TREE_CODE (target) == FUNCTION_DECL || TREE_CODE (target) == IDENTIFIER_NODE); gcc_assert (TREE_CODE (alias) == FUNCTION_DECL); - alias_node = cgraph_get_create_node (alias); + alias_node = cgraph_node::get_create (alias); gcc_assert (!alias_node->definition); alias_node->alias_target = target; alias_node->definition = true; @@ -602,10 +600,11 @@ cgraph_create_function_alias (tree alias, tree target) /* Attempt to mark ALIAS as an alias to DECL. Return alias node if successful and NULL otherwise. Same body aliases are output whenever the body of DECL is output, - and cgraph_get_node (ALIAS) transparently returns cgraph_get_node (DECL). */ + and cgraph_node::get (ALIAS) transparently returns + cgraph_node::get (DECL). */ struct cgraph_node * -cgraph_same_body_alias (struct cgraph_node *decl_node ATTRIBUTE_UNUSED, tree alias, tree decl) +cgraph_node::create_same_body_alias (tree alias, tree decl) { struct cgraph_node *n; #ifndef ASM_OUTPUT_DEF @@ -617,11 +616,10 @@ cgraph_same_body_alias (struct cgraph_node *decl_node ATTRIBUTE_UNUSED, tree ali if (cgraph_global_info_ready) return NULL; - n = cgraph_create_function_alias (alias, decl); + n = cgraph_node::create_alias (alias, decl); n->cpp_implicit_alias = true; if (cpp_implicit_aliases_done) - symtab_resolve_alias (n, - cgraph_get_node (decl)); + n->resolve_alias (cgraph_node::get (decl)); return n; } @@ -630,20 +628,19 @@ cgraph_same_body_alias (struct cgraph_node *decl_node ATTRIBUTE_UNUSED, tree ali See comments in thunk_adjust for detail on the parameters. */ struct cgraph_node * -cgraph_add_thunk (struct cgraph_node *decl_node ATTRIBUTE_UNUSED, - tree alias, tree decl ATTRIBUTE_UNUSED, - bool this_adjusting, - HOST_WIDE_INT fixed_offset, HOST_WIDE_INT virtual_value, - tree virtual_offset, - tree real_alias) +cgraph_node::create_thunk (tree alias, tree, bool this_adjusting, + HOST_WIDE_INT fixed_offset, + HOST_WIDE_INT virtual_value, + tree virtual_offset, + tree real_alias) { struct cgraph_node *node; - node = cgraph_get_node (alias); + node = cgraph_node::get (alias); if (node) - cgraph_reset_node (node); + node->reset (); else - node = cgraph_create_node (alias); + node = cgraph_node::create (alias); gcc_checking_assert (!virtual_offset || wi::eq_p (virtual_offset, virtual_value)); node->thunk.fixed_offset = fixed_offset; @@ -660,8 +657,8 @@ cgraph_add_thunk (struct cgraph_node *decl_node ATTRIBUTE_UNUSED, /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME. Return NULL if there's no such node. */ -struct cgraph_node * -cgraph_node_for_asm (tree asmname) +cgraph_node * +cgraph_node::get_for_asmname (tree asmname) { /* We do not want to look at inline clones. */ for (symtab_node *node = symtab_node_for_asm (asmname); @@ -732,15 +729,15 @@ cgraph_add_edge_to_call_site_hash (struct cgraph_edge *e) /* Return the callgraph edge representing the GIMPLE_CALL statement CALL_STMT. */ -struct cgraph_edge * -cgraph_edge (struct cgraph_node *node, gimple call_stmt) +cgraph_edge * +cgraph_node::get_edge (gimple call_stmt) { struct cgraph_edge *e, *e2; int n = 0; - if (node->call_site_hash) + if (call_site_hash) return (struct cgraph_edge *) - htab_find_with_hash (node->call_site_hash, call_stmt, + htab_find_with_hash (call_site_hash, call_stmt, htab_hash_pointer (call_stmt)); /* This loop may turn out to be performance problem. In such case adding @@ -748,7 +745,7 @@ cgraph_edge (struct cgraph_node *node, gimple call_stmt) solution. It is not good idea to add pointer into CALL_EXPR itself because we want to make possible having multiple cgraph nodes representing different clones of the same body before the body is actually cloned. */ - for (e = node->callees; e; e = e->next_callee) + for (e = callees; e; e = e->next_callee) { if (e->call_stmt == call_stmt) break; @@ -756,7 +753,7 @@ cgraph_edge (struct cgraph_node *node, gimple call_stmt) } if (!e) - for (e = node->indirect_calls; e; e = e->next_callee) + for (e = indirect_calls; e; e = e->next_callee) { if (e->call_stmt == call_stmt) break; @@ -765,10 +762,10 @@ cgraph_edge (struct cgraph_node *node, gimple call_stmt) if (n > 100) { - node->call_site_hash = htab_create_ggc (120, edge_hash, edge_eq, NULL); - for (e2 = node->callees; e2; e2 = e2->next_callee) + call_site_hash = htab_create_ggc (120, edge_hash, edge_eq, NULL); + for (e2 = callees; e2; e2 = e2->next_callee) cgraph_add_edge_to_call_site_hash (e2); - for (e2 = node->indirect_calls; e2; e2 = e2->next_callee) + for (e2 = indirect_calls; e2; e2 = e2->next_callee) cgraph_add_edge_to_call_site_hash (e2); } @@ -815,7 +812,7 @@ cgraph_set_call_stmt (struct cgraph_edge *e, gimple new_stmt, { /* Constant propagation (and possibly also inlining?) can turn an indirect call into a direct one. */ - struct cgraph_node *new_callee = cgraph_get_node (decl); + struct cgraph_node *new_callee = cgraph_node::get (decl); gcc_checking_assert (new_callee); e = cgraph_make_edge_direct (e, new_callee); @@ -832,12 +829,12 @@ cgraph_set_call_stmt (struct cgraph_edge *e, gimple new_stmt, parameters of which only CALLEE can be NULL (when creating an indirect call edge). */ -static struct cgraph_edge * -cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee, - gimple call_stmt, gcov_type count, int freq, - bool indir_unknown_callee) +cgraph_edge * +cgraph_node::create_edge (cgraph_node *caller, cgraph_node *callee, + gimple call_stmt, gcov_type count, int freq, + bool indir_unknown_callee) { - struct cgraph_edge *edge; + cgraph_edge *edge; /* LTO does not actually have access to the call_stmt since these have not been loaded yet. */ @@ -847,7 +844,8 @@ cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee, construction of call stmt hashtable. */ #ifdef ENABLE_CHECKING struct cgraph_edge *e; - gcc_checking_assert (!(e=cgraph_edge (caller, call_stmt)) || e->speculative); + gcc_checking_assert ( + !(e = caller->get_edge (call_stmt)) || e->speculative); #endif gcc_assert (is_gimple_call (call_stmt)); @@ -902,24 +900,24 @@ cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee, return edge; } -/* Create edge from CALLER to CALLEE in the cgraph. */ +/* Create edge from a given function to CALLEE in the cgraph. */ struct cgraph_edge * -cgraph_create_edge (struct cgraph_node *caller, struct cgraph_node *callee, - gimple call_stmt, gcov_type count, int freq) +cgraph_node::create_edge (struct cgraph_node *callee, + gimple call_stmt, gcov_type count, int freq) { - struct cgraph_edge *edge = cgraph_create_edge_1 (caller, callee, call_stmt, - count, freq, false); + cgraph_edge *edge = cgraph_node::create_edge (this, callee, call_stmt, + count, freq, false); initialize_inline_failed (edge); edge->next_caller = callee->callers; if (callee->callers) callee->callers->prev_caller = edge; - edge->next_callee = caller->callees; - if (caller->callees) - caller->callees->prev_callee = edge; - caller->callees = edge; + edge->next_callee = callees; + if (callees) + callees->prev_callee = edge; + callees = edge; callee->callers = edge; return edge; @@ -942,12 +940,11 @@ cgraph_allocate_init_indirect_info (void) PARAM_INDEX. */ struct cgraph_edge * -cgraph_create_indirect_edge (struct cgraph_node *caller, gimple call_stmt, - int ecf_flags, - gcov_type count, int freq) +cgraph_node::create_indirect_edge (gimple call_stmt, int ecf_flags, + gcov_type count, int freq) { - struct cgraph_edge *edge = cgraph_create_edge_1 (caller, NULL, call_stmt, - count, freq, true); + struct cgraph_edge *edge = cgraph_node::create_edge (this, NULL, call_stmt, + count, freq, true); tree target; initialize_inline_failed (edge); @@ -964,7 +961,7 @@ cgraph_create_indirect_edge (struct cgraph_node *caller, gimple call_stmt, HOST_WIDE_INT otr_token; ipa_polymorphic_call_context context; - get_polymorphic_call_info (caller->decl, + get_polymorphic_call_info (decl, target, &otr_type, &otr_token, &context, call_stmt); @@ -982,10 +979,10 @@ cgraph_create_indirect_edge (struct cgraph_node *caller, gimple call_stmt, edge->indirect_info->maybe_derived_type = context.maybe_derived_type; } - edge->next_callee = caller->indirect_calls; - if (caller->indirect_calls) - caller->indirect_calls->prev_callee = edge; - caller->indirect_calls = edge; + edge->next_callee = indirect_calls; + if (indirect_calls) + indirect_calls->prev_callee = edge; + indirect_calls = edge; return edge; } @@ -1112,7 +1109,7 @@ cgraph_turn_edge_to_speculative (struct cgraph_edge *e, xstrdup (n2->name ()), n2->order); } e->speculative = true; - e2 = cgraph_create_edge (n, n2, e->call_stmt, direct_count, direct_frequency); + e2 = n->create_edge (n2, e->call_stmt, direct_count, direct_frequency); initialize_inline_failed (e2); e2->speculative = true; if (TREE_NOTHROW (n2->decl)) @@ -1126,7 +1123,7 @@ cgraph_turn_edge_to_speculative (struct cgraph_edge *e, ref = n->add_reference (n2, IPA_REF_ADDR, e->call_stmt); ref->lto_stmt_uid = e->lto_stmt_uid; ref->speculative = e->speculative; - cgraph_mark_address_taken_node (n2); + n2->mark_address_taken (); return e2; } @@ -1161,7 +1158,7 @@ cgraph_speculative_call_info (struct cgraph_edge *e, /* We can take advantage of the call stmt hash. */ if (e2->call_stmt) { - e = cgraph_edge (e->caller, e2->call_stmt); + e = e->caller->get_edge (e2->call_stmt); gcc_assert (e->speculative && !e->indirect_unknown_callee); } else @@ -1217,8 +1214,8 @@ cgraph_resolve_speculation (struct cgraph_edge *edge, tree callee_decl) gcc_assert (edge->speculative); cgraph_speculative_call_info (edge, e2, edge, ref); if (!callee_decl - || !symtab_semantically_equivalent_p (ref->referred, - symtab_get_node (callee_decl))) + || !ref->referred->semantically_equivalent_p + (symtab_node::get (callee_decl))) { if (dump_file) { @@ -1259,7 +1256,7 @@ cgraph_resolve_speculation (struct cgraph_edge *edge, tree callee_decl) if (e2->indirect_unknown_callee || e2->inline_failed) cgraph_remove_edge (e2); else - cgraph_remove_node_and_inline_clones (e2->callee, NULL); + e2->callee->remove_symbol_and_inline_clones (); if (edge->caller->call_site_hash) cgraph_update_edge_in_call_site_hash (edge); return edge; @@ -1378,7 +1375,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) (int64_t)e->count); gcc_assert (e2->speculative); push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl)); - new_stmt = gimple_ic (e->call_stmt, cgraph (ref->referred), + new_stmt = gimple_ic (e->call_stmt, dyn_cast<cgraph_node *> (ref->referred), e->count || e2->count ? RDIV (e->count * REG_BR_PROB_BASE, e->count + e2->count) @@ -1388,8 +1385,8 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) : REG_BR_PROB_BASE / 2, e->count, e->count + e2->count); e->speculative = false; - cgraph_set_call_stmt_including_clones (e->caller, e->call_stmt, - new_stmt, false); + e->caller->set_call_stmt_including_clones (e->call_stmt, new_stmt, + false); e->frequency = compute_call_stmt_bb_frequency (e->caller->decl, gimple_bb (e->call_stmt)); e2->frequency = compute_call_stmt_bb_frequency @@ -1413,7 +1410,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) #ifdef ENABLE_CHECKING if (decl) { - node = cgraph_get_node (decl); + node = cgraph_node::get (decl); gcc_assert (!node || !node->clone.combined_args_to_skip); } #endif @@ -1491,7 +1488,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); } - cgraph_set_call_stmt_including_clones (e->caller, e->call_stmt, new_stmt, false); + e->caller->set_call_stmt_including_clones (e->call_stmt, new_stmt, false); if (cgraph_dump_file) { @@ -1522,7 +1519,7 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, into different builtin. */ if (old_call != new_call) { - struct cgraph_edge *e = cgraph_edge (node, old_stmt); + struct cgraph_edge *e = node->get_edge (old_stmt); struct cgraph_edge *ne = NULL; gcov_type count; int frequency; @@ -1555,7 +1552,7 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, if (e->indirect_unknown_callee || e->inline_failed) cgraph_remove_edge (e); else - cgraph_remove_node_and_inline_clones (e->callee, NULL); + e->callee->remove_symbol_and_inline_clones (); } else if (new_call) { @@ -1568,14 +1565,14 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, if (new_call) { - ne = cgraph_create_edge (node, cgraph_get_create_node (new_call), - new_stmt, count, frequency); + ne = node->create_edge (cgraph_node::get_create (new_call), + new_stmt, count, frequency); gcc_assert (ne->inline_failed); } } /* We only updated the call stmt; update pointer in cgraph edge.. */ else if (old_stmt != new_stmt) - cgraph_set_call_stmt (cgraph_edge (node, old_stmt), new_stmt); + cgraph_set_call_stmt (node->get_edge (old_stmt), new_stmt); } /* Update or remove the corresponding cgraph edge if a GIMPLE_CALL @@ -1585,7 +1582,7 @@ cgraph_update_edges_for_call_stmt_node (struct cgraph_node *node, void cgraph_update_edges_for_call_stmt (gimple old_stmt, tree old_decl, gimple new_stmt) { - struct cgraph_node *orig = cgraph_get_node (cfun->decl); + struct cgraph_node *orig = cgraph_node::get (cfun->decl); struct cgraph_node *node; gcc_checking_assert (orig); @@ -1612,14 +1609,14 @@ cgraph_update_edges_for_call_stmt (gimple old_stmt, tree old_decl, gimple new_st /* Remove all callees from the node. */ void -cgraph_node_remove_callees (struct cgraph_node *node) +cgraph_node::remove_callees (void) { struct cgraph_edge *e, *f; /* It is sufficient to remove the edges from the lists of callers of the callees. The callee list of the node can be zapped with one assignment. */ - for (e = node->callees; e; e = f) + for (e = callees; e; e = f) { f = e->next_callee; cgraph_call_edge_removal_hooks (e); @@ -1627,7 +1624,7 @@ cgraph_node_remove_callees (struct cgraph_node *node) cgraph_edge_remove_callee (e); cgraph_free_edge (e); } - for (e = node->indirect_calls; e; e = f) + for (e = indirect_calls; e; e = f) { f = e->next_callee; cgraph_call_edge_removal_hooks (e); @@ -1635,33 +1632,33 @@ cgraph_node_remove_callees (struct cgraph_node *node) cgraph_edge_remove_callee (e); cgraph_free_edge (e); } - node->indirect_calls = NULL; - node->callees = NULL; - if (node->call_site_hash) + indirect_calls = NULL; + callees = NULL; + if (call_site_hash) { - htab_delete (node->call_site_hash); - node->call_site_hash = NULL; + htab_delete (call_site_hash); + call_site_hash = NULL; } } /* Remove all callers from the node. */ -static void -cgraph_node_remove_callers (struct cgraph_node *node) +void +cgraph_node::remove_callers (void) { struct cgraph_edge *e, *f; /* It is sufficient to remove the edges from the lists of callees of the callers. The caller list of the node can be zapped with one assignment. */ - for (e = node->callers; e; e = f) + for (e = callers; e; e = f) { f = e->next_caller; cgraph_call_edge_removal_hooks (e); cgraph_edge_remove_caller (e); cgraph_free_edge (e); } - node->callers = NULL; + callers = NULL; } /* Helper function for cgraph_release_function_body and free_lang_data. @@ -1705,78 +1702,78 @@ release_function_body (tree decl) DECL_SAVED_TREE (decl) = NULL; } -/* Release memory used to represent body of function NODE. +/* Release memory used to represent body of function. Use this only for functions that are released before being translated to target code (i.e. RTL). Functions that are compiled to RTL and beyond are free'd in final.c via free_after_compilation(). */ void -cgraph_release_function_body (struct cgraph_node *node) +cgraph_node::release_body (void) { - node->ipa_transforms_to_apply.release (); - if (!node->used_as_abstract_origin && cgraph_state != CGRAPH_STATE_PARSING) + ipa_transforms_to_apply.release (); + if (!used_as_abstract_origin && cgraph_state != CGRAPH_STATE_PARSING) { - DECL_RESULT (node->decl) = NULL; - DECL_ARGUMENTS (node->decl) = NULL; + DECL_RESULT (decl) = NULL; + DECL_ARGUMENTS (decl) = NULL; } /* If the node is abstract and needed, then do not clear DECL_INITIAL of its associated function function declaration because it's needed to emit debug info later. */ - if (!node->used_as_abstract_origin && DECL_INITIAL (node->decl)) - DECL_INITIAL (node->decl) = error_mark_node; - release_function_body (node->decl); - if (node->lto_file_data) - lto_free_function_in_decl_state_for_node (node); + if (!used_as_abstract_origin && DECL_INITIAL (decl)) + DECL_INITIAL (decl) = error_mark_node; + release_function_body (decl); + if (lto_file_data) + lto_free_function_in_decl_state_for_node (this); } -/* Remove the node from cgraph. */ +/* Remove function from symbol table. */ void -cgraph_remove_node (struct cgraph_node *node) +cgraph_node::remove (void) { struct cgraph_node *n; - int uid = node->uid; + int uid = this->uid; - cgraph_call_node_removal_hooks (node); - cgraph_node_remove_callers (node); - cgraph_node_remove_callees (node); - node->ipa_transforms_to_apply.release (); + cgraph_call_node_removal_hooks (this); + remove_callers (); + remove_callees (); + ipa_transforms_to_apply.release (); /* Incremental inlining access removed nodes stored in the postorder list. */ - node->force_output = false; - node->forced_by_abi = false; - for (n = node->nested; n; n = n->next_nested) + force_output = false; + forced_by_abi = false; + for (n = nested; n; n = n->next_nested) n->origin = NULL; - node->nested = NULL; - if (node->origin) + nested = NULL; + if (origin) { - struct cgraph_node **node2 = &node->origin->nested; + struct cgraph_node **node2 = &origin->nested; - while (*node2 != node) + while (*node2 != this) node2 = &(*node2)->next_nested; - *node2 = node->next_nested; + *node2 = next_nested; } - symtab_unregister_node (node); - if (node->prev_sibling_clone) - node->prev_sibling_clone->next_sibling_clone = node->next_sibling_clone; - else if (node->clone_of) - node->clone_of->clones = node->next_sibling_clone; - if (node->next_sibling_clone) - node->next_sibling_clone->prev_sibling_clone = node->prev_sibling_clone; - if (node->clones) + unregister (); + if (prev_sibling_clone) + prev_sibling_clone->next_sibling_clone = next_sibling_clone; + else if (clone_of) + clone_of->clones = next_sibling_clone; + if (next_sibling_clone) + next_sibling_clone->prev_sibling_clone = prev_sibling_clone; + if (clones) { struct cgraph_node *n, *next; - if (node->clone_of) + if (clone_of) { - for (n = node->clones; n->next_sibling_clone; n = n->next_sibling_clone) - n->clone_of = node->clone_of; - n->clone_of = node->clone_of; - n->next_sibling_clone = node->clone_of->clones; - if (node->clone_of->clones) - node->clone_of->clones->prev_sibling_clone = n; - node->clone_of->clones = node->clones; + for (n = clones; n->next_sibling_clone; n = n->next_sibling_clone) + n->clone_of = clone_of; + n->clone_of = clone_of; + n->next_sibling_clone = clone_of->clones; + if (clone_of->clones) + clone_of->clones->prev_sibling_clone = n; + clone_of->clones = clones; } else { @@ -1785,7 +1782,7 @@ cgraph_remove_node (struct cgraph_node *node) tree intact. This can happen in unreachable function removal since we remove unreachable functions in random order, not by bottom-up walk of clone trees. */ - for (n = node->clones; n; n = next) + for (n = clones; n; n = next) { next = n->next_sibling_clone; n->next_sibling_clone = NULL; @@ -1801,7 +1798,7 @@ cgraph_remove_node (struct cgraph_node *node) */ if (cgraph_state != CGRAPH_LTO_STREAMING) { - n = cgraph_get_node (node->decl); + n = cgraph_node::get (decl); if (!n || (!n->clones && !n->clone_of && !n->global.inlined_to && (cgraph_global_info_ready @@ -1809,37 +1806,37 @@ cgraph_remove_node (struct cgraph_node *node) || DECL_EXTERNAL (n->decl) || !n->analyzed || (!flag_wpa && n->in_other_partition))))) - cgraph_release_function_body (node); + release_body (); } - node->decl = NULL; - if (node->call_site_hash) + decl = NULL; + if (call_site_hash) { - htab_delete (node->call_site_hash); - node->call_site_hash = NULL; + htab_delete (call_site_hash); + call_site_hash = NULL; } cgraph_n_nodes--; /* Clear out the node to NULL all pointers and add the node to the free list. */ - memset (node, 0, sizeof (*node)); - node->type = SYMTAB_FUNCTION; - node->uid = uid; - SET_NEXT_FREE_NODE (node, free_nodes); - free_nodes = node; + memset (this, 0, sizeof (*this)); + type = SYMTAB_FUNCTION; + this->uid = uid; + SET_NEXT_FREE_NODE (this, free_nodes); + free_nodes = this; } /* Likewise indicate that a node is having address taken. */ void -cgraph_mark_address_taken_node (struct cgraph_node *node) +cgraph_node::mark_address_taken (void) { /* Indirect inlining can figure out that all uses of the address are inlined. */ - if (node->global.inlined_to) + if (global.inlined_to) { gcc_assert (cfun->after_inlining); - gcc_assert (node->callers->indirect_inlining_edge); + gcc_assert (callers->indirect_inlining_edge); return; } /* FIXME: address_taken flag is used both as a shortcut for testing whether @@ -1848,8 +1845,8 @@ cgraph_mark_address_taken_node (struct cgraph_node *node) of the object was taken (and thus it should be set on node alias is referring to). We should remove the first use and the remove the following set. */ - node->address_taken = 1; - node = cgraph_function_or_thunk_node (node, NULL); + address_taken = 1; + cgraph_node *node = ultimate_alias_target (); node->address_taken = 1; } @@ -1861,7 +1858,7 @@ cgraph_local_info (tree decl) struct cgraph_node *node; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - node = cgraph_get_node (decl); + node = cgraph_node::get (decl); if (!node) return NULL; return &node->local; @@ -1875,7 +1872,7 @@ cgraph_global_info (tree decl) struct cgraph_node *node; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL && cgraph_global_info_ready); - node = cgraph_get_node (decl); + node = cgraph_node::get (decl); if (!node) return NULL; return &node->global; @@ -1889,7 +1886,7 @@ cgraph_rtl_info (tree decl) struct cgraph_node *node; gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - node = cgraph_get_node (decl); + node = cgraph_node::get (decl); if (!node || (decl != current_function_decl && !TREE_ASM_WRITTEN (node->decl))) @@ -1938,88 +1935,88 @@ const char * const cgraph_availability_names[] = {"unset", "not_available", "overwritable", "available", "local"}; -/* Dump call graph node NODE to file F. */ +/* Dump call graph node to file F. */ void -dump_cgraph_node (FILE *f, struct cgraph_node *node) +cgraph_node::dump (FILE *f) { struct cgraph_edge *edge; int indirect_calls_count = 0; - dump_symtab_base (f, node); + dump_base (f); - if (node->global.inlined_to) + if (global.inlined_to) fprintf (f, " Function %s/%i is inline copy in %s/%i\n", - xstrdup (node->name ()), - node->order, - xstrdup (node->global.inlined_to->name ()), - node->global.inlined_to->order); - if (node->clone_of) + xstrdup (name ()), + order, + xstrdup (global.inlined_to->name ()), + global.inlined_to->order); + if (clone_of) fprintf (f, " Clone of %s/%i\n", - node->clone_of->asm_name (), - node->clone_of->order); + clone_of->asm_name (), + clone_of->order); if (cgraph_function_flags_ready) fprintf (f, " Availability: %s\n", - cgraph_availability_names [cgraph_function_body_availability (node)]); + cgraph_availability_names [get_availability ()]); - if (node->profile_id) + if (profile_id) fprintf (f, " Profile id: %i\n", - node->profile_id); - fprintf (f, " First run: %i\n", node->tp_first_run); + profile_id); + fprintf (f, " First run: %i\n", tp_first_run); fprintf (f, " Function flags:"); - if (node->count) + if (count) fprintf (f, " executed %"PRId64"x", - (int64_t)node->count); - if (node->origin) - fprintf (f, " nested in: %s", node->origin->asm_name ()); - if (gimple_has_body_p (node->decl)) + (int64_t)count); + if (origin) + fprintf (f, " nested in: %s", origin->asm_name ()); + if (gimple_has_body_p (decl)) fprintf (f, " body"); - if (node->process) + if (process) fprintf (f, " process"); - if (node->local.local) + if (local.local) fprintf (f, " local"); - if (node->local.redefined_extern_inline) + if (local.redefined_extern_inline) fprintf (f, " redefined_extern_inline"); - if (node->only_called_at_startup) + if (only_called_at_startup) fprintf (f, " only_called_at_startup"); - if (node->only_called_at_exit) + if (only_called_at_exit) fprintf (f, " only_called_at_exit"); - if (node->tm_clone) + if (tm_clone) fprintf (f, " tm_clone"); - if (DECL_STATIC_CONSTRUCTOR (node->decl)) - fprintf (f," static_constructor (priority:%i)", node->get_init_priority ()); - if (DECL_STATIC_DESTRUCTOR (node->decl)) - fprintf (f," static_destructor (priority:%i)", node->get_fini_priority ()); + if (DECL_STATIC_CONSTRUCTOR (decl)) + fprintf (f," static_constructor (priority:%i)", get_init_priority ()); + if (DECL_STATIC_DESTRUCTOR (decl)) + fprintf (f," static_destructor (priority:%i)", get_fini_priority ()); fprintf (f, "\n"); - if (node->thunk.thunk_p) + if (thunk.thunk_p) { fprintf (f, " Thunk"); - if (node->thunk.alias) + if (thunk.alias) fprintf (f, " of %s (asm: %s)", - lang_hooks.decl_printable_name (node->thunk.alias, 2), - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->thunk.alias))); + lang_hooks.decl_printable_name (thunk.alias, 2), + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (thunk.alias))); fprintf (f, " fixed offset %i virtual value %i has " "virtual offset %i)\n", - (int)node->thunk.fixed_offset, - (int)node->thunk.virtual_value, - (int)node->thunk.virtual_offset_p); + (int)thunk.fixed_offset, + (int)thunk.virtual_value, + (int)thunk.virtual_offset_p); } - if (node->alias && node->thunk.alias - && DECL_P (node->thunk.alias)) + if (alias && thunk.alias + && DECL_P (thunk.alias)) { fprintf (f, " Alias of %s", - lang_hooks.decl_printable_name (node->thunk.alias, 2)); - if (DECL_ASSEMBLER_NAME_SET_P (node->thunk.alias)) + lang_hooks.decl_printable_name (thunk.alias, 2)); + if (DECL_ASSEMBLER_NAME_SET_P (thunk.alias)) fprintf (f, " (asm: %s)", - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->thunk.alias))); + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (thunk.alias))); fprintf (f, "\n"); } fprintf (f, " Called by: "); - for (edge = node->callers; edge; edge = edge->next_caller) + for (edge = callers; edge; edge = edge->next_caller) { fprintf (f, "%s/%i ", edge->caller->asm_name (), edge->caller->order); @@ -2040,7 +2037,7 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node) } fprintf (f, "\n Calls: "); - for (edge = node->callees; edge; edge = edge->next_callee) + for (edge = callees; edge; edge = edge->next_callee) { fprintf (f, "%s/%i ", edge->callee->asm_name (), edge->callee->order); @@ -2061,45 +2058,35 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node) } fprintf (f, "\n"); - for (edge = node->indirect_calls; edge; edge = edge->next_callee) + for (edge = indirect_calls; edge; edge = edge->next_callee) indirect_calls_count++; if (indirect_calls_count) fprintf (f, " Has %i outgoing edges for indirect calls.\n", indirect_calls_count); } - /* Dump call graph node NODE to stderr. */ DEBUG_FUNCTION void -debug_cgraph_node (struct cgraph_node *node) +cgraph_node::debug (void) { - dump_cgraph_node (stderr, node); + dump (stderr); } - /* Dump the callgraph to file F. */ void -dump_cgraph (FILE *f) +cgraph_node::dump_cgraph (FILE *f) { struct cgraph_node *node; fprintf (f, "callgraph:\n\n"); FOR_EACH_FUNCTION (node) - dump_cgraph_node (f, node); -} - - -/* Dump the call graph to stderr. */ - -DEBUG_FUNCTION void -debug_cgraph (void) -{ - dump_cgraph (stderr); + node->dump (f); } /* Return true when the DECL can possibly be inlined. */ + bool cgraph_function_possibly_inlined_p (tree decl) { @@ -2108,39 +2095,39 @@ cgraph_function_possibly_inlined_p (tree decl) return DECL_POSSIBLY_INLINED (decl); } -/* NODE is no longer nested function; update cgraph accordingly. */ +/* cgraph_node is no longer nested function; update cgraph accordingly. */ void -cgraph_unnest_node (struct cgraph_node *node) +cgraph_node::unnest (void) { - struct cgraph_node **node2 = &node->origin->nested; - gcc_assert (node->origin); + struct cgraph_node **node2 = &origin->nested; + gcc_assert (origin); - while (*node2 != node) + while (*node2 != this) node2 = &(*node2)->next_nested; - *node2 = node->next_nested; - node->origin = NULL; + *node2 = next_nested; + origin = NULL; } /* Return function availability. See cgraph.h for description of individual return values. */ enum availability -cgraph_function_body_availability (struct cgraph_node *node) +cgraph_node::get_availability (void) { enum availability avail; - if (!node->analyzed) + if (!analyzed) avail = AVAIL_NOT_AVAILABLE; - else if (node->local.local) + else if (local.local) avail = AVAIL_LOCAL; - else if (node->alias && node->weakref) - cgraph_function_or_thunk_node (node, &avail); - else if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (node->decl))) - avail = AVAIL_OVERWRITABLE; - else if (!node->externally_visible) + else if (alias && weakref) + ultimate_alias_target (&avail); + else if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl))) + avail = AVAIL_INTERPOSABLE; + else if (!externally_visible) avail = AVAIL_AVAILABLE; /* Inline functions are safe to be analyzed even if their symbol can be overwritten at runtime. It is not meaningful to enforce any sane behaviour on replacing inline function by different body. */ - else if (DECL_DECLARED_INLINE_P (node->decl)) + else if (DECL_DECLARED_INLINE_P (decl)) avail = AVAIL_AVAILABLE; /* If the function can be overwritten, return OVERWRITABLE. Take @@ -2153,9 +2140,8 @@ cgraph_function_body_availability (struct cgraph_node *node) AVAIL_AVAILABLE here? That would be good reason to preserve this bit. */ - else if (decl_replaceable_p (node->decl) - && !DECL_EXTERNAL (node->decl)) - avail = AVAIL_OVERWRITABLE; + else if (decl_replaceable_p (decl) && !DECL_EXTERNAL (decl)) + avail = AVAIL_INTERPOSABLE; else avail = AVAIL_AVAILABLE; return avail; @@ -2163,87 +2149,85 @@ cgraph_function_body_availability (struct cgraph_node *node) /* Worker for cgraph_node_can_be_local_p. */ static bool -cgraph_node_cannot_be_local_p_1 (struct cgraph_node *node, - void *data ATTRIBUTE_UNUSED) +cgraph_node_cannot_be_local_p_1 (struct cgraph_node *node, void *) { return !(!node->force_output && ((DECL_COMDAT (node->decl) && !node->forced_by_abi - && !symtab_used_from_object_file_p (node) + && !node->used_from_object_file_p () && !node->same_comdat_group) || !node->externally_visible)); } -/* Return true if NODE can be made local for API change. +/* Return true if cgraph_node can be made local for API change. Extern inline functions and C++ COMDAT functions can be made local at the expense of possible code size growth if function is used in multiple compilation units. */ bool -cgraph_node_can_be_local_p (struct cgraph_node *node) +cgraph_node::can_be_local_p (void) { - return (!node->address_taken - && !cgraph_for_node_and_aliases (node, - cgraph_node_cannot_be_local_p_1, - NULL, true)); + return (!address_taken + && !call_for_symbol_thunks_and_aliases (cgraph_node_cannot_be_local_p_1, + NULL, true)); } -/* Call calback on NODE, thunks and aliases associated to NODE. +/* Call calback on cgraph_node, thunks and aliases associated to cgraph_node. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped. */ bool -cgraph_for_node_thunks_and_aliases (struct cgraph_node *node, - bool (*callback) (struct cgraph_node *, void *), - void *data, - bool include_overwritable) +cgraph_node::call_for_symbol_thunks_and_aliases (bool (*callback) + (cgraph_node *, void *), + void *data, + bool include_overwritable) { struct cgraph_edge *e; struct ipa_ref *ref; - if (callback (node, data)) + if (callback (this, data)) return true; - for (e = node->callers; e; e = e->next_caller) + for (e = callers; e; e = e->next_caller) if (e->caller->thunk.thunk_p && (include_overwritable - || cgraph_function_body_availability (e->caller) > AVAIL_OVERWRITABLE)) - if (cgraph_for_node_thunks_and_aliases (e->caller, callback, data, - include_overwritable)) + || e->caller->get_availability () > AVAIL_INTERPOSABLE)) + if (e->caller->call_for_symbol_thunks_and_aliases (callback, data, + include_overwritable)) return true; - FOR_EACH_ALIAS (node, ref) + FOR_EACH_ALIAS (this, ref) { struct cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring); if (include_overwritable - || cgraph_function_body_availability (alias) > AVAIL_OVERWRITABLE) - if (cgraph_for_node_thunks_and_aliases (alias, callback, data, - include_overwritable)) + || alias->get_availability () > AVAIL_INTERPOSABLE) + if (alias->call_for_symbol_thunks_and_aliases (callback, data, + include_overwritable)) return true; } return false; } -/* Call calback on NODE and aliases associated to NODE. +/* Call calback on function and aliases associated to the function. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped. */ bool -cgraph_for_node_and_aliases (struct cgraph_node *node, - bool (*callback) (struct cgraph_node *, void *), - void *data, - bool include_overwritable) +cgraph_node::call_for_symbol_and_aliases (bool (*callback) (cgraph_node *, + void *), + void *data, + bool include_overwritable) { struct ipa_ref *ref; - if (callback (node, data)) + if (callback (this, data)) return true; - FOR_EACH_ALIAS (node, ref) + FOR_EACH_ALIAS (this, ref) { struct cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring); if (include_overwritable - || cgraph_function_body_availability (alias) > AVAIL_OVERWRITABLE) - if (cgraph_for_node_and_aliases (alias, callback, data, - include_overwritable)) + || alias->get_availability () > AVAIL_INTERPOSABLE) + if (alias->call_for_symbol_and_aliases (callback, data, + include_overwritable)) return true; } return false; @@ -2251,14 +2235,13 @@ cgraph_for_node_and_aliases (struct cgraph_node *node, /* Worker to bring NODE local. */ -static bool -cgraph_make_node_local_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) +bool +cgraph_node::make_local (struct cgraph_node *node, void *) { - gcc_checking_assert (cgraph_node_can_be_local_p (node)); + gcc_checking_assert (node->can_be_local_p ()); if (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl)) { - symtab_make_decl_local (node->decl); - + node->make_decl_local (); node->set_section (NULL); node->set_comdat_group (NULL); node->externally_visible = false; @@ -2268,18 +2251,17 @@ cgraph_make_node_local_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) node->unique_name = (node->resolution == LDPR_PREVAILING_DEF_IRONLY || node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP); node->resolution = LDPR_PREVAILING_DEF_IRONLY; - gcc_assert (cgraph_function_body_availability (node) == AVAIL_LOCAL); + gcc_assert (node->get_availability () == AVAIL_LOCAL); } return false; } -/* Bring NODE local. */ +/* Bring cgraph node local. */ void -cgraph_make_node_local (struct cgraph_node *node) +cgraph_node::make_local (void) { - cgraph_for_node_thunks_and_aliases (node, cgraph_make_node_local_1, - NULL, true); + call_for_symbol_thunks_and_aliases (cgraph_node::make_local, NULL, true); } /* Worker to set nothrow flag. */ @@ -2301,10 +2283,10 @@ cgraph_set_nothrow_flag_1 (struct cgraph_node *node, void *data) if any to NOTHROW. */ void -cgraph_set_nothrow_flag (struct cgraph_node *node, bool nothrow) +cgraph_node::set_nothrow_flag (bool nothrow) { - cgraph_for_node_thunks_and_aliases (node, cgraph_set_nothrow_flag_1, - (void *)(size_t)nothrow, false); + call_for_symbol_thunks_and_aliases (cgraph_set_nothrow_flag_1, + (void *)(size_t)nothrow, false); } /* Worker to set const flag. */ @@ -2326,14 +2308,14 @@ cgraph_set_const_flag_1 (struct cgraph_node *node, void *data) return false; } -/* Set TREE_READONLY on NODE's decl and on aliases of NODE +/* Set TREE_READONLY on cgraph_node's decl and on aliases of the node if any to READONLY. */ void -cgraph_set_const_flag (struct cgraph_node *node, bool readonly, bool looping) +cgraph_node::set_const_flag (bool readonly, bool looping) { - cgraph_for_node_thunks_and_aliases (node, cgraph_set_const_flag_1, - (void *)(size_t)(readonly + (int)looping * 2), + call_for_symbol_thunks_and_aliases (cgraph_set_const_flag_1, + (void *)(size_t)(readonly + (int)looping * 2), false); } @@ -2356,24 +2338,24 @@ cgraph_set_pure_flag_1 (struct cgraph_node *node, void *data) return false; } -/* Set DECL_PURE_P on NODE's decl and on aliases of NODE +/* Set DECL_PURE_P on cgraph_node's decl and on aliases of the node if any to PURE. */ void -cgraph_set_pure_flag (struct cgraph_node *node, bool pure, bool looping) +cgraph_node::set_pure_flag (bool pure, bool looping) { - cgraph_for_node_thunks_and_aliases (node, cgraph_set_pure_flag_1, - (void *)(size_t)(pure + (int)looping * 2), - false); + call_for_symbol_thunks_and_aliases (cgraph_set_pure_flag_1, + (void *)(size_t)(pure + (int)looping * 2), + false); } -/* Return true when NODE can not return or throw and thus +/* Return true when cgraph_node can not return or throw and thus it is safe to ignore its side effects for IPA analysis. */ bool -cgraph_node_cannot_return (struct cgraph_node *node) +cgraph_node::cannot_return_p (void) { - int flags = flags_from_decl_or_type (node->decl); + int flags = flags_from_decl_or_type (decl); if (!flag_exceptions) return (flags & ECF_NORETURN) != 0; else @@ -2389,7 +2371,7 @@ cgraph_node_cannot_return (struct cgraph_node *node) bool cgraph_edge_cannot_lead_to_return (struct cgraph_edge *e) { - if (cgraph_node_cannot_return (e->caller)) + if (e->caller->cannot_return_p ()) return true; if (e->indirect_unknown_callee) { @@ -2401,30 +2383,30 @@ cgraph_edge_cannot_lead_to_return (struct cgraph_edge *e) == (ECF_NORETURN | ECF_NOTHROW)); } else - return cgraph_node_cannot_return (e->callee); + return e->callee->cannot_return_p (); } -/* Return true when function NODE can be removed from callgraph +/* Return true when function can be removed from callgraph if all direct calls are eliminated. */ bool -cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node) +cgraph_node::can_remove_if_no_direct_calls_and_refs_p (void) { - gcc_assert (!node->global.inlined_to); + gcc_assert (!global.inlined_to); /* Extern inlines can always go, we will use the external definition. */ - if (DECL_EXTERNAL (node->decl)) + if (DECL_EXTERNAL (decl)) return true; /* When function is needed, we can not remove it. */ - if (node->force_output || node->used_from_other_partition) + if (force_output || used_from_other_partition) return false; - if (DECL_STATIC_CONSTRUCTOR (node->decl) - || DECL_STATIC_DESTRUCTOR (node->decl)) + if (DECL_STATIC_CONSTRUCTOR (decl) + || DECL_STATIC_DESTRUCTOR (decl)) return false; /* Only COMDAT functions can be removed if externally visible. */ - if (node->externally_visible - && (!DECL_COMDAT (node->decl) - || node->forced_by_abi - || symtab_used_from_object_file_p (node))) + if (externally_visible + && (!DECL_COMDAT (decl) + || forced_by_abi + || used_from_object_file_p ())) return false; return true; } @@ -2432,34 +2414,26 @@ cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node) /* Worker for cgraph_can_remove_if_no_direct_calls_p. */ static bool -nonremovable_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) +nonremovable_p (struct cgraph_node *node, void *) { - return !cgraph_can_remove_if_no_direct_calls_and_refs_p (node); + return !node->can_remove_if_no_direct_calls_and_refs_p (); } -/* Return true when function NODE and its aliases can be removed from callgraph - if all direct calls are eliminated. */ +/* Return true when function cgraph_node and its aliases can be removed from + callgraph if all direct calls are eliminated. */ bool -cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node) +cgraph_node::can_remove_if_no_direct_calls_p (void) { /* Extern inlines can always go, we will use the external definition. */ - if (DECL_EXTERNAL (node->decl)) + if (DECL_EXTERNAL (decl)) return true; - if (node->address_taken) + if (address_taken) return false; - return !cgraph_for_node_and_aliases (node, nonremovable_p, NULL, true); + return !call_for_symbol_and_aliases (nonremovable_p, NULL, true); } -/* Worker for cgraph_can_remove_if_no_direct_calls_p. */ - -static bool -used_from_object_file_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) -{ - return symtab_used_from_object_file_p (node); -} - -/* Return true when function NODE can be expected to be removed +/* Return true when function cgraph_node can be expected to be removed from program when direct calls in this compilation unit are removed. As a special case COMDAT functions are @@ -2474,18 +2448,20 @@ used_from_object_file_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) linkonce section. */ bool -cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node) +cgraph_node::will_be_removed_from_program_if_no_direct_calls_p (void) { - gcc_assert (!node->global.inlined_to); - if (cgraph_for_node_and_aliases (node, used_from_object_file_p, NULL, true)) + gcc_assert (!global.inlined_to); + + if (call_for_symbol_and_aliases (used_from_object_file_p_worker, + NULL, true)) return false; if (!in_lto_p && !flag_whole_program) - return cgraph_only_called_directly_p (node); + return only_called_directly_p (); else { - if (DECL_EXTERNAL (node->decl)) + if (DECL_EXTERNAL (decl)) return true; - return cgraph_can_remove_if_no_direct_calls_p (node); + return can_remove_if_no_direct_calls_p (); } } @@ -2493,21 +2469,21 @@ cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node /* Worker for cgraph_only_called_directly_p. */ static bool -cgraph_not_only_called_directly_p_1 (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) +cgraph_not_only_called_directly_p_1 (struct cgraph_node *node, void *) { - return !cgraph_only_called_directly_or_aliased_p (node); + return !node->only_called_directly_or_aliased_p (); } -/* Return true when function NODE and all its aliases are only called +/* Return true when function cgraph_node and all its aliases are only called directly. i.e. it is not externally visible, address was not taken and it is not used in any other non-standard way. */ bool -cgraph_only_called_directly_p (struct cgraph_node *node) +cgraph_node::only_called_directly_p (void) { - gcc_assert (cgraph_function_or_thunk_node (node, NULL) == node); - return !cgraph_for_node_and_aliases (node, cgraph_not_only_called_directly_p_1, + gcc_assert (ultimate_alias_target () == this); + return !call_for_symbol_and_aliases (cgraph_not_only_called_directly_p_1, NULL, true); } @@ -2517,27 +2493,27 @@ cgraph_only_called_directly_p (struct cgraph_node *node) static bool collect_callers_of_node_1 (struct cgraph_node *node, void *data) { - vec<cgraph_edge_p> *redirect_callers = (vec<cgraph_edge_p> *)data; + vec<cgraph_edge *> *redirect_callers = (vec<cgraph_edge *> *)data; struct cgraph_edge *cs; enum availability avail; - cgraph_function_or_thunk_node (node, &avail); + node->ultimate_alias_target (&avail); - if (avail > AVAIL_OVERWRITABLE) + if (avail > AVAIL_INTERPOSABLE) for (cs = node->callers; cs != NULL; cs = cs->next_caller) if (!cs->indirect_inlining_edge) redirect_callers->safe_push (cs); return false; } -/* Collect all callers of NODE and its aliases that are known to lead to NODE - (i.e. are not overwritable). */ +/* Collect all callers of cgraph_node and its aliases that are known to lead to + cgraph_node (i.e. are not overwritable). */ -vec<cgraph_edge_p> -collect_callers_of_node (struct cgraph_node *node) +vec<cgraph_edge *> +cgraph_node::collect_callers (void) { - vec<cgraph_edge_p> redirect_callers = vNULL; - cgraph_for_node_and_aliases (node, collect_callers_of_node_1, - &redirect_callers, false); + vec<cgraph_edge *> redirect_callers = vNULL; + call_for_symbol_thunks_and_aliases (collect_callers_of_node_1, + &redirect_callers, false); return redirect_callers; } @@ -2547,8 +2523,8 @@ static bool clone_of_p (struct cgraph_node *node, struct cgraph_node *node2) { bool skipped_thunk = false; - node = cgraph_function_or_thunk_node (node, NULL); - node2 = cgraph_function_or_thunk_node (node2, NULL); + node = node->ultimate_alias_target (); + node2 = node2->ultimate_alias_target (); /* There are no virtual clones of thunks so check former_clone_of or if we might have skipped thunks because this adjustments are no longer @@ -2559,7 +2535,7 @@ clone_of_p (struct cgraph_node *node, struct cgraph_node *node2) return true; if (!node->thunk.this_adjusting) return false; - node = cgraph_function_or_thunk_node (node->callees->callee, NULL); + node = node->callees->callee->ultimate_alias_target (); skipped_thunk = true; } @@ -2653,7 +2629,7 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl) return false; if (cgraph_state == CGRAPH_LTO_STREAMING) return false; - node = cgraph_get_node (decl); + node = cgraph_node::get (decl); /* We do not know if a node from a different partition is an alias or what it aliases and therefore cannot do the former_clone_of check reliably. When @@ -2665,15 +2641,16 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl) || e->callee->in_other_partition) return false; + node = node->ultimate_alias_target (); + /* Optimizers can redirect unreachable calls or calls triggering undefined behaviour to builtin_unreachable. */ if (DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE) return false; - node = cgraph_function_or_thunk_node (node, NULL); if (e->callee->former_clone_of != node->decl - && (node != cgraph_function_or_thunk_node (e->callee, NULL)) + && (node != e->callee->ultimate_alias_target ()) && !clone_of_p (node, e->callee)) return true; else @@ -2682,10 +2659,10 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl) /* Verify cgraph nodes of given cgraph node. */ DEBUG_FUNCTION void -verify_cgraph_node (struct cgraph_node *node) +cgraph_node::verify_node (void) { struct cgraph_edge *e; - struct function *this_cfun = DECL_STRUCT_FUNCTION (node->decl); + struct function *this_cfun = DECL_STRUCT_FUNCTION (decl); basic_block this_block; gimple_stmt_iterator gsi; bool error_found = false; @@ -2694,8 +2671,8 @@ verify_cgraph_node (struct cgraph_node *node) return; timevar_push (TV_CGRAPH_VERIFY); - error_found |= verify_symtab_base (node); - for (e = node->callees; e; e = e->next_callee) + error_found |= verify_base (); + for (e = callees; e; e = e->next_callee) if (e->aux) { error ("aux field set for edge %s->%s", @@ -2703,37 +2680,37 @@ verify_cgraph_node (struct cgraph_node *node) identifier_to_locale (e->callee->name ())); error_found = true; } - if (node->count < 0) + if (count < 0) { error ("execution count is negative"); error_found = true; } - if (node->global.inlined_to && node->same_comdat_group) + if (global.inlined_to && same_comdat_group) { error ("inline clone in same comdat group list"); error_found = true; } - if (!node->definition && !node->in_other_partition && node->local.local) + if (!definition && !in_other_partition && local.local) { error ("local symbols must be defined"); error_found = true; } - if (node->global.inlined_to && node->externally_visible) + if (global.inlined_to && externally_visible) { error ("externally visible inline clone"); error_found = true; } - if (node->global.inlined_to && node->address_taken) + if (global.inlined_to && address_taken) { error ("inline clone with address taken"); error_found = true; } - if (node->global.inlined_to && node->force_output) + if (global.inlined_to && force_output) { error ("inline clone is forced to output"); error_found = true; } - for (e = node->indirect_calls; e; e = e->next_callee) + for (e = indirect_calls; e; e = e->next_callee) { if (e->aux) { @@ -2751,13 +2728,13 @@ verify_cgraph_node (struct cgraph_node *node) error_found = true; } } - bool check_comdat = symtab_comdat_local_p (node); - for (e = node->callers; e; e = e->next_caller) + bool check_comdat = comdat_local_p (); + for (e = callers; e; e = e->next_caller) { if (verify_edge_count_and_frequency (e)) error_found = true; if (check_comdat - && !symtab_in_same_comdat_p (e->caller, node)) + && !in_same_comdat_group_p (e->caller)) { error ("comdat-local function called by %s outside its comdat", identifier_to_locale (e->caller->name ())); @@ -2765,92 +2742,92 @@ verify_cgraph_node (struct cgraph_node *node) } if (!e->inline_failed) { - if (node->global.inlined_to + if (global.inlined_to != (e->caller->global.inlined_to ? e->caller->global.inlined_to : e->caller)) { error ("inlined_to pointer is wrong"); error_found = true; } - if (node->callers->next_caller) + if (callers->next_caller) { error ("multiple inline callers"); error_found = true; } } else - if (node->global.inlined_to) + if (global.inlined_to) { error ("inlined_to pointer set for noninline callers"); error_found = true; } } - for (e = node->indirect_calls; e; e = e->next_callee) + for (e = indirect_calls; e; e = e->next_callee) if (verify_edge_count_and_frequency (e)) error_found = true; - if (!node->callers && node->global.inlined_to) + if (!callers && global.inlined_to) { error ("inlined_to pointer is set but no predecessors found"); error_found = true; } - if (node->global.inlined_to == node) + if (global.inlined_to == this) { error ("inlined_to pointer refers to itself"); error_found = true; } - if (node->clone_of) + if (clone_of) { struct cgraph_node *n; - for (n = node->clone_of->clones; n; n = n->next_sibling_clone) - if (n == node) + for (n = clone_of->clones; n; n = n->next_sibling_clone) + if (n == this) break; if (!n) { - error ("node has wrong clone_of"); + error ("cgraph_node has wrong clone_of"); error_found = true; } } - if (node->clones) + if (clones) { struct cgraph_node *n; - for (n = node->clones; n; n = n->next_sibling_clone) - if (n->clone_of != node) + for (n = clones; n; n = n->next_sibling_clone) + if (n->clone_of != this) break; if (n) { - error ("node has wrong clone list"); + error ("cgraph_node has wrong clone list"); error_found = true; } } - if ((node->prev_sibling_clone || node->next_sibling_clone) && !node->clone_of) + if ((prev_sibling_clone || next_sibling_clone) && !clone_of) { - error ("node is in clone list but it is not clone"); + error ("cgraph_node is in clone list but it is not clone"); error_found = true; } - if (!node->prev_sibling_clone && node->clone_of && node->clone_of->clones != node) + if (!prev_sibling_clone && clone_of && clone_of->clones != this) { - error ("node has wrong prev_clone pointer"); + error ("cgraph_node has wrong prev_clone pointer"); error_found = true; } - if (node->prev_sibling_clone && node->prev_sibling_clone->next_sibling_clone != node) + if (prev_sibling_clone && prev_sibling_clone->next_sibling_clone != this) { error ("double linked list of clones corrupted"); error_found = true; } - if (node->analyzed && node->alias) + if (analyzed && alias) { bool ref_found = false; int i; struct ipa_ref *ref = NULL; - if (node->callees) + if (callees) { error ("Alias has call edges"); error_found = true; } - for (i = 0; node->iterate_reference (i, ref); i++) + for (i = 0; iterate_reference (i, ref); i++) if (ref->use != IPA_REF_ALIAS) { error ("Alias has non-alias reference"); @@ -2869,28 +2846,28 @@ verify_cgraph_node (struct cgraph_node *node) error_found = true; } } - if (node->analyzed && node->thunk.thunk_p) + if (analyzed && thunk.thunk_p) { - if (!node->callees) + if (!callees) { error ("No edge out of thunk node"); error_found = true; } - else if (node->callees->next_callee) + else if (callees->next_callee) { error ("More than one edge out of thunk node"); error_found = true; } - if (gimple_has_body_p (node->decl)) + if (gimple_has_body_p (decl)) { error ("Thunk is not supposed to have body"); error_found = true; } } - else if (node->analyzed && gimple_has_body_p (node->decl) - && !TREE_ASM_WRITTEN (node->decl) - && (!DECL_EXTERNAL (node->decl) || node->global.inlined_to) - && !flag_wpa) + else if (analyzed && gimple_has_body_p (decl) + && !TREE_ASM_WRITTEN (decl) + && (!DECL_EXTERNAL (decl) || global.inlined_to) + && !flag_wpa) { if (this_cfun->cfg) { @@ -2913,7 +2890,7 @@ verify_cgraph_node (struct cgraph_node *node) pointer_set_insert (stmts, stmt); if (is_gimple_call (stmt)) { - struct cgraph_edge *e = cgraph_edge (node, stmt); + struct cgraph_edge *e = get_edge (stmt); tree decl = gimple_call_fndecl (stmt); if (e) { @@ -2953,8 +2930,7 @@ verify_cgraph_node (struct cgraph_node *node) } } } - for (i = 0; - node->iterate_reference (i, ref); i++) + for (i = 0; iterate_reference (i, ref); i++) if (ref->stmt && !pointer_set_contains (stmts, ref->stmt)) { error ("reference to dead statement"); @@ -2967,7 +2943,7 @@ verify_cgraph_node (struct cgraph_node *node) /* No CFG available?! */ gcc_unreachable (); - for (e = node->callees; e; e = e->next_callee) + for (e = callees; e; e = e->next_callee) { if (!e->aux) { @@ -2979,7 +2955,7 @@ verify_cgraph_node (struct cgraph_node *node) } e->aux = 0; } - for (e = node->indirect_calls; e; e = e->next_callee) + for (e = indirect_calls; e; e = e->next_callee) { if (!e->aux && !e->speculative) { @@ -2993,7 +2969,7 @@ verify_cgraph_node (struct cgraph_node *node) } if (error_found) { - dump_cgraph_node (stderr, node); + dump (stderr); internal_error ("verify_cgraph_node failed"); } timevar_pop (TV_CGRAPH_VERIFY); @@ -3001,7 +2977,7 @@ verify_cgraph_node (struct cgraph_node *node) /* Verify whole cgraph structure. */ DEBUG_FUNCTION void -verify_cgraph (void) +cgraph_node::verify_cgraph_nodes (void) { struct cgraph_node *node; @@ -3009,44 +2985,47 @@ verify_cgraph (void) return; FOR_EACH_FUNCTION (node) - verify_cgraph_node (node); + node->verify (); } -/* Given NODE, walk the alias chain to return the function NODE is alias of. +/* Walk the alias chain to return the function cgraph_node is alias of. Walk through thunk, too. When AVAILABILITY is non-NULL, get minimal availability in the chain. */ -struct cgraph_node * -cgraph_function_node (struct cgraph_node *node, enum availability *availability) +cgraph_node * +cgraph_node::function_symbol (enum availability *availability) { + cgraph_node *node = NULL; + do { - node = cgraph_function_or_thunk_node (node, availability); + node = ultimate_alias_target (availability); if (node->thunk.thunk_p) { node = node->callees->callee; if (availability) { enum availability a; - a = cgraph_function_body_availability (node); + a = node->get_availability (); if (a < *availability) *availability = a; } - node = cgraph_function_or_thunk_node (node, availability); + node = node->ultimate_alias_target (availability); } } while (node && node->thunk.thunk_p); return node; } -/* When doing LTO, read NODE's body from disk if it is not already present. */ +/* When doing LTO, read cgraph_node's body from disk if it is not already + present. */ bool -cgraph_get_body (struct cgraph_node *node) +cgraph_node::get_body (void) { struct lto_file_decl_data *file_data; const char *data, *name; size_t len; - tree decl = node->decl; + tree decl = this->decl; if (DECL_RESULT (decl)) return false; @@ -3055,7 +3034,7 @@ cgraph_get_body (struct cgraph_node *node) timevar_push (TV_IPA_LTO_GIMPLE_IN); - file_data = node->lto_file_data; + file_data = lto_file_data; name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); /* We may have renamed the declaration, e.g., a static function. */ @@ -3065,7 +3044,7 @@ cgraph_get_body (struct cgraph_node *node) name, &len); if (!data) { - dump_cgraph_node (stderr, node); + debug (); fatal_error ("%s: section %s is missing", file_data->file_name, name); @@ -3073,11 +3052,11 @@ cgraph_get_body (struct cgraph_node *node) gcc_assert (DECL_STRUCT_FUNCTION (decl) == NULL); - lto_input_function_body (file_data, node, data); + lto_input_function_body (file_data, this, data); lto_stats.num_function_bodies++; lto_free_section_data (file_data, LTO_section_function_body, name, data, len); - lto_free_function_in_decl_state_for_node (node); + lto_free_function_in_decl_state_for_node (this); timevar_pop (TV_IPA_LTO_GIMPLE_IN); |