summaryrefslogtreecommitdiff
path: root/gcc/cgraph.h
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-24 22:00:14 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-24 22:00:14 +0000
commit8c0163928b8ac73298dc1ef3aca43e8921780832 (patch)
tree12ca2f5d9d68edce3aad0e13eb2c2fb693d94c86 /gcc/cgraph.h
parent5f70fed563a6de012a39846859192ba2e40ba5c8 (diff)
downloadgcc-8c0163928b8ac73298dc1ef3aca43e8921780832.tar.gz
* tree-core.h (tree_decl_with_vis): Replace comdat_group by
symtab_node pointer. * tree.c (copy_node_stat): Be sure tonot copy symtab_node pointer. (find_decls_types_r): Do not walk COMDAT_GROUP. * tree.h (DECL_COMDAT_GROUP): Revamp to use decl_comdat_group. * varasm.c (make_decl_one_only): Use set_comdat_group; create node if needed. * ipa-inline-transform.c (save_inline_function_body): Update way we decl->symtab mapping. * symtab.c (symtab_hash, hash_node, eq_node symtab_insert_node_to_hashtable): Remove. (symtab_register_node): Update. (symtab_unregister_node): Update. (symtab_get_node): Reimplement as inline function. (symtab_add_to_same_comdat_group): Update. (symtab_dissolve_same_comdat_group_list): Update. (dump_symtab_base): Update. (verify_symtab_base): Update. (symtab_make_decl_local): Update. (fixup_same_cpp_alias_visibility): Update. (symtab_nonoverwritable_alias): Update. * cgraphclones.c (set_new_clone_decl_and_node_flags): Update. * ipa.c (update_visibility_by_resolution_info): UPdate. * bb-reorder.c: Include cgraph.h * lto-streamer-out.c (DFS_write_tree_body, hash_tree): Do not deal with comdat groups. * ipa-comdats.c (set_comdat_group, ipa_comdats): Update. * cgraph.c (cgraph_get_create_node): Update. * cgraph.h (struct symtab_node): Add get_comdat_group, set_comdat_group and comdat_group_. (symtab_get_node): Make inline. (symtab_insert_node_to_hashtable): Remove. (symtab_can_be_discarded): Update. (decl_comdat_group): New function. * tree-streamer-in.c (lto_input_ts_decl_with_vis_tree_pointers): Update. * lto-cgraph.c (lto_output_node, lto_output_varpool_node): Stream out comdat group name. (read_comdat_group): New function. (input_node, input_varpool_node): Use it. * trans-mem.c (ipa_tm_create_version_alias): Update code creating comdat groups. * mips.c (mips_start_unique_function): Likewise. (ix86_code_end): Likewise. (rs6000_code_end): Likweise. * tree-streamer-out.c (DECL_COMDAT_GROUP): Do not stream comdat group. * lto-symtab.c (lto_symtab_merge_symbols): Update code setting symtab pointer. * lto.c (compare_tree_sccs_1): Do not compare comdat groups. * optmize.c (maybe_thunk_body): Use set_comdat_group. (maybe_clone_body): Likewise. * decl.c (duplicate_decls): Update code duplicating comdat group; do not copy symtab pointer; before freeing newdecl remove it from symtab. * decl2.c (constrain_visibility): Use set_comdat_group. * c-decl.c (merge_decls): Preserve symtab node pointers. (duplicate_decls): Free new decl. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210901 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraph.h')
-rw-r--r--gcc/cgraph.h53
1 files changed, 49 insertions, 4 deletions
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 9dc6f0186f1..cfb2d4850fd 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -141,6 +141,18 @@ public:
/* Circular list of nodes in the same comdat group if non-NULL. */
symtab_node *same_comdat_group;
+ /* Return comdat group. */
+ tree get_comdat_group ()
+ {
+ return comdat_group_;
+ }
+
+ /* Set comdat group. */
+ void set_comdat_group (tree group)
+ {
+ comdat_group_ = group;
+ }
+
/* Vectors of referring and referenced entities. */
struct ipa_ref_list ref_list;
@@ -153,6 +165,9 @@ public:
struct lto_file_decl_data * lto_file_data;
PTR GTY ((skip)) aux;
+
+ /* Comdat group the symbol is in. Can be private if GGC allowed that. */
+ tree comdat_group_;
};
enum availability
@@ -727,9 +742,7 @@ void symtab_register_node (symtab_node *);
void symtab_unregister_node (symtab_node *);
void symtab_remove_from_same_comdat_group (symtab_node *);
void symtab_remove_node (symtab_node *);
-symtab_node *symtab_get_node (const_tree);
symtab_node *symtab_node_for_asm (const_tree asmname);
-void symtab_insert_node_to_hashtable (symtab_node *);
void symtab_add_to_same_comdat_group (symtab_node *, symtab_node *);
void symtab_dissolve_same_comdat_group_list (symtab_node *node);
void dump_symtab (FILE *);
@@ -989,6 +1002,28 @@ void varpool_remove_initializer (varpool_node *);
/* In cgraph.c */
extern void change_decl_assembler_name (tree, tree);
+/* Return symbol table node associated with DECL, if any,
+ and NULL otherwise. */
+
+static inline symtab_node *
+symtab_get_node (const_tree decl)
+{
+#ifdef ENABLE_CHECKING
+ /* Check that we are called for sane type of object - functions
+ and static or external variables. */
+ gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
+ || (TREE_CODE (decl) == VAR_DECL
+ && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
+ || in_lto_p)));
+ /* Check that the mapping is sane - perhaps this check can go away,
+ but at the moment frontends tends to corrupt the mapping by calling
+ memcpy/memset on the tree nodes. */
+ gcc_checking_assert (!decl->decl_with_vis.symtab_node
+ || decl->decl_with_vis.symtab_node->decl == decl);
+#endif
+ return decl->decl_with_vis.symtab_node;
+}
+
/* Return callgraph node for given symbol and check it is a function. */
static inline struct cgraph_node *
cgraph (symtab_node *node)
@@ -1548,7 +1583,7 @@ static inline bool
symtab_can_be_discarded (symtab_node *node)
{
return (DECL_EXTERNAL (node->decl)
- || (DECL_ONE_ONLY (node->decl)
+ || (node->get_comdat_group ()
&& node->resolution != LDPR_PREVAILING_DEF
&& node->resolution != LDPR_PREVAILING_DEF_IRONLY
&& node->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP));
@@ -1580,6 +1615,16 @@ symtab_in_same_comdat_p (symtab_node *one, symtab_node *two)
two = cn->global.inlined_to;
}
- return DECL_COMDAT_GROUP (one->decl) == DECL_COMDAT_GROUP (two->decl);
+ return one->get_comdat_group () == two->get_comdat_group ();
+}
+
+/* Return comdat group of DECL. */
+static inline tree
+decl_comdat_group (tree node)
+{
+ struct symtab_node *snode = symtab_get_node (node);
+ if (!snode)
+ return NULL;
+ return snode->get_comdat_group ();
}
#endif /* GCC_CGRAPH_H */