aboutsummaryrefslogtreecommitdiff
path: root/gcc/varpool.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2014-08-25 15:01:47 +0200
committerMartin Liska <marxin@gcc.gnu.org>2014-08-25 13:01:47 +0000
commit3dafb85c8e6ade82adc591fe97c116b193f8bb0d (patch)
tree6efa3ef534f8ca5761c35200d5cc61a819dde6f4 /gcc/varpool.c
parent3749134042ab5f54d0c30af1ec336e7132ac9bc8 (diff)
downloadgcc-3dafb85c8e6ade82adc591fe97c116b193f8bb0d.zip
gcc-3dafb85c8e6ade82adc591fe97c116b193f8bb0d.tar.gz
gcc-3dafb85c8e6ade82adc591fe97c116b193f8bb0d.tar.bz2
IPA C++ refactoring 4/N
* cgraph.h (symtab_node): (bool needed_p (void)): created from decide_is_symbol_needed (bool referred_to_p (void)): created from referred_to_p (static cgraph_node *get_for_asmname (tree asmname)): created from symtab_node_for_asm * cgraph.h (cgraph_node): (void assemble_thunks_and_aliases (void)): created from assemble_thunks_and_aliases (void expand (void)): created from expand_function (static void finalize_function (tree, bool)): created from cgraph_finalize_function (static cgraph_local_info *local_info (tree decl)): created from cgraph_local_info (static cgraph_global_info *global_info (tree)): created from cgraph_global_info (static cgraph_rtl_info *rtl_info (tree)): created from cgraph_rtl_info * cgraph.h (varpool_node): (static void add (tree decl): created from varpool_add_new_variable * cgraph.h (cgraph_edge): void remove (void); (void remove_caller (void)): created from cgraph_edge_remove_caller (void remove_callee (void)): created from cgraph_edge_remove_callee (void set_call_stmt (gimple new_stmt, bool update_speculative = true)): created from cgraph_set_call_stmt (void redirect_callee (cgraph_node *n)): created from cgraph_redirect_edge_callee (cgraph_edge *make_direct (cgraph_node *callee)): created from cgraph_make_edge_direct (cgraph_edge *make_speculative (cgraph_node *n2, gcov_type direct_count, gimple redirect_call_stmt_to_callee (void)): created from cgraph_turn_edge_to_speculative (void speculative_call_info (cgraph_edge *&direct, cgraph_edge *&indirect, ipa_ref *&reference)): created from cgraph_speculative_call_info (cgraph_edge * clone (cgraph_node *n, gimple call_stmt, unsigned stmt_uid, gcov_type count_scale, int freq_scale, bool update_original)): created from cgraph_clone_edge (cgraph_edge *resolve_speculation (tree callee_decl)): created from cgraph_resolve_speculation (bool cannot_lead_to_return_p (void)): created from cannot_lead_to_return_p (bool recursive_p (void)): created from cgraph_edge_recursive_p (bool maybe_hot_p (void)): created from cgraph_maybe_hot_edge_p (static unsigned int rebuild_edges (void)): created from rebuild_cgraph_edges (static void rebuild_references (void)): created from cgraph_rebuild_references * cgraph.h (symbol_table): (create_reference): renamed from add_reference (maybe_create_reference): renamed from maybe_add_reference (void register_symbol (symtab_node *node)): new function (void clear_asm_symbols (void)): new function (void unregister (symtab_node *node)): new function (void release_symbol (cgraph_node *node, int uid)): new function (cgraph_node * allocate_cgraph_symbol (void)): new function (void initialize (void)): created from cgraph_init (symtab_node *first_symbol (void)):new function (asm_node *first_asm_symbol (void)):new function (symtab_node *first_defined_symbol (void)):new function (varpool_node *first_variable (void)):new function (varpool_node *next_variable (varpool_node *node)):new function (varpool_node *first_static_initializer (void)):new function (varpool_node *next_static_initializer (varpool_node *node)):new function (varpool_node *first_defined_variable (void)):new function (varpool_node *next_defined_variable (varpool_node *node)):new function (cgraph_node *first_defined_function (void)):new function (cgraph_node *next_defined_function (cgraph_node *node)):new function (cgraph_node *first_function (void)):new function (cgraph_node *next_function (cgraph_node *node)):new function (cgraph_node *first_function_with_gimple_body (void)):new function (asm_node *finalize_toplevel_asm (tree asm_str)): created from add_asm_node (bool remove_unreachable_nodes (bool before_inlining_p, FILE *file)): created from symtab_remove_unreachable_nodes (void remove_unreferenced_decls (void)): created from varpool_remove_unreferenced_decls (void process_new_functions (void)): created from cgraph_process_new_functions (void process_same_body_aliases (void)): created from cgraph_process_same_body_aliases (bool output_variables (void)): created from varpool_node::output_variables (void output_asm_statements (void)): created from output_asm_statements (void finalize_compilation_unit (void)): created from finalize_compilation_unit (void compile (void)): created from compile (void output_weakrefs (void)): created from output_weakrefs (cgraph_node *create_empty (void)): created from cgraph_node::create_empty (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_node::create_edge (void free_edge (cgraph_edge *e)): created from cgraph_free_edge (cgraph_node *next_function_with_gimple_body (cgraph_node *node)): created from cgraph_next_function_with_gimple_body (void remove_edge_removal_hook (cgraph_edge_hook_list *)): created from cgraph_remove_edge_removal_hook (cgraph_node_hook_list *add_cgraph_removal_hook (cgraph_node_hook, void *)): created from cgraph_add_node_removal_hook (void remove_cgraph_removal_hook (cgraph_node_hook_list *)): created from cgraph_remove_node_removal_hook (varpool_node_hook_list *add_varpool_removal_hook (varpool_node_hook, void *)): created from varpool_add_node_removal_hook (void remove_varpool_removal_hook (varpool_node_hook_list *)): created from varpool_remove_node_removal_hook (cgraph_node_hook_list *add_cgraph_insertion_hook (cgraph_node_hook, void *)): created from cgraph_add_function_insertion_hook (void remove_cgraph_insertion_hook (cgraph_node_hook_list *)): created from cgraph_remove_function_insertion_hook (varpool_node_hook_list *add_varpool_insertion_hook (varpool_node_hook, void *)): created from varpool_add_variable_insertion_hook (void remove_varpool_insertion_hook (varpool_node_hook_list *)): created from varpool_remove_variable_insertion_hook (cgraph_2edge_hook_list *add_edge_duplication_hook (cgraph_2edge_hook, void *)): created from cgraph_add_edge_duplication_hook (void remove_edge_duplication_hook (cgraph_2edge_hook_list *)): created from cgraph_remove_edge_duplication_hook (cgraph_2node_hook_list *add_cgraph_duplication_hook (cgraph_2node_hook, void *)): created from cgraph_add_node_duplication_hook (void remove_cgraph_duplication_hook (cgraph_2node_hook_list *)): created from cgraph_remove_node_duplication_hook (void call_edge_removal_hooks (cgraph_edge *e)): created from cgraph_call_edge_removal_hooks (void call_cgraph_insertion_hooks (cgraph_node *node)): created from call_function_insertion_hooks (void call_cgraph_removal_hooks (cgraph_node *node)): created from cgraph_call_node_removal_hooks (void call_cgraph_duplication_hooks (cgraph_node *node, cgraph_node *node2)): created from cgraph_node::call_duplication_hooks (void call_edge_duplication_hooks (cgraph_edge *cs1, cgraph_edge *cs2)): created from cgraph_call_edge_duplication_hooks (void call_varpool_removal_hooks (varpool_node *node)): created from varpool_call_node_removal_hooks (void call_varpool_insertion_hooks (varpool_node *node)): created from varpool_call_variable_insertion_hooks (void insert_to_assembler_name_hash (symtab_node *node, bool with_clones)): created from insert_to_assembler_name_hash (void unlink_from_assembler_name_hash (symtab_node *node, bool with_clones)): created from unlink_from_assembler_name_hash (void symtab_prevail_in_asm_name_hash (symtab_node *node)): created from symtab_prevail_in_asm_name_hash (void symtab_initialize_asm_name_hash (void)): created from symtab_initialize_asm_name_hash (void change_decl_assembler_name (tree decl, tree name)): created from change_decl_assembler_name (void materialize_all_clones (void)): created from cgraph_materialize_all_clones (static hashval_t decl_assembler_name_hash (const_tree asmname)): created from decl_assembler_name_hash (static bool decl_assembler_name_equal (tree decl, const_tree asmname)): created from decl_assembler_name_equal (static hashval_t hash_node_by_assembler_name (const void *p)): created from hash_node_by_assembler_name (static int eq_assembler_name (const void *p1, const void *p2)): created from eq_assembler_name From-SVN: r214422
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r--gcc/varpool.c105
1 files changed, 50 insertions, 55 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c
index b5fe71e..72971d6 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -50,19 +50,14 @@ struct varpool_node_hook_list {
struct varpool_node_hook_list *next;
};
-/* List of hooks triggered when a node is removed. */
-struct varpool_node_hook_list *first_varpool_node_removal_hook;
-/* List of hooks triggered when an variable is inserted. */
-struct varpool_node_hook_list *first_varpool_variable_insertion_hook;
-
/* Register HOOK to be called with DATA on each removed node. */
-struct varpool_node_hook_list *
-varpool_add_node_removal_hook (varpool_node_hook hook, void *data)
+varpool_node_hook_list *
+symbol_table::add_varpool_removal_hook (varpool_node_hook hook, void *data)
{
- struct varpool_node_hook_list *entry;
- struct varpool_node_hook_list **ptr = &first_varpool_node_removal_hook;
+ varpool_node_hook_list *entry;
+ varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
- entry = (struct varpool_node_hook_list *) xmalloc (sizeof (*entry));
+ entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
entry->hook = hook;
entry->data = data;
entry->next = NULL;
@@ -74,9 +69,9 @@ varpool_add_node_removal_hook (varpool_node_hook hook, void *data)
/* Remove ENTRY from the list of hooks called on removing nodes. */
void
-varpool_remove_node_removal_hook (struct varpool_node_hook_list *entry)
+symbol_table::remove_varpool_removal_hook (varpool_node_hook_list *entry)
{
- struct varpool_node_hook_list **ptr = &first_varpool_node_removal_hook;
+ varpool_node_hook_list **ptr = &m_first_varpool_removal_hook;
while (*ptr != entry)
ptr = &(*ptr)->next;
@@ -85,10 +80,10 @@ varpool_remove_node_removal_hook (struct varpool_node_hook_list *entry)
}
/* Call all node removal hooks. */
-static void
-varpool_call_node_removal_hooks (varpool_node *node)
+void
+symbol_table::call_varpool_removal_hooks (varpool_node *node)
{
- struct varpool_node_hook_list *entry = first_varpool_node_removal_hook;
+ varpool_node_hook_list *entry = m_first_varpool_removal_hook;
while (entry)
{
entry->hook (node, entry->data);
@@ -97,13 +92,13 @@ varpool_call_node_removal_hooks (varpool_node *node)
}
/* Register HOOK to be called with DATA on each inserted node. */
-struct varpool_node_hook_list *
-varpool_add_variable_insertion_hook (varpool_node_hook hook, void *data)
+varpool_node_hook_list *
+symbol_table::add_varpool_insertion_hook (varpool_node_hook hook, void *data)
{
- struct varpool_node_hook_list *entry;
- struct varpool_node_hook_list **ptr = &first_varpool_variable_insertion_hook;
+ varpool_node_hook_list *entry;
+ varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
- entry = (struct varpool_node_hook_list *) xmalloc (sizeof (*entry));
+ entry = (varpool_node_hook_list *) xmalloc (sizeof (*entry));
entry->hook = hook;
entry->data = data;
entry->next = NULL;
@@ -115,9 +110,9 @@ varpool_add_variable_insertion_hook (varpool_node_hook hook, void *data)
/* Remove ENTRY from the list of hooks called on inserted nodes. */
void
-varpool_remove_variable_insertion_hook (struct varpool_node_hook_list *entry)
+symbol_table::remove_varpool_insertion_hook (varpool_node_hook_list *entry)
{
- struct varpool_node_hook_list **ptr = &first_varpool_variable_insertion_hook;
+ varpool_node_hook_list **ptr = &m_first_varpool_insertion_hook;
while (*ptr != entry)
ptr = &(*ptr)->next;
@@ -127,9 +122,9 @@ varpool_remove_variable_insertion_hook (struct varpool_node_hook_list *entry)
/* Call all node insertion hooks. */
void
-varpool_call_variable_insertion_hooks (varpool_node *node)
+symbol_table::call_varpool_insertion_hooks (varpool_node *node)
{
- struct varpool_node_hook_list *entry = first_varpool_variable_insertion_hook;
+ varpool_node_hook_list *entry = m_first_varpool_insertion_hook;
while (entry)
{
entry->hook (node, entry->data);
@@ -167,11 +162,11 @@ varpool_node::get_create (tree decl)
void
varpool_node::remove (void)
{
- varpool_call_node_removal_hooks (this);
+ symtab->call_varpool_removal_hooks (this);
unregister ();
/* When streaming we can have multiple nodes associated with decl. */
- if (cgraph_state == CGRAPH_LTO_STREAMING)
+ if (symtab->state == LTO_STREAMING)
;
/* Keep constructor when it may be used for folding. We remove
references to external variables before final compilation. */
@@ -195,7 +190,7 @@ varpool_node::remove_initializer (void)
entries for given decl. Do not attempt to remove
the boides, or we will end up remiving
wrong one. */
- && cgraph_state != CGRAPH_LTO_STREAMING)
+ && symtab->state != LTO_STREAMING)
DECL_INITIAL (decl) = error_mark_node;
}
@@ -205,7 +200,7 @@ varpool_node::dump (FILE *f)
{
dump_base (f);
fprintf (f, " Availability: %s\n",
- cgraph_function_flags_ready
+ symtab->function_flags_ready
? cgraph_availability_names[get_availability ()]
: "not-ready");
fprintf (f, " Varpool flags:");
@@ -256,7 +251,7 @@ varpool_node::debug_varpool (void)
varpool_node *
varpool_node::get_for_asmname (tree asmname)
{
- if (symtab_node *node = symtab_node_for_asm (asmname))
+ if (symtab_node *node = symtab_node::get_for_asmname (asmname))
return dyn_cast <varpool_node *> (node);
else
return NULL;
@@ -268,7 +263,7 @@ varpool_node::get_for_asmname (tree asmname)
tree
varpool_node::get_constructor (void)
{
- struct lto_file_decl_data *file_data;
+ lto_file_decl_data *file_data;
const char *data, *name;
size_t len;
@@ -437,16 +432,16 @@ ctor_for_folding (tree decl)
}
/* Add the variable DECL to the varpool.
- Unlike varpool_finalize_decl function is intended to be used
+ Unlike finalize_decl function is intended to be used
by middle end and allows insertion of new variable at arbitrary point
of compilation. */
void
-varpool_add_new_variable (tree decl)
+varpool_node::add (tree decl)
{
varpool_node *node;
varpool_node::finalize_decl (decl);
node = varpool_node::get_create (decl);
- varpool_call_variable_insertion_hooks (node);
+ symtab->call_varpool_insertion_hooks (node);
if (node->externally_visible_p ())
node->externally_visible = true;
}
@@ -487,7 +482,7 @@ varpool_node::analyze (void)
We however don't want to re-analyze already analyzed nodes. */
if (!analyzed)
{
- gcc_assert (!in_lto_p || cgraph_function_flags_ready);
+ gcc_assert (!in_lto_p || symtab->function_flags_ready);
/* Compute the alignment early so function body expanders are
already informed about increased alignment. */
align_variable (decl, 0);
@@ -504,7 +499,7 @@ varpool_node::analyze (void)
void
varpool_node::assemble_aliases (void)
{
- struct ipa_ref *ref;
+ ipa_ref *ref;
FOR_EACH_ALIAS (this, ref)
{
@@ -578,20 +573,20 @@ enqueue_node (varpool_node *node, varpool_node **first)
reachability starting from variables that are either externally visible
or was referred from the asm output routines. */
-static void
-varpool_remove_unreferenced_decls (void)
+void
+symbol_table::remove_unreferenced_decls (void)
{
varpool_node *next, *node;
varpool_node *first = (varpool_node *)(void *)1;
int i;
- struct ipa_ref *ref = NULL;
+ ipa_ref *ref = NULL;
hash_set<varpool_node *> referenced;
if (seen_error ())
return;
- if (cgraph_dump_file)
- fprintf (cgraph_dump_file, "Trivially needed variables:");
+ if (dump_file)
+ fprintf (dump_file, "Trivially needed variables:");
FOR_EACH_DEFINED_VARIABLE (node)
{
if (node->analyzed
@@ -601,8 +596,8 @@ varpool_remove_unreferenced_decls (void)
|| DECL_RTL_SET_P (node->decl)))
{
enqueue_node (node, &first);
- if (cgraph_dump_file)
- fprintf (cgraph_dump_file, " %s", node->asm_name ());
+ if (dump_file)
+ fprintf (dump_file, " %s", node->asm_name ());
}
}
while (first != (varpool_node *)(void *)1)
@@ -635,24 +630,24 @@ varpool_remove_unreferenced_decls (void)
referenced.add (node);
}
}
- if (cgraph_dump_file)
- fprintf (cgraph_dump_file, "\nRemoving variables:");
- for (node = varpool_first_defined_variable (); node; node = next)
+ if (dump_file)
+ fprintf (dump_file, "\nRemoving variables:");
+ for (node = first_defined_variable (); node; node = next)
{
- next = varpool_next_defined_variable (node);
+ next = next_defined_variable (node);
if (!node->aux)
{
- if (cgraph_dump_file)
- fprintf (cgraph_dump_file, " %s", node->asm_name ());
- if (referenced.contains (node))
+ if (dump_file)
+ fprintf (dump_file, " %s", node->asm_name ());
+ if (referenced.contains(node))
node->remove_initializer ();
else
node->remove ();
}
}
- if (cgraph_dump_file)
- fprintf (cgraph_dump_file, "\n");
+ if (dump_file)
+ fprintf (dump_file, "\n");
}
/* For variables in named sections make sure get_variable_section
@@ -674,7 +669,7 @@ varpool_node::finalize_named_section_flags (void)
/* Output all variables enqueued to be assembled. */
bool
-varpool_node::output_variables (void)
+symbol_table::output_variables (void)
{
bool changed = false;
varpool_node *node;
@@ -682,7 +677,7 @@ varpool_node::output_variables (void)
if (seen_error ())
return false;
- varpool_remove_unreferenced_decls ();
+ remove_unreferenced_decls ();
timevar_push (TV_VAROUT);
@@ -755,7 +750,7 @@ varpool_node::create_extra_name_alias (tree alias, tree decl)
via DECL_ASSEMBLER_NAME mechanizm.
This is unfortunate because they are not going through the
standard channels. Ensure they get output. */
- if (cpp_implicit_aliases_done)
+ if (symtab->cpp_implicit_aliases_done)
alias_node->resolve_alias (varpool_node::get_create (decl));
return alias_node;
}
@@ -770,7 +765,7 @@ varpool_node::call_for_node_and_aliases (bool (*callback) (varpool_node *,
void *data,
bool include_overwritable)
{
- struct ipa_ref *ref;
+ ipa_ref *ref;
if (callback (this, data))
return true;