From b395f451e4885860674410cda8c8fb2d5fa51d20 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 20 May 2014 19:57:45 +0000 Subject: [PATCH] * tree.h (DECL_ONE_ONLY): Return true only for externally visible symbols. * except.c (switch_to_exception_section, resolve_unique_section, get_named_text_section, default_function_rodata_section, align_variable, get_block_for_decl, default_section_type_flags): Use DECL_COMDAT_GROUP instead of DECL_ONE_ONLY. * symtab.c (symtab_add_to_same_comdat_group, symtab_make_decl_local, fixup_same_cpp_alias_visibility, symtab_nonoverwritable_alias, symtab_get_symbol_partitioning_class): Likewise. * cgraphclones.c (cgraph_create_virtual_clone): Likewise. * bb-reorder.c (pass_partition_blocks::gate): Likewise. * config/c6x/c6x.c (c6x_elf_unique_section): Likewise. (c6x_function_in_section_p): Likewise. * config/darwin.c (machopic_select_section): Likewise. * config/arm/arm.c (arm_function_in_section_p): Likewise. * config/mips/mips.c (mips_function_rodata_section): Likewise. * config/mep/mep.c (mep_select_section): LIkewise. * config/i386/i386.c (x86_64_elf_unique_section): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210654 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 22 ++++++++++++++++++++++ gcc/bb-reorder.c | 2 +- gcc/cgraphclones.c | 2 +- gcc/config/arm/arm.c | 2 +- gcc/config/c6x/c6x.c | 4 ++-- gcc/config/darwin.c | 2 +- gcc/config/i386/i386.c | 2 +- gcc/config/mep/mep.c | 4 ++-- gcc/config/mips/mips.c | 2 +- gcc/except.c | 4 ++-- gcc/symtab.c | 15 +++++++-------- gcc/tree.h | 3 ++- gcc/varasm.c | 15 ++++++++------- 13 files changed, 51 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2ee681aa1cc..e16d69e5e57 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2014-05-20 Jan Hubicka + + * tree.h (DECL_ONE_ONLY): Return true only for externally visible + symbols. + * except.c (switch_to_exception_section, resolve_unique_section, + get_named_text_section, default_function_rodata_section, + align_variable, get_block_for_decl, default_section_type_flags): + Use DECL_COMDAT_GROUP instead of DECL_ONE_ONLY. + * symtab.c (symtab_add_to_same_comdat_group, + symtab_make_decl_local, fixup_same_cpp_alias_visibility, + symtab_nonoverwritable_alias, symtab_get_symbol_partitioning_class): + Likewise. + * cgraphclones.c (cgraph_create_virtual_clone): Likewise. + * bb-reorder.c (pass_partition_blocks::gate): Likewise. + * config/c6x/c6x.c (c6x_elf_unique_section): Likewise. + (c6x_function_in_section_p): Likewise. + * config/darwin.c (machopic_select_section): Likewise. + * config/arm/arm.c (arm_function_in_section_p): Likewise. + * config/mips/mips.c (mips_function_rodata_section): Likewise. + * config/mep/mep.c (mep_select_section): LIkewise. + * config/i386/i386.c (x86_64_elf_unique_section): Likewise. + 2014-05-20 Eric Botcazou * tree-ssa-dom.c (hashable_expr_equal_p) : Also compare the diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index 3d7fad59339..f16f57b6961 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -2669,7 +2669,7 @@ pass_partition_blocks::gate (function *fun) /* See gate_handle_reorder_blocks. We should not partition if we are going to omit the reordering. */ && optimize_function_for_speed_p (fun) - && !DECL_ONE_ONLY (current_function_decl) + && !DECL_COMDAT_GROUP (current_function_decl) && !user_defined_section_attribute); } diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index d61e0f74db7..df8b2a29e22 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -558,7 +558,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node, that is not weak also. ??? We cannot use COMDAT linkage because there is no ABI support for this. */ - if (DECL_ONE_ONLY (old_decl)) + if (DECL_COMDAT_GROUP (old_decl)) DECL_SECTION_NAME (new_node->decl) = NULL; set_new_clone_decl_and_node_flags (new_node); new_node->clone.tree_map = tree_map; diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 43a8c4195b4..ccad5484ff5 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -6154,7 +6154,7 @@ arm_function_in_section_p (tree decl, section *section) if (!DECL_SECTION_NAME (decl)) { /* Make sure that we will not create a unique section for DECL. */ - if (flag_function_sections || DECL_ONE_ONLY (decl)) + if (flag_function_sections || DECL_COMDAT_GROUP (decl)) return false; } diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index 2da2790bf53..339da13e23b 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -985,7 +985,7 @@ c6x_elf_unique_section (tree decl, int reloc) { const char *prefix = NULL; /* We only need to use .gnu.linkonce if we don't have COMDAT groups. */ - bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP; + bool one_only = DECL_COMDAT_GROUP (decl) && !HAVE_COMDAT_GROUP; if (c6x_in_small_data_p (decl)) { @@ -1202,7 +1202,7 @@ c6x_function_in_section_p (tree decl, section *section) if (!DECL_SECTION_NAME (decl)) { /* Make sure that we will not create a unique section for DECL. */ - if (flag_function_sections || DECL_ONE_ONLY (decl)) + if (flag_function_sections || DECL_COMDAT_GROUP (decl)) return false; } diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 462c81d0a08..cec341dfe35 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1521,7 +1521,7 @@ machopic_select_section (tree decl, one = DECL_P (decl) && TREE_CODE (decl) == VAR_DECL - && DECL_ONE_ONLY (decl); + && DECL_COMDAT_GROUP (decl); ro = TREE_READONLY (decl) || TREE_CONSTANT (decl) ; diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 6ffb7884008..415e31b5606 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5147,7 +5147,7 @@ x86_64_elf_unique_section (tree decl, int reloc) { const char *prefix = NULL; /* We only need to use .gnu.linkonce if we don't have COMDAT groups. */ - bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP; + bool one_only = DECL_COMDAT_GROUP (decl) && !HAVE_COMDAT_GROUP; switch (categorize_decl_for_section (decl, reloc)) { diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index c780b5afdea..107f1fa02d7 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -4532,7 +4532,7 @@ mep_select_section (tree decl, int reloc ATTRIBUTE_UNUSED, else encoding = 0; - if (flag_function_sections || DECL_ONE_ONLY (decl)) + if (flag_function_sections || DECL_COMDAT_GROUP (decl)) mep_unique_section (decl, 0); else if (lookup_attribute ("vliw", TYPE_ATTRIBUTES (TREE_TYPE (decl)))) { @@ -4651,7 +4651,7 @@ mep_unique_section (tree decl, int reloc) name += 3; } - prefix = prefixes[sec][DECL_ONE_ONLY(decl)]; + prefix = prefixes[sec][DECL_COMDAT_GROUP(decl) != NULL]; len = strlen (name) + strlen (prefix); string = (char *) alloca (len + 1); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index a754353a98b..17af1d6fbd6 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -8469,7 +8469,7 @@ mips_function_rodata_section (tree decl) if (decl && DECL_SECTION_NAME (decl)) { const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); - if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0) + if (DECL_COMDAT_GROUP (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0) { char *rname = ASTRDUP (name); rname[14] = 'd'; diff --git a/gcc/except.c b/gcc/except.c index 82985938b66..fe1de06a12e 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -2867,12 +2867,12 @@ switch_to_exception_section (const char * ARG_UNUSED (fnname)) #ifdef HAVE_LD_EH_GC_SECTIONS if (flag_function_sections - || (DECL_ONE_ONLY (current_function_decl) && HAVE_COMDAT_GROUP)) + || (DECL_COMDAT_GROUP (current_function_decl) && HAVE_COMDAT_GROUP)) { char *section_name = XNEWVEC (char, strlen (fnname) + 32); /* The EH table must match the code section, so only mark it linkonce if we have COMDAT groups to tie them together. */ - if (DECL_ONE_ONLY (current_function_decl) && HAVE_COMDAT_GROUP) + if (DECL_COMDAT_GROUP (current_function_decl) && HAVE_COMDAT_GROUP) flags |= SECTION_LINKONCE; sprintf (section_name, ".gcc_except_table.%s", fnname); s = get_section (section_name, flags, current_function_decl); diff --git a/gcc/symtab.c b/gcc/symtab.c index 6b9b77abdfc..9d7c7e64b49 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -513,7 +513,7 @@ void symtab_add_to_same_comdat_group (symtab_node *new_node, symtab_node *old_node) { - gcc_assert (DECL_ONE_ONLY (old_node->decl)); + gcc_assert (DECL_COMDAT_GROUP (old_node->decl)); gcc_assert (!new_node->same_comdat_group); gcc_assert (new_node != old_node); @@ -832,9 +832,9 @@ verify_symtab_base (symtab_node *node) { symtab_node *n = node->same_comdat_group; - if (!DECL_ONE_ONLY (n->decl)) + if (!DECL_COMDAT_GROUP (n->decl)) { - error ("non-DECL_ONE_ONLY node in a same_comdat_group list"); + error ("node is in same_comdat_group list but has no DECL_COMDAT_GROUP"); error_found = true; } if (DECL_COMDAT_GROUP (n->decl) != DECL_COMDAT_GROUP (node->same_comdat_group->decl)) @@ -958,7 +958,7 @@ symtab_make_decl_local (tree decl) DECL_COMMON (decl) = 0; else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - if (DECL_ONE_ONLY (decl) || DECL_COMDAT (decl)) + if (DECL_COMDAT_GROUP (decl) || DECL_COMDAT (decl)) { DECL_SECTION_NAME (decl) = 0; DECL_COMDAT (decl) = 0; @@ -1101,7 +1101,7 @@ fixup_same_cpp_alias_visibility (symtab_node *node, symtab_node *target) DECL_COMDAT (node->decl) = DECL_COMDAT (target->decl); DECL_COMDAT_GROUP (node->decl) = DECL_COMDAT_GROUP (target->decl); - if (DECL_ONE_ONLY (target->decl) + if (DECL_COMDAT_GROUP (target->decl) && !node->same_comdat_group) symtab_add_to_same_comdat_group (node, target); } @@ -1231,7 +1231,7 @@ symtab_nonoverwritable_alias (symtab_node *node) /* Update the properties. */ DECL_EXTERNAL (new_decl) = 0; - if (DECL_ONE_ONLY (node->decl)) + if (DECL_COMDAT_GROUP (node->decl)) DECL_SECTION_NAME (new_decl) = NULL; DECL_COMDAT_GROUP (new_decl) = 0; TREE_PUBLIC (new_decl) = 0; @@ -1328,8 +1328,7 @@ symtab_get_symbol_partitioning_class (symtab_node *node) return SYMBOL_EXTERNAL; /* Linker discardable symbols are duplicated to every use unless they are - keyed. - Keyed symbols or those. */ + keyed. */ if (DECL_ONE_ONLY (node->decl) && !node->force_output && !node->forced_by_abi diff --git a/gcc/tree.h b/gcc/tree.h index f9c2ca92640..e0a3084b755 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2327,7 +2327,8 @@ extern void decl_value_expr_insert (tree, tree); /* Used in TREE_PUBLIC decls to indicate that copies of this DECL in multiple translation units should be merged. */ -#define DECL_ONE_ONLY(NODE) (DECL_COMDAT_GROUP (NODE) != NULL_TREE) +#define DECL_ONE_ONLY(NODE) (DECL_COMDAT_GROUP (NODE) != NULL_TREE \ + && (TREE_PUBLIC (NODE) || DECL_EXTERNAL (NODE))) /* The name of the object as the assembler will see it (but before any translations made by ASM_OUTPUT_LABELREF). Often this is the same diff --git a/gcc/varasm.c b/gcc/varasm.c index 988665260cc..67810960a6e 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -428,7 +428,7 @@ resolve_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED, if (DECL_SECTION_NAME (decl) == NULL_TREE && targetm_common.have_named_sections && (flag_function_or_data_sections - || DECL_ONE_ONLY (decl))) + || DECL_COMDAT_GROUP (decl))) { targetm.asm_out.unique_section (decl, reloc); DECL_HAS_IMPLICIT_SECTION_NAME_P (decl) = true; @@ -517,7 +517,7 @@ get_named_text_section (tree decl, /* Do not try to split gnu_linkonce functions. This gets somewhat slipperly. */ - if (DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP) + if (DECL_COMDAT_GROUP (decl) && !HAVE_COMDAT_GROUP) return NULL; name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); name = targetm.strip_name_encoding (name); @@ -687,7 +687,7 @@ default_function_rodata_section (tree decl) { const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); - if (DECL_ONE_ONLY (decl) && HAVE_COMDAT_GROUP) + if (DECL_COMDAT_GROUP (decl) && HAVE_COMDAT_GROUP) { const char *dot; size_t len; @@ -704,7 +704,7 @@ default_function_rodata_section (tree decl) return get_section (rname, SECTION_LINKONCE, decl); } /* For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo. */ - else if (DECL_ONE_ONLY (decl) + else if (DECL_COMDAT_GROUP (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0) { size_t len = strlen (name) + 1; @@ -996,7 +996,8 @@ align_variable (tree decl, bool dont_output_data) and for code accessing the variable as guaranteed alignment, we can only increase the alignment if it is a performance optimization if the references to it must bind to the current definition. */ - if (decl_binds_to_current_def_p (decl)) + if (decl_binds_to_current_def_p (decl) + && !DECL_VIRTUAL_P (decl)) { #ifdef DATA_ALIGNMENT unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align); @@ -1142,7 +1143,7 @@ get_block_for_decl (tree decl) /* There's no point using object blocks for something that is isolated by definition. */ - if (DECL_ONE_ONLY (decl)) + if (DECL_COMDAT_GROUP (decl)) return NULL; } @@ -6076,7 +6077,7 @@ default_section_type_flags (tree decl, const char *name, int reloc) flags |= SECTION_RELRO; } - if (decl && DECL_P (decl) && DECL_ONE_ONLY (decl)) + if (decl && DECL_P (decl) && DECL_COMDAT_GROUP (decl)) flags |= SECTION_LINKONCE; if (strcmp (name, ".vtable_map_vars") == 0) -- 2.11.4.GIT