summaryrefslogtreecommitdiff
path: root/gcc/cgraphclones.c
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-24 12:07:13 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-24 12:07:13 +0000
commit415d1b9a7810774124b32b9dc3990c81ba96efaa (patch)
tree4dd09f8eb18392a620ad92b028d01fbda5d27ee7 /gcc/cgraphclones.c
parenta0792f1ef98b4610cc0a20de07c5f891e4c345a1 (diff)
downloadgcc-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/cgraphclones.c')
-rw-r--r--gcc/cgraphclones.c300
1 files changed, 143 insertions, 157 deletions
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 2e7dc9060b7..f097da8b22d 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -128,21 +128,21 @@ cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n,
via cgraph_resolve_speculation and not here. */
&& !e->speculative)
{
- struct cgraph_node *callee = cgraph_get_node (decl);
+ struct cgraph_node *callee = cgraph_node::get (decl);
gcc_checking_assert (callee);
- new_edge = cgraph_create_edge (n, callee, call_stmt, count, freq);
+ new_edge = n->create_edge (callee, call_stmt, count, freq);
}
else
{
- new_edge = cgraph_create_indirect_edge (n, call_stmt,
- e->indirect_info->ecf_flags,
- count, freq);
+ new_edge = n->create_indirect_edge (call_stmt,
+ e->indirect_info->ecf_flags,
+ count, freq);
*new_edge->indirect_info = *e->indirect_info;
}
}
else
{
- new_edge = cgraph_create_edge (n, e->callee, call_stmt, count, freq);
+ new_edge = n->create_edge (e->callee, call_stmt, count, freq);
if (e->indirect_info)
{
new_edge->indirect_info
@@ -304,7 +304,7 @@ static cgraph_node *
duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
{
cgraph_node *new_thunk, *thunk_of;
- thunk_of = cgraph_function_or_thunk_node (thunk->callees->callee);
+ thunk_of = thunk->callees->callee->ultimate_alias_target ();
if (thunk_of->thunk.thunk_p)
node = duplicate_thunk_for_node (thunk_of, node);
@@ -341,7 +341,7 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
DECL_NAME (new_decl) = clone_function_name (thunk->decl, "artificial_thunk");
SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
- new_thunk = cgraph_create_node (new_decl);
+ new_thunk = cgraph_node::create (new_decl);
set_new_clone_decl_and_node_flags (new_thunk);
new_thunk->definition = true;
new_thunk->thunk = thunk->thunk;
@@ -350,13 +350,13 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
new_thunk->clone.args_to_skip = node->clone.args_to_skip;
new_thunk->clone.combined_args_to_skip = node->clone.combined_args_to_skip;
- struct cgraph_edge *e = cgraph_create_edge (new_thunk, node, NULL, 0,
- CGRAPH_FREQ_BASE);
+ struct cgraph_edge *e = new_thunk->create_edge (node, NULL, 0,
+ CGRAPH_FREQ_BASE);
e->call_stmt_cannot_inline_p = true;
cgraph_call_edge_duplication_hooks (thunk->callees, e);
- if (!expand_thunk (new_thunk, false, false))
+ if (!new_thunk->expand_thunk (false, false))
new_thunk->analyzed = true;
- cgraph_call_node_duplication_hooks (thunk, new_thunk);
+ thunk->call_duplication_hooks (new_thunk);
return new_thunk;
}
@@ -367,7 +367,7 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
void
redirect_edge_duplicating_thunks (struct cgraph_edge *e, struct cgraph_node *n)
{
- cgraph_node *orig_to = cgraph_function_or_thunk_node (e->callee);
+ cgraph_node *orig_to = e->callee->ultimate_alias_target ();
if (orig_to->thunk.thunk_p)
n = duplicate_thunk_for_node (orig_to, n);
@@ -390,67 +390,67 @@ redirect_edge_duplicating_thunks (struct cgraph_edge *e, struct cgraph_node *n)
will see this in node's global.inlined_to, when invoked. Can be NULL if the
node is not inlined. */
-struct cgraph_node *
-cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
- bool update_original,
- vec<cgraph_edge_p> redirect_callers,
- bool call_duplication_hook,
- struct cgraph_node *new_inlined_to,
- bitmap args_to_skip)
+cgraph_node *
+cgraph_node::create_clone (tree decl, gcov_type gcov_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)
{
- struct cgraph_node *new_node = cgraph_create_empty_node ();
+ struct cgraph_node *new_node = cgraph_node::create_empty ();
struct cgraph_edge *e;
gcov_type count_scale;
unsigned i;
new_node->decl = decl;
- symtab_register_node (new_node);
- new_node->origin = n->origin;
- new_node->lto_file_data = n->lto_file_data;
+ new_node->register_symbol ();
+ new_node->origin = origin;
+ new_node->lto_file_data = lto_file_data;
if (new_node->origin)
{
new_node->next_nested = new_node->origin->nested;
new_node->origin->nested = new_node;
}
- new_node->analyzed = n->analyzed;
- new_node->definition = n->definition;
- new_node->local = n->local;
+ new_node->analyzed = analyzed;
+ new_node->definition = definition;
+ new_node->local = local;
new_node->externally_visible = false;
new_node->local.local = true;
- new_node->global = n->global;
+ new_node->global = global;
new_node->global.inlined_to = new_inlined_to;
- new_node->rtl = n->rtl;
+ new_node->rtl = rtl;
new_node->count = count;
- new_node->frequency = n->frequency;
- new_node->tp_first_run = n->tp_first_run;
+ new_node->frequency = frequency;
+ new_node->tp_first_run = tp_first_run;
new_node->clone.tree_map = NULL;
new_node->clone.args_to_skip = args_to_skip;
if (!args_to_skip)
- new_node->clone.combined_args_to_skip = n->clone.combined_args_to_skip;
- else if (n->clone.combined_args_to_skip)
+ new_node->clone.combined_args_to_skip = clone.combined_args_to_skip;
+ else if (clone.combined_args_to_skip)
{
new_node->clone.combined_args_to_skip = BITMAP_GGC_ALLOC ();
bitmap_ior (new_node->clone.combined_args_to_skip,
- n->clone.combined_args_to_skip, args_to_skip);
+ clone.combined_args_to_skip, args_to_skip);
}
else
new_node->clone.combined_args_to_skip = args_to_skip;
- if (n->count)
+ if (count)
{
- if (new_node->count > n->count)
+ if (new_node->count > count)
count_scale = REG_BR_PROB_BASE;
else
- count_scale = GCOV_COMPUTE_SCALE (new_node->count, n->count);
+ count_scale = GCOV_COMPUTE_SCALE (new_node->count, count);
}
else
count_scale = 0;
if (update_original)
{
- n->count -= count;
- if (n->count < 0)
- n->count = 0;
+ count -= gcov_count;
+ if (count < 0)
+ count = 0;
}
FOR_EACH_VEC_ELT (redirect_callers, i, e)
@@ -464,23 +464,23 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
redirect_edge_duplicating_thunks (e, new_node);
}
- for (e = n->callees;e; e=e->next_callee)
+ for (e = callees;e; e=e->next_callee)
cgraph_clone_edge (e, new_node, e->call_stmt, e->lto_stmt_uid,
count_scale, freq, update_original);
- for (e = n->indirect_calls; e; e = e->next_callee)
+ for (e = indirect_calls; e; e = e->next_callee)
cgraph_clone_edge (e, new_node, e->call_stmt, e->lto_stmt_uid,
count_scale, freq, update_original);
- new_node->clone_references (n);
+ new_node->clone_references (this);
- new_node->next_sibling_clone = n->clones;
- if (n->clones)
- n->clones->prev_sibling_clone = new_node;
- n->clones = new_node;
- new_node->clone_of = n;
+ new_node->next_sibling_clone = clones;
+ if (clones)
+ clones->prev_sibling_clone = new_node;
+ clones = new_node;
+ new_node->clone_of = this;
if (call_duplication_hook)
- cgraph_call_node_duplication_hooks (n, new_node);
+ call_duplication_hooks (new_node);
return new_node;
}
@@ -516,13 +516,11 @@ clone_function_name (tree decl, const char *suffix)
bitmap interface.
*/
struct cgraph_node *
-cgraph_create_virtual_clone (struct cgraph_node *old_node,
- vec<cgraph_edge_p> redirect_callers,
- vec<ipa_replace_map_p, va_gc> *tree_map,
- bitmap args_to_skip,
- const char * suffix)
+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)
{
- tree old_decl = old_node->decl;
+ tree old_decl = decl;
struct cgraph_node *new_node = NULL;
tree new_decl;
size_t len, i;
@@ -532,7 +530,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
if (!in_lto_p)
gcc_checking_assert (tree_versionable_function_p (old_decl));
- gcc_assert (old_node->local.can_change_signature || !args_to_skip);
+ gcc_assert (local.can_change_signature || !args_to_skip);
/* Make a new FUNCTION_DECL tree node */
if (!args_to_skip)
@@ -560,9 +558,9 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
SET_DECL_ASSEMBLER_NAME (new_decl, clone_function_name (old_decl, suffix));
SET_DECL_RTL (new_decl, NULL);
- new_node = cgraph_clone_node (old_node, new_decl, old_node->count,
- CGRAPH_FREQ_BASE, false,
- redirect_callers, false, NULL, args_to_skip);
+ new_node = create_clone (new_decl, count, CGRAPH_FREQ_BASE, false,
+ redirect_callers, false, NULL, args_to_skip);
+
/* Update the properties.
Make clone visible only within this translation unit. Make sure
that is not weak also.
@@ -581,26 +579,25 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
new_node->maybe_add_reference (map->new_tree, IPA_REF_ADDR, NULL);
- if (old_node->ipa_transforms_to_apply.exists ())
+ if (ipa_transforms_to_apply.exists ())
new_node->ipa_transforms_to_apply
- = old_node->ipa_transforms_to_apply.copy ();
-
- cgraph_call_node_duplication_hooks (old_node, new_node);
+ = ipa_transforms_to_apply.copy ();
+ call_duplication_hooks (new_node);
return new_node;
}
-/* NODE is being removed from symbol table; see if its entry can be replaced by
- other inline clone. */
-struct cgraph_node *
-cgraph_find_replacement_node (struct cgraph_node *node)
+/* callgraph node being removed from symbol table; see if its entry can be
+ replaced by other inline clone. */
+cgraph_node *
+cgraph_node::find_replacement (void)
{
struct cgraph_node *next_inline_clone, *replacement;
- for (next_inline_clone = node->clones;
+ for (next_inline_clone = clones;
next_inline_clone
- && next_inline_clone->decl != node->decl;
+ && next_inline_clone->decl != decl;
next_inline_clone = next_inline_clone->next_sibling_clone)
;
@@ -620,32 +617,32 @@ cgraph_find_replacement_node (struct cgraph_node *node)
= next_inline_clone->prev_sibling_clone;
if (next_inline_clone->prev_sibling_clone)
{
- gcc_assert (node->clones != next_inline_clone);
+ gcc_assert (clones != next_inline_clone);
next_inline_clone->prev_sibling_clone->next_sibling_clone
= next_inline_clone->next_sibling_clone;
}
else
{
- gcc_assert (node->clones == next_inline_clone);
- node->clones = next_inline_clone->next_sibling_clone;
+ gcc_assert (clones == next_inline_clone);
+ clones = next_inline_clone->next_sibling_clone;
}
- new_clones = node->clones;
- node->clones = NULL;
+ new_clones = clones;
+ clones = NULL;
/* Copy clone info. */
- next_inline_clone->clone = node->clone;
+ next_inline_clone->clone = clone;
/* Now place it into clone tree at same level at NODE. */
- next_inline_clone->clone_of = node->clone_of;
+ next_inline_clone->clone_of = clone_of;
next_inline_clone->prev_sibling_clone = NULL;
next_inline_clone->next_sibling_clone = NULL;
- if (node->clone_of)
+ if (clone_of)
{
- if (node->clone_of->clones)
- node->clone_of->clones->prev_sibling_clone = next_inline_clone;
- next_inline_clone->next_sibling_clone = node->clone_of->clones;
- node->clone_of->clones = next_inline_clone;
+ if (clone_of->clones)
+ clone_of->clones->prev_sibling_clone = next_inline_clone;
+ next_inline_clone->next_sibling_clone = clone_of->clones;
+ clone_of->clones = next_inline_clone;
}
/* Merge the clone list. */
@@ -657,7 +654,7 @@ cgraph_find_replacement_node (struct cgraph_node *node)
{
n = next_inline_clone->clones;
while (n->next_sibling_clone)
- n = n->next_sibling_clone;
+ n = n->next_sibling_clone;
n->next_sibling_clone = new_clones;
new_clones->prev_sibling_clone = n;
}
@@ -683,21 +680,20 @@ cgraph_find_replacement_node (struct cgraph_node *node)
call. */
void
-cgraph_set_call_stmt_including_clones (struct cgraph_node *orig,
- gimple old_stmt, gimple new_stmt,
- bool update_speculative)
+cgraph_node::set_call_stmt_including_clones (gimple old_stmt, gimple new_stmt,
+ bool update_speculative)
{
struct cgraph_node *node;
- struct cgraph_edge *edge = cgraph_edge (orig, old_stmt);
+ struct cgraph_edge *edge = get_edge (old_stmt);
if (edge)
cgraph_set_call_stmt (edge, new_stmt, update_speculative);
- node = orig->clones;
+ node = clones;
if (node)
- while (node != orig)
+ while (node != this)
{
- struct cgraph_edge *edge = cgraph_edge (node, old_stmt);
+ struct cgraph_edge *edge = node->get_edge (old_stmt);
if (edge)
{
cgraph_set_call_stmt (edge, new_stmt, update_speculative);
@@ -722,9 +718,9 @@ cgraph_set_call_stmt_including_clones (struct cgraph_node *orig,
node = node->next_sibling_clone;
else
{
- while (node != orig && !node->next_sibling_clone)
+ while (node != this && !node->next_sibling_clone)
node = node->clone_of;
- if (node != orig)
+ if (node != this)
node = node->next_sibling_clone;
}
}
@@ -738,27 +734,26 @@ cgraph_set_call_stmt_including_clones (struct cgraph_node *orig,
frequencies of the clones. */
void
-cgraph_create_edge_including_clones (struct cgraph_node *orig,
- struct cgraph_node *callee,
- gimple old_stmt,
- gimple stmt, gcov_type count,
- int freq,
- cgraph_inline_failed_t reason)
+cgraph_node::create_edge_including_clones (struct cgraph_node *callee,
+ gimple old_stmt, gimple stmt,
+ gcov_type count,
+ int freq,
+ cgraph_inline_failed_t reason)
{
struct cgraph_node *node;
struct cgraph_edge *edge;
- if (!cgraph_edge (orig, stmt))
+ if (!get_edge (stmt))
{
- edge = cgraph_create_edge (orig, callee, stmt, count, freq);
+ edge = create_edge (callee, stmt, count, freq);
edge->inline_failed = reason;
}
- node = orig->clones;
+ node = clones;
if (node)
- while (node != orig)
+ while (node != this)
{
- struct cgraph_edge *edge = cgraph_edge (node, old_stmt);
+ struct cgraph_edge *edge = node->get_edge (old_stmt);
/* It is possible that clones already contain the edge while
master didn't. Either we promoted indirect call into direct
@@ -766,10 +761,9 @@ cgraph_create_edge_including_clones (struct cgraph_node *orig,
master where edges has been removed. */
if (edge)
cgraph_set_call_stmt (edge, stmt);
- else if (!cgraph_edge (node, stmt))
+ else if (! node->get_edge (stmt))
{
- edge = cgraph_create_edge (node, callee, stmt, count,
- freq);
+ edge = node->create_edge (callee, stmt, count, freq);
edge->inline_failed = reason;
}
@@ -779,9 +773,9 @@ cgraph_create_edge_including_clones (struct cgraph_node *orig,
node = node->next_sibling_clone;
else
{
- while (node != orig && !node->next_sibling_clone)
+ while (node != this && !node->next_sibling_clone)
node = node->clone_of;
- if (node != orig)
+ if (node != this)
node = node->next_sibling_clone;
}
}
@@ -793,23 +787,23 @@ cgraph_create_edge_including_clones (struct cgraph_node *orig,
tree. */
bool
-cgraph_remove_node_and_inline_clones (struct cgraph_node *node, struct cgraph_node *forbidden_node)
+cgraph_node::remove_symbol_and_inline_clones (cgraph_node *forbidden_node)
{
struct cgraph_edge *e, *next;
bool found = false;
- if (node == forbidden_node)
+ if (this == forbidden_node)
{
- cgraph_remove_edge (node->callers);
+ cgraph_remove_edge (callers);
return true;
}
- for (e = node->callees; e; e = next)
+ for (e = callees; e; e = next)
{
next = e->next_callee;
if (!e->inline_failed)
- found |= cgraph_remove_node_and_inline_clones (e->callee, forbidden_node);
+ found |= e->callee->remove_symbol_and_inline_clones (forbidden_node);
}
- cgraph_remove_node (node);
+ remove ();
return found;
}
@@ -835,9 +829,9 @@ update_call_expr (struct cgraph_node *new_version)
/* Create a new cgraph node which is the new version of
- OLD_VERSION node. REDIRECT_CALLERS holds the callers
+ callgraph node. REDIRECT_CALLERS holds the callers
edges which should be redirected to point to
- NEW_VERSION. ALL the callees edges of OLD_VERSION
+ NEW_VERSION. ALL the callees edges of the node
are cloned to the new version node. Return the new
version node.
@@ -845,37 +839,34 @@ update_call_expr (struct cgraph_node *new_version)
was copied to prevent duplications of calls that are dead
in the clone. */
-struct cgraph_node *
-cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
- tree new_decl,
- vec<cgraph_edge_p> redirect_callers,
- bitmap bbs_to_copy)
+cgraph_node *
+cgraph_node::create_version_clone (tree new_decl,
+ vec<cgraph_edge *> redirect_callers,
+ bitmap bbs_to_copy)
{
struct cgraph_node *new_version;
struct cgraph_edge *e;
unsigned i;
- gcc_assert (old_version);
-
- new_version = cgraph_create_node (new_decl);
+ new_version = cgraph_node::create (new_decl);
- new_version->analyzed = old_version->analyzed;
- new_version->definition = old_version->definition;
- new_version->local = old_version->local;
+ new_version->analyzed = analyzed;
+ new_version->definition = definition;
+ new_version->local = local;
new_version->externally_visible = false;
new_version->local.local = new_version->definition;
- new_version->global = old_version->global;
- new_version->rtl = old_version->rtl;
- new_version->count = old_version->count;
+ new_version->global = global;
+ new_version->rtl = rtl;
+ new_version->count = count;
- for (e = old_version->callees; e; e=e->next_callee)
+ for (e = callees; e; e=e->next_callee)
if (!bbs_to_copy
|| bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
cgraph_clone_edge (e, new_version, e->call_stmt,
e->lto_stmt_uid, REG_BR_PROB_BASE,
CGRAPH_FREQ_BASE,
true);
- for (e = old_version->indirect_calls; e; e=e->next_callee)
+ for (e = indirect_calls; e; e=e->next_callee)
if (!bbs_to_copy
|| bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
cgraph_clone_edge (e, new_version, e->call_stmt,
@@ -889,7 +880,7 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
cgraph_redirect_edge_callee (e, new_version);
}
- cgraph_call_node_duplication_hooks (old_version, new_version);
+ call_duplication_hooks (new_version);
return new_version;
}
@@ -904,7 +895,6 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
TREE_MAP is a mapping of tree nodes we want to replace with
new ones (according to results of prior analysis).
- OLD_VERSION_NODE is the node that is versioned.
If non-NULL ARGS_TO_SKIP determine function parameters to remove
from new version.
@@ -914,24 +904,21 @@ cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
Return the new version's cgraph node. */
-struct cgraph_node *
-cgraph_function_versioning (struct cgraph_node *old_version_node,
- vec<cgraph_edge_p> redirect_callers,
- vec<ipa_replace_map_p, va_gc> *tree_map,
- bitmap args_to_skip,
- bool skip_return,
- bitmap bbs_to_copy,
- basic_block new_entry_block,
- const char *clone_name)
+cgraph_node *
+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)
{
- tree old_decl = old_version_node->decl;
+ tree old_decl = decl;
struct cgraph_node *new_version_node = NULL;
tree new_decl;
if (!tree_versionable_function_p (old_decl))
return NULL;
- gcc_assert (old_version_node->local.can_change_signature || !args_to_skip);
+ gcc_assert (local.can_change_signature || !args_to_skip);
/* Make a new FUNCTION_DECL tree node for the new version. */
if (!args_to_skip && !skip_return)
@@ -951,13 +938,12 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
/* Create the new version's call-graph node.
and update the edges of the new node. */
- new_version_node =
- cgraph_copy_node_for_versioning (old_version_node, new_decl,
- redirect_callers, bbs_to_copy);
+ new_version_node = create_version_clone (new_decl, redirect_callers,
+ bbs_to_copy);
- if (old_version_node->ipa_transforms_to_apply.exists ())
+ if (ipa_transforms_to_apply.exists ())
new_version_node->ipa_transforms_to_apply
- = old_version_node->ipa_transforms_to_apply.copy ();
+ = ipa_transforms_to_apply.copy ();
/* Copy the OLD_VERSION_NODE function tree to the new version. */
tree_function_versioning (old_decl, new_decl, tree_map, false, args_to_skip,
skip_return, bbs_to_copy, new_entry_block);
@@ -967,7 +953,7 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
that is not weak also.
??? We cannot use COMDAT linkage because there is no
ABI support for this. */
- symtab_make_decl_local (new_version_node->decl);
+ new_version_node->make_decl_local ();
DECL_VIRTUAL_P (new_version_node->decl) = 0;
new_version_node->externally_visible = 0;
new_version_node->local.local = 1;
@@ -983,7 +969,7 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
/* Update the call_expr on the edges to call the new version node. */
update_call_expr (new_version_node);
- cgraph_call_function_insertion_hooks (new_version_node);
+ new_version_node->call_function_insertion_hooks ();
return new_version_node;
}
@@ -1018,8 +1004,8 @@ cgraph_materialize_clone (struct cgraph_node *node)
node->prev_sibling_clone = NULL;
if (!node->clone_of->analyzed && !node->clone_of->clones)
{
- cgraph_release_function_body (node->clone_of);
- cgraph_node_remove_callees (node->clone_of);
+ node->clone_of->release_body ();
+ node->clone_of->remove_callees ();
node->clone_of->remove_all_references ();
}
node->clone_of = NULL;
@@ -1042,7 +1028,7 @@ cgraph_materialize_all_clones (void)
if (cgraph_dump_file)
fprintf (cgraph_dump_file, "Materializing clones\n");
#ifdef ENABLE_CHECKING
- verify_cgraph ();
+ cgraph_node::verify_cgraph_nodes ();
#endif
/* We can also do topological order, but number of iterations should be
@@ -1057,7 +1043,7 @@ cgraph_materialize_all_clones (void)
&& !gimple_has_body_p (node->decl))
{
if (!node->clone_of->clone_of)
- cgraph_get_body (node->clone_of);
+ node->clone_of->get_body ();
if (gimple_has_body_p (node->clone_of->decl))
{
if (cgraph_dump_file)
@@ -1104,7 +1090,7 @@ cgraph_materialize_all_clones (void)
FOR_EACH_FUNCTION (node)
if (!node->analyzed && node->callees)
{
- cgraph_node_remove_callees (node);
+ node->remove_callees ();
node->remove_all_references ();
}
else
@@ -1112,7 +1098,7 @@ cgraph_materialize_all_clones (void)
if (cgraph_dump_file)
fprintf (cgraph_dump_file, "Materialization Call site updates done.\n");
#ifdef ENABLE_CHECKING
- verify_cgraph ();
+ cgraph_node::verify_cgraph_nodes ();
#endif
symtab_remove_unreachable_nodes (false, cgraph_dump_file);
}