* [patch][lto merge] Remove the comdat_group langhook
@ 2009-04-20 12:37 Rafael Espindola
2009-04-20 13:32 ` Diego Novillo
2009-04-20 15:22 ` Mark Mitchell
0 siblings, 2 replies; 14+ messages in thread
From: Rafael Espindola @ 2009-04-20 12:37 UTC (permalink / raw)
To: Gcc Patch List; +Cc: Diego Novillo, Mark Mitchell
[-- Attachment #1: Type: text/plain, Size: 2345 bytes --]
This patch removes the comdat_group langhook. This is needed for lto,
since we cannot call back into cc1 or cc1plus to find the comdat
group.
A side effect of this is that the position in the code where we
compute the assembly name changes. This causes some warnings to change
too. They don't have the "instantiated from" part and are reported at
the instantiation line, not at the template definition line.
Bootstrapped and tested on linux x86-64.
OK for trunk?
gcc/
2009-04-20 Rafael Avila de Espindola <espindola@google.com>
* cgraphunit.c (cgraph_function_versioning,save_inline_function_body):
Use DECL_COMDAT_GROUP instead of DECL_ONE_ONLY.
* config/i386/i386.c (ix86_file_end): Compute DECL_COMDAT_GROUP.
* dwarf2asm.c(dw2_force_const_mem): Update call to make_decl_one_only.
* langhooks-def.h (lhd_comdat_group, LANG_HOOKS_COMDAT_GROUP): Remove.
(LANG_HOOKS_DECLS): Remove LANG_HOOKS_COMDAT_GROUP.
* langhooks.c (lhd_comdat_group): Remove.
* langhooks.h (lang_hooks_for_decls): Remove comdat_group.
* tree.h (DECL_COMDAT_GROUP): New.
(DECL_ONE_ONLY): Use DECL_COMDAT_GROUP.
(tree_decl_with_vis): Add comdat_group. Remove one_only.
(make_decl_one_only): Change signature.
* varasm.c (get_emutls_init_templ_addr, emutls_decl): Update call to
make_decl_one_only.
(make_decl_one_only): Change signature.
(default_elf_asm_named_section): Use DECL_COMDAT_GROUP.
gcc/cp
2009-04-20 Rafael Avila de Espindola <espindola@google.com>
* cp-objcp-common.h (LANG_HOOKS_COMDAT_GROUP): Remove.
* cp-tree.h (cxx_comdat_group): Change signature.
* decl.c (duplicate_decls): Use DECL_COMDAT_GROUP.
(cxx_comdat_group): Change signature.
* decl2.c (comdat_linkage, maybe_make_one_only): Update call to
make_decl_one_only.
(constrain_visibility, get_guard): Use DECL_COMDAT_GROUP.
* method.c (use_thunk): Update call to make_decl_one_only.
* optimize.c (maybe_clone_body): Use DECL_COMDAT_GROUP.
gcc/testsuite
2009-04-20 Rafael Avila de Espindola <espindola@google.com>
* g++.dg/abi/mangle11.C: Update warning line.
* g++.dg/abi/mangle12.C: Update warning line.
* g++.dg/abi/mangle17.C: Update warning line.
* g++.dg/abi/mangle20-2.C: Update warning line.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
[-- Attachment #2: comdat.patch --]
[-- Type: text/x-diff, Size: 15971 bytes --]
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a99b7df..6783292 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1560,7 +1560,7 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
??? We cannot use COMDAT linkage because there is no
ABI support for this. */
DECL_EXTERNAL (new_version_node->decl) = 0;
- DECL_ONE_ONLY (new_version_node->decl) = 0;
+ DECL_COMDAT_GROUP (new_version_node->decl) = NULL_TREE;
TREE_PUBLIC (new_version_node->decl) = 0;
DECL_COMDAT (new_version_node->decl) = 0;
DECL_WEAK (new_version_node->decl) = 0;
@@ -1599,7 +1599,7 @@ save_inline_function_body (struct cgraph_node *node)
tree_function_versioning (node->decl, first_clone->decl, NULL, true, NULL);
DECL_EXTERNAL (first_clone->decl) = 0;
- DECL_ONE_ONLY (first_clone->decl) = 0;
+ DECL_COMDAT_GROUP (first_clone->decl) = NULL_TREE;
TREE_PUBLIC (first_clone->decl) = 0;
DECL_COMDAT (first_clone->decl) = 0;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 503cc08..f3b7e04 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7473,7 +7473,7 @@ ix86_file_end (void)
error_mark_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
- DECL_ONE_ONLY (decl) = 1;
+ DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl);
(*targetm.asm_out.unique_section) (decl, 0);
switch_to_section (get_named_section (decl, NULL, 0));
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 1ce9d36..6723a85 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -78,8 +78,6 @@ extern bool cp_function_decl_explicit_p (tree decl);
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
#undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS cp_write_global_declarations
-#undef LANG_HOOKS_COMDAT_GROUP
-#define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group
#undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function
#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6637d4f..6a897fe 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4395,7 +4395,7 @@ extern tree cxx_builtin_function (tree decl);
extern tree cxx_builtin_function_ext_scope (tree decl);
extern tree check_elaborated_type_specifier (enum tag_types, tree, bool);
extern void warn_extern_redeclared_static (tree, tree);
-extern const char *cxx_comdat_group (tree);
+extern tree cxx_comdat_group (tree);
extern bool cp_missing_noreturn_ok_p (tree);
extern void initialize_artificial_var (tree, tree);
extern tree check_var_type (tree, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index cd550f2..3a9a1d8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1837,7 +1837,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* Merge the storage class information. */
merge_weak (newdecl, olddecl);
- DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl);
+ if (DECL_ONE_ONLY (olddecl))
+ DECL_COMDAT_GROUP (newdecl) = DECL_COMDAT_GROUP (olddecl);
+
DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
@@ -12751,7 +12753,7 @@ cp_missing_noreturn_ok_p (tree decl)
/* Return the COMDAT group into which DECL should be placed. */
-const char *
+tree
cxx_comdat_group (tree decl)
{
tree name;
@@ -12781,7 +12783,7 @@ cxx_comdat_group (tree decl)
name = DECL_ASSEMBLER_NAME (decl);
}
- return IDENTIFIER_POINTER (name);
+ return name;
}
#include "gt-cp-decl.h"
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 91c707d..c936f40 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1508,7 +1508,7 @@ void
comdat_linkage (tree decl)
{
if (flag_weak)
- make_decl_one_only (decl);
+ make_decl_one_only (decl, cxx_comdat_group (decl));
else if (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)))
/* We can just emit function and compiler-generated variables
@@ -1580,7 +1580,7 @@ maybe_make_one_only (tree decl)
|| (! DECL_EXPLICIT_INSTANTIATION (decl)
&& ! DECL_TEMPLATE_SPECIALIZATION (decl)))
{
- make_decl_one_only (decl);
+ make_decl_one_only (decl, cxx_comdat_group (decl));
if (TREE_CODE (decl) == VAR_DECL)
{
@@ -1839,7 +1839,7 @@ constrain_visibility (tree decl, int visibility)
if (!DECL_EXTERN_C_P (decl))
{
TREE_PUBLIC (decl) = 0;
- DECL_ONE_ONLY (decl) = 0;
+ DECL_COMDAT_GROUP (decl) = NULL_TREE;
DECL_INTERFACE_KNOWN (decl) = 1;
if (DECL_LANG_SPECIFIC (decl))
DECL_NOT_REALLY_EXTERN (decl) = 1;
@@ -2497,7 +2497,7 @@ get_guard (tree decl)
TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
TREE_STATIC (guard) = TREE_STATIC (decl);
DECL_COMMON (guard) = DECL_COMMON (decl);
- DECL_ONE_ONLY (guard) = DECL_ONE_ONLY (decl);
+ DECL_COMDAT_GROUP (guard) = DECL_COMDAT_GROUP (decl);
if (TREE_PUBLIC (decl))
DECL_WEAK (guard) = DECL_WEAK (decl);
DECL_VISIBILITY (guard) = DECL_VISIBILITY (decl);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index e632fe0..9d67b31 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -381,7 +381,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
= DECL_VISIBILITY_SPECIFIED (function);
if (DECL_ONE_ONLY (function))
- make_decl_one_only (thunk_fndecl);
+ make_decl_one_only (thunk_fndecl, cxx_comdat_group (thunk_fndecl));
if (flag_syntax_only)
{
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 8c7b9e8..9d4a8c5 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -141,7 +141,12 @@ maybe_clone_body (tree fn)
DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn);
DECL_COMDAT (clone) = DECL_COMDAT (fn);
DECL_WEAK (clone) = DECL_WEAK (fn);
- DECL_ONE_ONLY (clone) = DECL_ONE_ONLY (fn);
+
+ /* We don't copy the comdat group from fn to clone because the assembler
+ name of fn was corrupted by write_mangled_name by adding *INTERNAL*
+ to it. By doing so, it also corrupted the comdat group. */
+ if (DECL_ONE_ONLY (fn))
+ DECL_COMDAT_GROUP (clone) = cxx_comdat_group (clone);
DECL_SECTION_NAME (clone) = DECL_SECTION_NAME (fn);
DECL_USE_TEMPLATE (clone) = DECL_USE_TEMPLATE (fn);
DECL_EXTERNAL (clone) = DECL_EXTERNAL (fn);
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
index 5ccbcf1..bdedc06 100644
--- a/gcc/dwarf2asm.c
+++ b/gcc/dwarf2asm.c
@@ -838,7 +838,7 @@ dw2_force_const_mem (rtx x, bool is_public)
DECL_IGNORED_P (decl) = 1;
TREE_PUBLIC (decl) = 1;
DECL_INITIAL (decl) = decl;
- make_decl_one_only (decl);
+ make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
}
else
{
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 4b6ce27..34ed4cd 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -58,7 +58,6 @@ extern void lhd_incomplete_type_error (const_tree, const_tree);
extern tree lhd_type_promotes_to (tree);
extern void lhd_register_builtin_type (tree, const char *);
extern bool lhd_decl_ok_for_sibcall (const_tree);
-extern const char *lhd_comdat_group (tree);
extern tree lhd_expr_size (const_tree);
extern size_t lhd_tree_size (enum tree_code);
extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
@@ -189,7 +188,6 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
#define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
#define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall
-#define LANG_HOOKS_COMDAT_GROUP lhd_comdat_group
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE hook_bool_const_tree_false
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING lhd_omp_predetermined_sharing
#define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR hook_bool_tree_bool_false
@@ -209,7 +207,6 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
LANG_HOOKS_WRITE_GLOBALS, \
LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
- LANG_HOOKS_COMDAT_GROUP, \
LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE, \
LANG_HOOKS_OMP_PREDETERMINED_SHARING, \
LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR, \
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 1964137..c1ae866 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -300,14 +300,6 @@ lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
return true;
}
-/* Return the COMDAT group into which DECL should be placed. */
-
-const char *
-lhd_comdat_group (tree decl)
-{
- return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-}
-
/* lang_hooks.decls.final_write_globals: perform final processing on
global variables. */
void
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 6c57ca2..1955557 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -173,15 +173,6 @@ struct lang_hooks_for_decls
/* True if this decl may be called via a sibcall. */
bool (*ok_for_sibcall) (const_tree);
- /* Return the COMDAT group into which this DECL should be placed.
- It is known that the DECL belongs in *some* COMDAT group when
- this hook is called. The return value will be used immediately,
- but not explicitly deallocated, so implementations should not use
- xmalloc to allocate the string returned. (Typically, the return
- value will be the string already stored in an
- IDENTIFIER_NODE.) */
- const char * (*comdat_group) (tree);
-
/* True if OpenMP should privatize what this DECL points to rather
than the DECL itself. */
bool (*omp_privatize_by_reference) (const_tree);
diff --git a/gcc/testsuite/g++.dg/abi/mangle11.C b/gcc/testsuite/g++.dg/abi/mangle11.C
index 6d09b51..a049a95 100644
--- a/gcc/testsuite/g++.dg/abi/mangle11.C
+++ b/gcc/testsuite/g++.dg/abi/mangle11.C
@@ -1,10 +1,10 @@
// { dg-options "-Wabi -fabi-version=1" }
template <typename Q>
-void f (typename Q::X) {} // { dg-warning "mangle" }
+void f (typename Q::X) {}
struct S {
typedef int X;
};
-template void f<S> (int);
+template void f<S> (int); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle12.C b/gcc/testsuite/g++.dg/abi/mangle12.C
index a3bd9ff..7176fcd 100644
--- a/gcc/testsuite/g++.dg/abi/mangle12.C
+++ b/gcc/testsuite/g++.dg/abi/mangle12.C
@@ -1,11 +1,11 @@
// { dg-options "-Wabi -fabi-version=1" }
template <template <typename> class Q>
-void f (typename Q<int>::X) {} // { dg-warning "mangle" }
+void f (typename Q<int>::X) {}
template <typename Q>
struct S {
typedef int X;
};
-template void f<S> (int);
+template void f<S> (int); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle17.C b/gcc/testsuite/g++.dg/abi/mangle17.C
index 134b976..0a5fe9a 100644
--- a/gcc/testsuite/g++.dg/abi/mangle17.C
+++ b/gcc/testsuite/g++.dg/abi/mangle17.C
@@ -4,8 +4,8 @@ enum E { e = 3 };
template <int I> struct S {};
-template <int I> void f (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
-template void f<7>(S<7 + e + int (3.7)>);
+template <int I> void f (S<I + e + int (3.7)>) {}
+template void f<7>(S<7 + e + int (3.7)>); // { dg-warning "mangle" }
-template <int I> void g (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
-template void g<7>(S<7 + e + int (3.7)>);
+template <int I> void g (S<I + e + int (3.7)>) {}
+template void g<7>(S<7 + e + int (3.7)>); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle20-2.C b/gcc/testsuite/g++.dg/abi/mangle20-2.C
index 38ac523..bf3d189 100644
--- a/gcc/testsuite/g++.dg/abi/mangle20-2.C
+++ b/gcc/testsuite/g++.dg/abi/mangle20-2.C
@@ -7,10 +7,10 @@
// PR 9043
// mangled array types in templates
-template <int I> void f(int (*)[2]) {} // { dg-warning "mangled name" }
+template <int I> void f(int (*)[2]) {}
template <int I> void g(int (*)[I+2]) {}
-template void f<1>(int (*)[2]);
+template void f<1>(int (*)[2]); // { dg-warning "mangled name" }
// { dg-final { scan-assembler "\n_?_Z1fILi1EEvPALi2E_i\[: \t\n\]" } }
template void g<1>(int (*)[3]);
// { dg-final { scan-assembler "\n_?_Z1gILi1EEvPAplT_Li2E_i\[: \t\n\]" } }
diff --git a/gcc/tree.h b/gcc/tree.h
index c5c855f..f31f1c8 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2910,6 +2910,8 @@ extern void decl_restrict_base_insert (tree, tree);
something which is DECL_COMDAT. */
#define DECL_COMDAT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_flag)
+#define DECL_COMDAT_GROUP(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_group)
+
/* A replaceable function is one which may be replaced at link-time
with an entirely different definition, provided that the
replacement has the same type. For example, functions declared
@@ -2978,13 +2980,14 @@ extern void decl_restrict_base_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_WITH_VIS_CHECK (NODE)->decl_with_vis.one_only)
+#define DECL_ONE_ONLY(NODE) (DECL_COMDAT_GROUP (NODE) != NULL_TREE)
struct tree_decl_with_vis GTY(())
{
struct tree_decl_with_rtl common;
tree assembler_name;
tree section_name;
+ tree comdat_group;
/* Belong to VAR_DECL exclusively. */
unsigned defer_output:1;
@@ -3004,7 +3007,6 @@ struct tree_decl_with_vis GTY(())
ENUM_BITFIELD(symbol_visibility) visibility : 2;
unsigned visibility_specified : 1;
/* Belong to FUNCTION_DECL exclusively. */
- unsigned one_only : 1;
unsigned init_priority_p:1;
/* Belongs to VAR_DECL exclusively. */
@@ -5014,7 +5016,7 @@ extern unsigned int update_alignment_for_field (record_layout_info, tree,
unsigned int);
/* varasm.c */
extern void make_decl_rtl (tree);
-extern void make_decl_one_only (tree);
+extern void make_decl_one_only (tree, tree);
extern int supports_one_only (void);
extern void resolve_unique_section (tree, int, int);
extern void mark_referenced (tree);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 4e41444..5f24d8a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -324,7 +324,7 @@ get_emutls_init_templ_addr (tree decl)
DECL_WEAK (to) = DECL_WEAK (decl);
if (DECL_ONE_ONLY (decl))
{
- make_decl_one_only (to);
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
TREE_STATIC (to) = TREE_STATIC (decl);
TREE_PUBLIC (to) = TREE_PUBLIC (decl);
DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
@@ -386,7 +386,7 @@ emutls_decl (tree decl)
TREE_READONLY (to) = 0;
SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
if (DECL_ONE_ONLY (decl))
- make_decl_one_only (to);
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
DECL_CONTEXT (to) = DECL_CONTEXT (decl);
if (targetm.emutls.var_align_fixed)
/* If we're not allowed to change the proxy object's
@@ -5512,7 +5512,7 @@ supports_one_only (void)
translation units without generating a linker error. */
void
-make_decl_one_only (tree decl)
+make_decl_one_only (tree decl, tree comdat_group)
{
gcc_assert (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL);
@@ -5524,7 +5524,7 @@ make_decl_one_only (tree decl)
#ifdef MAKE_DECL_ONE_ONLY
MAKE_DECL_ONE_ONLY (decl);
#endif
- DECL_ONE_ONLY (decl) = 1;
+ DECL_COMDAT_GROUP (decl) = comdat_group;
}
else if (TREE_CODE (decl) == VAR_DECL
&& (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
@@ -5785,7 +5785,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags,
fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
fprintf (asm_out_file, ",%s,comdat",
- lang_hooks.decls.comdat_group (decl));
+ IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)));
}
putc ('\n', asm_out_file);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-20 12:37 [patch][lto merge] Remove the comdat_group langhook Rafael Espindola
@ 2009-04-20 13:32 ` Diego Novillo
2009-04-20 15:22 ` Mark Mitchell
1 sibling, 0 replies; 14+ messages in thread
From: Diego Novillo @ 2009-04-20 13:32 UTC (permalink / raw)
To: Rafael Espindola; +Cc: Gcc Patch List, Mark Mitchell, Jan Hubicka, ubizjak
On Mon, Apr 20, 2009 at 08:36, Rafael Espindola <espindola@google.com> wrote:
> gcc/
> 2009-04-20 Rafael Avila de Espindola <espindola@google.com>
>
> * cgraphunit.c (cgraph_function_versioning,save_inline_function_body):
> Use DECL_COMDAT_GROUP instead of DECL_ONE_ONLY.
> * config/i386/i386.c (ix86_file_end): Compute DECL_COMDAT_GROUP.
> * dwarf2asm.c(dw2_force_const_mem): Update call to make_decl_one_only.
> * langhooks-def.h (lhd_comdat_group, LANG_HOOKS_COMDAT_GROUP): Remove.
> (LANG_HOOKS_DECLS): Remove LANG_HOOKS_COMDAT_GROUP.
> * langhooks.c (lhd_comdat_group): Remove.
> * langhooks.h (lang_hooks_for_decls): Remove comdat_group.
> * tree.h (DECL_COMDAT_GROUP): New.
> (DECL_ONE_ONLY): Use DECL_COMDAT_GROUP.
> (tree_decl_with_vis): Add comdat_group. Remove one_only.
> (make_decl_one_only): Change signature.
> * varasm.c (get_emutls_init_templ_addr, emutls_decl): Update call to
> make_decl_one_only.
> (make_decl_one_only): Change signature.
> (default_elf_asm_named_section): Use DECL_COMDAT_GROUP.
>
> gcc/cp
> 2009-04-20 Rafael Avila de Espindola <espindola@google.com>
>
> * cp-objcp-common.h (LANG_HOOKS_COMDAT_GROUP): Remove.
> * cp-tree.h (cxx_comdat_group): Change signature.
> * decl.c (duplicate_decls): Use DECL_COMDAT_GROUP.
> (cxx_comdat_group): Change signature.
> * decl2.c (comdat_linkage, maybe_make_one_only): Update call to
> make_decl_one_only.
> (constrain_visibility, get_guard): Use DECL_COMDAT_GROUP.
> * method.c (use_thunk): Update call to make_decl_one_only.
> * optimize.c (maybe_clone_body): Use DECL_COMDAT_GROUP.
>
> gcc/testsuite
> 2009-04-20 Rafael Avila de Espindola <espindola@google.com>
>
> * g++.dg/abi/mangle11.C: Update warning line.
> * g++.dg/abi/mangle12.C: Update warning line.
> * g++.dg/abi/mangle17.C: Update warning line.
> * g++.dg/abi/mangle20-2.C: Update warning line.
OK with me but since this is a feature used only by i386, an x86
maintainer should review this change. Jan, Uros, would you mind
taking a look?
Thanks. Diego.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-20 12:37 [patch][lto merge] Remove the comdat_group langhook Rafael Espindola
2009-04-20 13:32 ` Diego Novillo
@ 2009-04-20 15:22 ` Mark Mitchell
2009-04-24 14:54 ` Rafael Espindola
2009-04-29 15:57 ` Jason Merrill
1 sibling, 2 replies; 14+ messages in thread
From: Mark Mitchell @ 2009-04-20 15:22 UTC (permalink / raw)
To: Rafael Espindola; +Cc: Gcc Patch List, Diego Novillo, Jason Merrill
Rafael Espindola wrote:
> 2009-04-20 Rafael Avila de Espindola <espindola@google.com>
>
> * cgraphunit.c (cgraph_function_versioning,save_inline_function_body):
> Use DECL_COMDAT_GROUP instead of DECL_ONE_ONLY.
I'd like Jason Merrill to review this patch. Jason was responsible for
a lot of the COMDAT/ONE_ONLY/LINKONCE functionality in the compiler, and
is probably best able to know whether this change is safe.
The part that concerns me is turning DECL_ONE_ONLY into a dependency on
DECL_COMDAT_GROUP; we also support one-only via other mechanisms (like
weak symbols) on some targets. Jason will probably be able to tell if
that's a safe change.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-20 15:22 ` Mark Mitchell
@ 2009-04-24 14:54 ` Rafael Espindola
2009-04-29 15:57 ` Jason Merrill
1 sibling, 0 replies; 14+ messages in thread
From: Rafael Espindola @ 2009-04-24 14:54 UTC (permalink / raw)
To: Mark Mitchell; +Cc: Gcc Patch List, Diego Novillo, Jason Merrill
ping?
2009/4/20 Mark Mitchell <mark@codesourcery.com>:
> Rafael Espindola wrote:
>
>> 2009-04-20 Rafael Avila de Espindola <espindola@google.com>
>>
>> * cgraphunit.c (cgraph_function_versioning,save_inline_function_body):
>> Use DECL_COMDAT_GROUP instead of DECL_ONE_ONLY.
>
> I'd like Jason Merrill to review this patch. Jason was responsible for
> a lot of the COMDAT/ONE_ONLY/LINKONCE functionality in the compiler, and
> is probably best able to know whether this change is safe.
>
> The part that concerns me is turning DECL_ONE_ONLY into a dependency on
> DECL_COMDAT_GROUP; we also support one-only via other mechanisms (like
> weak symbols) on some targets. Jason will probably be able to tell if
> that's a safe change.
>
> Thanks,
>
> --
> Mark Mitchell
> CodeSourcery
> mark@codesourcery.com
> (650) 331-3385 x713
>
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-20 15:22 ` Mark Mitchell
2009-04-24 14:54 ` Rafael Espindola
@ 2009-04-29 15:57 ` Jason Merrill
2009-04-29 16:08 ` Jason Merrill
2009-04-30 13:32 ` Rafael Espindola
1 sibling, 2 replies; 14+ messages in thread
From: Jason Merrill @ 2009-04-29 15:57 UTC (permalink / raw)
To: gcc-patches; +Cc: Rafael Espindola, Gcc Patch List, Diego Novillo
Mark Mitchell wrote:
> The part that concerns me is turning DECL_ONE_ONLY into a dependency on
> DECL_COMDAT_GROUP; we also support one-only via other mechanisms (like
> weak symbols) on some targets. Jason will probably be able to tell if
> that's a safe change.
That seems fine to me; for targets that don't support comdat groups the
patch effectively just changes DECL_ONE_ONLY from a single bit to a word.
I do wonder how much of a difference that makes to memory consumption.
Also, if you're removing a bitfield you need to update the "unused bits"
comment at the end of the struct.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-29 15:57 ` Jason Merrill
@ 2009-04-29 16:08 ` Jason Merrill
2009-04-30 13:32 ` Rafael Espindola
1 sibling, 0 replies; 14+ messages in thread
From: Jason Merrill @ 2009-04-29 16:08 UTC (permalink / raw)
To: Mark Mitchell; +Cc: Rafael Espindola, Gcc Patch List, Diego Novillo
Mark Mitchell wrote:
> The part that concerns me is turning DECL_ONE_ONLY into a dependency on
> DECL_COMDAT_GROUP; we also support one-only via other mechanisms (like
> weak symbols) on some targets. Jason will probably be able to tell if
> that's a safe change.
That seems fine to me; for targets that don't support comdat groups the
patch effectively just changes DECL_ONE_ONLY from a single bit to a word.
I do wonder how much of a difference that makes to memory consumption.
Also, if you're removing a bitfield you need to update the "unused bits"
comment at the end of the struct.
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-29 15:57 ` Jason Merrill
2009-04-29 16:08 ` Jason Merrill
@ 2009-04-30 13:32 ` Rafael Espindola
2009-04-30 16:12 ` Rafael Espindola
1 sibling, 1 reply; 14+ messages in thread
From: Rafael Espindola @ 2009-04-30 13:32 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Diego Novillo
[-- Attachment #1: Type: text/plain, Size: 676 bytes --]
> That seems fine to me; for targets that don't support comdat groups the
> patch effectively just changes DECL_ONE_ONLY from a single bit to a word.
>
> I do wonder how much of a difference that makes to memory consumption. Also,
> if you're removing a bitfield you need to update the "unused bits" comment
> at the end of the struct.
Updated patch attached.
It looks like --enable-gather-detailed-mem-stats is broken on trunk.
Checking why. Do you have any suggestion for a good test for memory
use?
> Jason
>
>
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
[-- Attachment #2: comdat.patch --]
[-- Type: text/x-patch, Size: 16103 bytes --]
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a99b7df..6783292 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1560,7 +1560,7 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
??? We cannot use COMDAT linkage because there is no
ABI support for this. */
DECL_EXTERNAL (new_version_node->decl) = 0;
- DECL_ONE_ONLY (new_version_node->decl) = 0;
+ DECL_COMDAT_GROUP (new_version_node->decl) = NULL_TREE;
TREE_PUBLIC (new_version_node->decl) = 0;
DECL_COMDAT (new_version_node->decl) = 0;
DECL_WEAK (new_version_node->decl) = 0;
@@ -1599,7 +1599,7 @@ save_inline_function_body (struct cgraph_node *node)
tree_function_versioning (node->decl, first_clone->decl, NULL, true, NULL);
DECL_EXTERNAL (first_clone->decl) = 0;
- DECL_ONE_ONLY (first_clone->decl) = 0;
+ DECL_COMDAT_GROUP (first_clone->decl) = NULL_TREE;
TREE_PUBLIC (first_clone->decl) = 0;
DECL_COMDAT (first_clone->decl) = 0;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 5e7689b..33bf2f2 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7475,7 +7475,7 @@ ix86_file_end (void)
error_mark_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
- DECL_ONE_ONLY (decl) = 1;
+ DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl);
(*targetm.asm_out.unique_section) (decl, 0);
switch_to_section (get_named_section (decl, NULL, 0));
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 1ce9d36..6723a85 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -78,8 +78,6 @@ extern bool cp_function_decl_explicit_p (tree decl);
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
#undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS cp_write_global_declarations
-#undef LANG_HOOKS_COMDAT_GROUP
-#define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group
#undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function
#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 1f3d0c1..ebb6bb4 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4380,7 +4380,7 @@ extern tree cxx_builtin_function (tree decl);
extern tree cxx_builtin_function_ext_scope (tree decl);
extern tree check_elaborated_type_specifier (enum tag_types, tree, bool);
extern void warn_extern_redeclared_static (tree, tree);
-extern const char *cxx_comdat_group (tree);
+extern tree cxx_comdat_group (tree);
extern bool cp_missing_noreturn_ok_p (tree);
extern void initialize_artificial_var (tree, tree);
extern tree check_var_type (tree, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e06dce2..894187f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1835,7 +1835,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* Merge the storage class information. */
merge_weak (newdecl, olddecl);
- DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl);
+ if (DECL_ONE_ONLY (olddecl))
+ DECL_COMDAT_GROUP (newdecl) = DECL_COMDAT_GROUP (olddecl);
+
DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
@@ -12750,7 +12752,7 @@ cp_missing_noreturn_ok_p (tree decl)
/* Return the COMDAT group into which DECL should be placed. */
-const char *
+tree
cxx_comdat_group (tree decl)
{
tree name;
@@ -12780,7 +12782,7 @@ cxx_comdat_group (tree decl)
name = DECL_ASSEMBLER_NAME (decl);
}
- return IDENTIFIER_POINTER (name);
+ return name;
}
#include "gt-cp-decl.h"
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 8196b54..9264d3a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1508,7 +1508,7 @@ void
comdat_linkage (tree decl)
{
if (flag_weak)
- make_decl_one_only (decl);
+ make_decl_one_only (decl, cxx_comdat_group (decl));
else if (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)))
/* We can just emit function and compiler-generated variables
@@ -1580,7 +1580,7 @@ maybe_make_one_only (tree decl)
|| (! DECL_EXPLICIT_INSTANTIATION (decl)
&& ! DECL_TEMPLATE_SPECIALIZATION (decl)))
{
- make_decl_one_only (decl);
+ make_decl_one_only (decl, cxx_comdat_group (decl));
if (TREE_CODE (decl) == VAR_DECL)
{
@@ -1839,7 +1839,7 @@ constrain_visibility (tree decl, int visibility)
if (!DECL_EXTERN_C_P (decl))
{
TREE_PUBLIC (decl) = 0;
- DECL_ONE_ONLY (decl) = 0;
+ DECL_COMDAT_GROUP (decl) = NULL_TREE;
DECL_INTERFACE_KNOWN (decl) = 1;
if (DECL_LANG_SPECIFIC (decl))
DECL_NOT_REALLY_EXTERN (decl) = 1;
@@ -2497,7 +2497,7 @@ get_guard (tree decl)
TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
TREE_STATIC (guard) = TREE_STATIC (decl);
DECL_COMMON (guard) = DECL_COMMON (decl);
- DECL_ONE_ONLY (guard) = DECL_ONE_ONLY (decl);
+ DECL_COMDAT_GROUP (guard) = DECL_COMDAT_GROUP (decl);
if (TREE_PUBLIC (decl))
DECL_WEAK (guard) = DECL_WEAK (decl);
DECL_VISIBILITY (guard) = DECL_VISIBILITY (decl);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index e632fe0..9d67b31 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -381,7 +381,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
= DECL_VISIBILITY_SPECIFIED (function);
if (DECL_ONE_ONLY (function))
- make_decl_one_only (thunk_fndecl);
+ make_decl_one_only (thunk_fndecl, cxx_comdat_group (thunk_fndecl));
if (flag_syntax_only)
{
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 8c7b9e8..9d4a8c5 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -141,7 +141,12 @@ maybe_clone_body (tree fn)
DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn);
DECL_COMDAT (clone) = DECL_COMDAT (fn);
DECL_WEAK (clone) = DECL_WEAK (fn);
- DECL_ONE_ONLY (clone) = DECL_ONE_ONLY (fn);
+
+ /* We don't copy the comdat group from fn to clone because the assembler
+ name of fn was corrupted by write_mangled_name by adding *INTERNAL*
+ to it. By doing so, it also corrupted the comdat group. */
+ if (DECL_ONE_ONLY (fn))
+ DECL_COMDAT_GROUP (clone) = cxx_comdat_group (clone);
DECL_SECTION_NAME (clone) = DECL_SECTION_NAME (fn);
DECL_USE_TEMPLATE (clone) = DECL_USE_TEMPLATE (fn);
DECL_EXTERNAL (clone) = DECL_EXTERNAL (fn);
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
index 5ccbcf1..bdedc06 100644
--- a/gcc/dwarf2asm.c
+++ b/gcc/dwarf2asm.c
@@ -838,7 +838,7 @@ dw2_force_const_mem (rtx x, bool is_public)
DECL_IGNORED_P (decl) = 1;
TREE_PUBLIC (decl) = 1;
DECL_INITIAL (decl) = decl;
- make_decl_one_only (decl);
+ make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
}
else
{
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 4b6ce27..34ed4cd 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -58,7 +58,6 @@ extern void lhd_incomplete_type_error (const_tree, const_tree);
extern tree lhd_type_promotes_to (tree);
extern void lhd_register_builtin_type (tree, const char *);
extern bool lhd_decl_ok_for_sibcall (const_tree);
-extern const char *lhd_comdat_group (tree);
extern tree lhd_expr_size (const_tree);
extern size_t lhd_tree_size (enum tree_code);
extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
@@ -189,7 +188,6 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
#define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
#define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall
-#define LANG_HOOKS_COMDAT_GROUP lhd_comdat_group
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE hook_bool_const_tree_false
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING lhd_omp_predetermined_sharing
#define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR hook_bool_tree_bool_false
@@ -209,7 +207,6 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
LANG_HOOKS_WRITE_GLOBALS, \
LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
- LANG_HOOKS_COMDAT_GROUP, \
LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE, \
LANG_HOOKS_OMP_PREDETERMINED_SHARING, \
LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR, \
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index fa9b8dd..59a73d2 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -300,14 +300,6 @@ lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
return true;
}
-/* Return the COMDAT group into which DECL should be placed. */
-
-const char *
-lhd_comdat_group (tree decl)
-{
- return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-}
-
/* lang_hooks.decls.final_write_globals: perform final processing on
global variables. */
void
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 6c57ca2..1955557 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -173,15 +173,6 @@ struct lang_hooks_for_decls
/* True if this decl may be called via a sibcall. */
bool (*ok_for_sibcall) (const_tree);
- /* Return the COMDAT group into which this DECL should be placed.
- It is known that the DECL belongs in *some* COMDAT group when
- this hook is called. The return value will be used immediately,
- but not explicitly deallocated, so implementations should not use
- xmalloc to allocate the string returned. (Typically, the return
- value will be the string already stored in an
- IDENTIFIER_NODE.) */
- const char * (*comdat_group) (tree);
-
/* True if OpenMP should privatize what this DECL points to rather
than the DECL itself. */
bool (*omp_privatize_by_reference) (const_tree);
diff --git a/gcc/testsuite/g++.dg/abi/mangle11.C b/gcc/testsuite/g++.dg/abi/mangle11.C
index 6d09b51..a049a95 100644
--- a/gcc/testsuite/g++.dg/abi/mangle11.C
+++ b/gcc/testsuite/g++.dg/abi/mangle11.C
@@ -1,10 +1,10 @@
// { dg-options "-Wabi -fabi-version=1" }
template <typename Q>
-void f (typename Q::X) {} // { dg-warning "mangle" }
+void f (typename Q::X) {}
struct S {
typedef int X;
};
-template void f<S> (int);
+template void f<S> (int); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle12.C b/gcc/testsuite/g++.dg/abi/mangle12.C
index a3bd9ff..7176fcd 100644
--- a/gcc/testsuite/g++.dg/abi/mangle12.C
+++ b/gcc/testsuite/g++.dg/abi/mangle12.C
@@ -1,11 +1,11 @@
// { dg-options "-Wabi -fabi-version=1" }
template <template <typename> class Q>
-void f (typename Q<int>::X) {} // { dg-warning "mangle" }
+void f (typename Q<int>::X) {}
template <typename Q>
struct S {
typedef int X;
};
-template void f<S> (int);
+template void f<S> (int); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle17.C b/gcc/testsuite/g++.dg/abi/mangle17.C
index 134b976..0a5fe9a 100644
--- a/gcc/testsuite/g++.dg/abi/mangle17.C
+++ b/gcc/testsuite/g++.dg/abi/mangle17.C
@@ -4,8 +4,8 @@ enum E { e = 3 };
template <int I> struct S {};
-template <int I> void f (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
-template void f<7>(S<7 + e + int (3.7)>);
+template <int I> void f (S<I + e + int (3.7)>) {}
+template void f<7>(S<7 + e + int (3.7)>); // { dg-warning "mangle" }
-template <int I> void g (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
-template void g<7>(S<7 + e + int (3.7)>);
+template <int I> void g (S<I + e + int (3.7)>) {}
+template void g<7>(S<7 + e + int (3.7)>); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle20-2.C b/gcc/testsuite/g++.dg/abi/mangle20-2.C
index 38ac523..bf3d189 100644
--- a/gcc/testsuite/g++.dg/abi/mangle20-2.C
+++ b/gcc/testsuite/g++.dg/abi/mangle20-2.C
@@ -7,10 +7,10 @@
// PR 9043
// mangled array types in templates
-template <int I> void f(int (*)[2]) {} // { dg-warning "mangled name" }
+template <int I> void f(int (*)[2]) {}
template <int I> void g(int (*)[I+2]) {}
-template void f<1>(int (*)[2]);
+template void f<1>(int (*)[2]); // { dg-warning "mangled name" }
// { dg-final { scan-assembler "\n_?_Z1fILi1EEvPALi2E_i\[: \t\n\]" } }
template void g<1>(int (*)[3]);
// { dg-final { scan-assembler "\n_?_Z1gILi1EEvPAplT_Li2E_i\[: \t\n\]" } }
diff --git a/gcc/tree.h b/gcc/tree.h
index 1e58d52..b4314f0 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2873,6 +2873,8 @@ extern void decl_restrict_base_insert (tree, tree);
something which is DECL_COMDAT. */
#define DECL_COMDAT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_flag)
+#define DECL_COMDAT_GROUP(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_group)
+
/* A replaceable function is one which may be replaced at link-time
with an entirely different definition, provided that the
replacement has the same type. For example, functions declared
@@ -2941,12 +2943,13 @@ extern void decl_restrict_base_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_WITH_VIS_CHECK (NODE)->decl_with_vis.one_only)
+#define DECL_ONE_ONLY(NODE) (DECL_COMDAT_GROUP (NODE) != NULL_TREE)
struct GTY(()) tree_decl_with_vis {
struct tree_decl_with_rtl common;
tree assembler_name;
tree section_name;
+ tree comdat_group;
/* Belong to VAR_DECL exclusively. */
unsigned defer_output:1;
@@ -2966,12 +2969,11 @@ struct GTY(()) tree_decl_with_vis {
ENUM_BITFIELD(symbol_visibility) visibility : 2;
unsigned visibility_specified : 1;
/* Belong to FUNCTION_DECL exclusively. */
- unsigned one_only : 1;
unsigned init_priority_p:1;
/* Belongs to VAR_DECL exclusively. */
ENUM_BITFIELD(tls_model) tls_model : 3;
- /* 13 unused bits. */
+ /* 14 unused bits. */
};
/* In a VAR_DECL that's static,
@@ -4984,7 +4986,7 @@ extern unsigned int update_alignment_for_field (record_layout_info, tree,
unsigned int);
/* varasm.c */
extern void make_decl_rtl (tree);
-extern void make_decl_one_only (tree);
+extern void make_decl_one_only (tree, tree);
extern int supports_one_only (void);
extern void resolve_unique_section (tree, int, int);
extern void mark_referenced (tree);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 9dcae52..607a101 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -324,7 +324,7 @@ get_emutls_init_templ_addr (tree decl)
DECL_WEAK (to) = DECL_WEAK (decl);
if (DECL_ONE_ONLY (decl))
{
- make_decl_one_only (to);
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
TREE_STATIC (to) = TREE_STATIC (decl);
TREE_PUBLIC (to) = TREE_PUBLIC (decl);
DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
@@ -386,7 +386,7 @@ emutls_decl (tree decl)
TREE_READONLY (to) = 0;
SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
if (DECL_ONE_ONLY (decl))
- make_decl_one_only (to);
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
DECL_CONTEXT (to) = DECL_CONTEXT (decl);
if (targetm.emutls.var_align_fixed)
/* If we're not allowed to change the proxy object's
@@ -5507,7 +5507,7 @@ supports_one_only (void)
translation units without generating a linker error. */
void
-make_decl_one_only (tree decl)
+make_decl_one_only (tree decl, tree comdat_group)
{
gcc_assert (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL);
@@ -5519,7 +5519,7 @@ make_decl_one_only (tree decl)
#ifdef MAKE_DECL_ONE_ONLY
MAKE_DECL_ONE_ONLY (decl);
#endif
- DECL_ONE_ONLY (decl) = 1;
+ DECL_COMDAT_GROUP (decl) = comdat_group;
}
else if (TREE_CODE (decl) == VAR_DECL
&& (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
@@ -5780,7 +5780,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags,
fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
fprintf (asm_out_file, ",%s,comdat",
- lang_hooks.decls.comdat_group (decl));
+ IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)));
}
putc ('\n', asm_out_file);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-30 13:32 ` Rafael Espindola
@ 2009-04-30 16:12 ` Rafael Espindola
2009-05-05 12:44 ` Rafael Espindola
0 siblings, 1 reply; 14+ messages in thread
From: Rafael Espindola @ 2009-04-30 16:12 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Diego Novillo
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
> It looks like --enable-gather-detailed-mem-stats is broken on trunk.
> Checking why. Do you have any suggestion for a good test for memory
> use?
Fixed the --enable-gather-detailed-mem-stats build problem. I did a
test with insn-attrtab.i on linux x86-64. The results are attached.
If I read it correctly, with the patch we now allocate 0.3% more memory.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
[-- Attachment #2: patch-mem-report.bz2 --]
[-- Type: application/x-bzip2, Size: 20127 bytes --]
[-- Attachment #3: trunk-mem-report.bz2 --]
[-- Type: application/x-bzip2, Size: 20198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-04-30 16:12 ` Rafael Espindola
@ 2009-05-05 12:44 ` Rafael Espindola
2009-06-10 15:45 ` Rafael Espindola
0 siblings, 1 reply; 14+ messages in thread
From: Rafael Espindola @ 2009-05-05 12:44 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Diego Novillo
> If I read it correctly, with the patch we now allocate 0.3% more memory.
So, is that acceptable?
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-05-05 12:44 ` Rafael Espindola
@ 2009-06-10 15:45 ` Rafael Espindola
2009-06-15 14:12 ` Diego Novillo
0 siblings, 1 reply; 14+ messages in thread
From: Rafael Espindola @ 2009-06-10 15:45 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, Diego Novillo
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
> So, is that acceptable?
Ping.
Updated patch attached.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
[-- Attachment #2: comdat.patch --]
[-- Type: application/octet-stream, Size: 16626 bytes --]
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index fe1126b..556a4d9 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1709,7 +1709,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
??? We cannot use COMDAT linkage because there is no
ABI support for this. */
DECL_EXTERNAL (new_node->decl) = 0;
- DECL_ONE_ONLY (new_node->decl) = 0;
+ DECL_COMDAT_GROUP (new_node->decl) = 0;
TREE_PUBLIC (new_node->decl) = 0;
DECL_COMDAT (new_node->decl) = 0;
DECL_WEAK (new_node->decl) = 0;
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 70b2682..b1e7401 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1615,7 +1615,7 @@ cgraph_function_versioning (struct cgraph_node *old_version_node,
??? We cannot use COMDAT linkage because there is no
ABI support for this. */
DECL_EXTERNAL (new_version_node->decl) = 0;
- DECL_ONE_ONLY (new_version_node->decl) = 0;
+ DECL_COMDAT_GROUP (new_version_node->decl) = NULL_TREE;
TREE_PUBLIC (new_version_node->decl) = 0;
DECL_COMDAT (new_version_node->decl) = 0;
DECL_WEAK (new_version_node->decl) = 0;
@@ -1685,7 +1685,7 @@ save_inline_function_body (struct cgraph_node *node)
tree_function_versioning (node->decl, first_clone->decl, NULL, true, NULL);
DECL_EXTERNAL (first_clone->decl) = 0;
- DECL_ONE_ONLY (first_clone->decl) = 0;
+ DECL_COMDAT_GROUP (first_clone->decl) = NULL_TREE;
TREE_PUBLIC (first_clone->decl) = 0;
DECL_COMDAT (first_clone->decl) = 0;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 80f3ea3..caef14d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7500,7 +7500,7 @@ ix86_file_end (void)
error_mark_node);
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
- DECL_ONE_ONLY (decl) = 1;
+ DECL_COMDAT_GROUP (decl) = DECL_ASSEMBLER_NAME (decl);
(*targetm.asm_out.unique_section) (decl, 0);
switch_to_section (get_named_section (decl, NULL, 0));
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 1ce9d36..6723a85 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -78,8 +78,6 @@ extern bool cp_function_decl_explicit_p (tree decl);
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
#undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS cp_write_global_declarations
-#undef LANG_HOOKS_COMDAT_GROUP
-#define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group
#undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function
#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e31726c..902f200 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4372,7 +4372,7 @@ extern tree cxx_builtin_function (tree decl);
extern tree cxx_builtin_function_ext_scope (tree decl);
extern tree check_elaborated_type_specifier (enum tag_types, tree, bool);
extern void warn_extern_redeclared_static (tree, tree);
-extern const char *cxx_comdat_group (tree);
+extern tree cxx_comdat_group (tree);
extern bool cp_missing_noreturn_ok_p (tree);
extern void initialize_artificial_var (tree, tree);
extern tree check_var_type (tree, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index bf99b3d..99ca17e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1835,7 +1835,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* Merge the storage class information. */
merge_weak (newdecl, olddecl);
- DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl);
+ if (DECL_ONE_ONLY (olddecl))
+ DECL_COMDAT_GROUP (newdecl) = DECL_COMDAT_GROUP (olddecl);
+
DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
@@ -12787,7 +12789,7 @@ cp_missing_noreturn_ok_p (tree decl)
/* Return the COMDAT group into which DECL should be placed. */
-const char *
+tree
cxx_comdat_group (tree decl)
{
tree name;
@@ -12817,7 +12819,7 @@ cxx_comdat_group (tree decl)
name = DECL_ASSEMBLER_NAME (decl);
}
- return IDENTIFIER_POINTER (name);
+ return name;
}
#include "gt-cp-decl.h"
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index d368ea8..b26589d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1508,7 +1508,7 @@ void
comdat_linkage (tree decl)
{
if (flag_weak)
- make_decl_one_only (decl);
+ make_decl_one_only (decl, cxx_comdat_group (decl));
else if (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)))
/* We can just emit function and compiler-generated variables
@@ -1580,7 +1580,7 @@ maybe_make_one_only (tree decl)
|| (! DECL_EXPLICIT_INSTANTIATION (decl)
&& ! DECL_TEMPLATE_SPECIALIZATION (decl)))
{
- make_decl_one_only (decl);
+ make_decl_one_only (decl, cxx_comdat_group (decl));
if (TREE_CODE (decl) == VAR_DECL)
{
@@ -1843,7 +1843,7 @@ constrain_visibility (tree decl, int visibility)
if (!DECL_EXTERN_C_P (decl))
{
TREE_PUBLIC (decl) = 0;
- DECL_ONE_ONLY (decl) = 0;
+ DECL_COMDAT_GROUP (decl) = NULL_TREE;
DECL_INTERFACE_KNOWN (decl) = 1;
if (DECL_LANG_SPECIFIC (decl))
DECL_NOT_REALLY_EXTERN (decl) = 1;
@@ -2501,7 +2501,7 @@ get_guard (tree decl)
TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
TREE_STATIC (guard) = TREE_STATIC (decl);
DECL_COMMON (guard) = DECL_COMMON (decl);
- DECL_ONE_ONLY (guard) = DECL_ONE_ONLY (decl);
+ DECL_COMDAT_GROUP (guard) = DECL_COMDAT_GROUP (decl);
if (TREE_PUBLIC (decl))
DECL_WEAK (guard) = DECL_WEAK (decl);
DECL_VISIBILITY (guard) = DECL_VISIBILITY (decl);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 410503d..97c9e55 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -381,7 +381,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
= DECL_VISIBILITY_SPECIFIED (function);
if (DECL_ONE_ONLY (function))
- make_decl_one_only (thunk_fndecl);
+ make_decl_one_only (thunk_fndecl, cxx_comdat_group (thunk_fndecl));
if (flag_syntax_only)
{
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 8c7b9e8..9d4a8c5 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -141,7 +141,12 @@ maybe_clone_body (tree fn)
DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn);
DECL_COMDAT (clone) = DECL_COMDAT (fn);
DECL_WEAK (clone) = DECL_WEAK (fn);
- DECL_ONE_ONLY (clone) = DECL_ONE_ONLY (fn);
+
+ /* We don't copy the comdat group from fn to clone because the assembler
+ name of fn was corrupted by write_mangled_name by adding *INTERNAL*
+ to it. By doing so, it also corrupted the comdat group. */
+ if (DECL_ONE_ONLY (fn))
+ DECL_COMDAT_GROUP (clone) = cxx_comdat_group (clone);
DECL_SECTION_NAME (clone) = DECL_SECTION_NAME (fn);
DECL_USE_TEMPLATE (clone) = DECL_USE_TEMPLATE (fn);
DECL_EXTERNAL (clone) = DECL_EXTERNAL (fn);
diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
index 7e3fc82..9f7bf34 100644
--- a/gcc/dwarf2asm.c
+++ b/gcc/dwarf2asm.c
@@ -879,7 +879,7 @@ dw2_output_indirect_constant_1 (splay_tree_node node,
if (TREE_PUBLIC (id))
{
TREE_PUBLIC (decl) = 1;
- make_decl_one_only (decl);
+ make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
}
else
TREE_STATIC (decl) = 1;
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 506b527..2631ff8 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -58,7 +58,6 @@ extern void lhd_incomplete_type_error (const_tree, const_tree);
extern tree lhd_type_promotes_to (tree);
extern void lhd_register_builtin_type (tree, const char *);
extern bool lhd_decl_ok_for_sibcall (const_tree);
-extern const char *lhd_comdat_group (tree);
extern tree lhd_expr_size (const_tree);
extern size_t lhd_tree_size (enum tree_code);
extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
@@ -191,7 +190,6 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
#define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
#define LANG_HOOKS_DECL_OK_FOR_SIBCALL lhd_decl_ok_for_sibcall
-#define LANG_HOOKS_COMDAT_GROUP lhd_comdat_group
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE hook_bool_const_tree_false
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING lhd_omp_predetermined_sharing
#define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR hook_bool_tree_bool_false
@@ -211,7 +209,6 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
LANG_HOOKS_WRITE_GLOBALS, \
LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
- LANG_HOOKS_COMDAT_GROUP, \
LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE, \
LANG_HOOKS_OMP_PREDETERMINED_SHARING, \
LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR, \
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 8579062..4de02a5 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -300,14 +300,6 @@ lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
return true;
}
-/* Return the COMDAT group into which DECL should be placed. */
-
-const char *
-lhd_comdat_group (tree decl)
-{
- return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-}
-
/* lang_hooks.decls.final_write_globals: perform final processing on
global variables. */
void
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 06ad6c1..ed3e7e7 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -176,15 +176,6 @@ struct lang_hooks_for_decls
/* True if this decl may be called via a sibcall. */
bool (*ok_for_sibcall) (const_tree);
- /* Return the COMDAT group into which this DECL should be placed.
- It is known that the DECL belongs in *some* COMDAT group when
- this hook is called. The return value will be used immediately,
- but not explicitly deallocated, so implementations should not use
- xmalloc to allocate the string returned. (Typically, the return
- value will be the string already stored in an
- IDENTIFIER_NODE.) */
- const char * (*comdat_group) (tree);
-
/* True if OpenMP should privatize what this DECL points to rather
than the DECL itself. */
bool (*omp_privatize_by_reference) (const_tree);
diff --git a/gcc/testsuite/g++.dg/abi/mangle11.C b/gcc/testsuite/g++.dg/abi/mangle11.C
index 6d09b51..a049a95 100644
--- a/gcc/testsuite/g++.dg/abi/mangle11.C
+++ b/gcc/testsuite/g++.dg/abi/mangle11.C
@@ -1,10 +1,10 @@
// { dg-options "-Wabi -fabi-version=1" }
template <typename Q>
-void f (typename Q::X) {} // { dg-warning "mangle" }
+void f (typename Q::X) {}
struct S {
typedef int X;
};
-template void f<S> (int);
+template void f<S> (int); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle12.C b/gcc/testsuite/g++.dg/abi/mangle12.C
index a3bd9ff..7176fcd 100644
--- a/gcc/testsuite/g++.dg/abi/mangle12.C
+++ b/gcc/testsuite/g++.dg/abi/mangle12.C
@@ -1,11 +1,11 @@
// { dg-options "-Wabi -fabi-version=1" }
template <template <typename> class Q>
-void f (typename Q<int>::X) {} // { dg-warning "mangle" }
+void f (typename Q<int>::X) {}
template <typename Q>
struct S {
typedef int X;
};
-template void f<S> (int);
+template void f<S> (int); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle17.C b/gcc/testsuite/g++.dg/abi/mangle17.C
index 134b976..0a5fe9a 100644
--- a/gcc/testsuite/g++.dg/abi/mangle17.C
+++ b/gcc/testsuite/g++.dg/abi/mangle17.C
@@ -4,8 +4,8 @@ enum E { e = 3 };
template <int I> struct S {};
-template <int I> void f (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
-template void f<7>(S<7 + e + int (3.7)>);
+template <int I> void f (S<I + e + int (3.7)>) {}
+template void f<7>(S<7 + e + int (3.7)>); // { dg-warning "mangle" }
-template <int I> void g (S<I + e + int (3.7)>) {} // { dg-warning "mangle" }
-template void g<7>(S<7 + e + int (3.7)>);
+template <int I> void g (S<I + e + int (3.7)>) {}
+template void g<7>(S<7 + e + int (3.7)>); // { dg-warning "mangle" }
diff --git a/gcc/testsuite/g++.dg/abi/mangle20-2.C b/gcc/testsuite/g++.dg/abi/mangle20-2.C
index 38ac523..bf3d189 100644
--- a/gcc/testsuite/g++.dg/abi/mangle20-2.C
+++ b/gcc/testsuite/g++.dg/abi/mangle20-2.C
@@ -7,10 +7,10 @@
// PR 9043
// mangled array types in templates
-template <int I> void f(int (*)[2]) {} // { dg-warning "mangled name" }
+template <int I> void f(int (*)[2]) {}
template <int I> void g(int (*)[I+2]) {}
-template void f<1>(int (*)[2]);
+template void f<1>(int (*)[2]); // { dg-warning "mangled name" }
// { dg-final { scan-assembler "\n_?_Z1fILi1EEvPALi2E_i\[: \t\n\]" } }
template void g<1>(int (*)[3]);
// { dg-final { scan-assembler "\n_?_Z1gILi1EEvPAplT_Li2E_i\[: \t\n\]" } }
diff --git a/gcc/tree.h b/gcc/tree.h
index d88d85f..b14b32f 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2867,6 +2867,8 @@ extern void decl_restrict_base_insert (tree, tree);
something which is DECL_COMDAT. */
#define DECL_COMDAT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_flag)
+#define DECL_COMDAT_GROUP(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_group)
+
/* A replaceable function is one which may be replaced at link-time
with an entirely different definition, provided that the
replacement has the same type. For example, functions declared
@@ -2935,12 +2937,13 @@ extern void decl_restrict_base_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_WITH_VIS_CHECK (NODE)->decl_with_vis.one_only)
+#define DECL_ONE_ONLY(NODE) (DECL_COMDAT_GROUP (NODE) != NULL_TREE)
struct GTY(()) tree_decl_with_vis {
struct tree_decl_with_rtl common;
tree assembler_name;
tree section_name;
+ tree comdat_group;
/* Belong to VAR_DECL exclusively. */
unsigned defer_output:1;
@@ -2960,12 +2963,11 @@ struct GTY(()) tree_decl_with_vis {
ENUM_BITFIELD(symbol_visibility) visibility : 2;
unsigned visibility_specified : 1;
/* Belong to FUNCTION_DECL exclusively. */
- unsigned one_only : 1;
unsigned init_priority_p:1;
/* Belongs to VAR_DECL exclusively. */
ENUM_BITFIELD(tls_model) tls_model : 3;
- /* 13 unused bits. */
+ /* 14 unused bits. */
};
/* In a VAR_DECL that's static,
@@ -4992,7 +4994,7 @@ extern unsigned int update_alignment_for_field (record_layout_info, tree,
unsigned int);
/* varasm.c */
extern void make_decl_rtl (tree);
-extern void make_decl_one_only (tree);
+extern void make_decl_one_only (tree, tree);
extern int supports_one_only (void);
extern void resolve_unique_section (tree, int, int);
extern void mark_referenced (tree);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index c5de9ae..29a6153 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -322,7 +322,7 @@ get_emutls_init_templ_addr (tree decl)
DECL_WEAK (to) = DECL_WEAK (decl);
if (DECL_ONE_ONLY (decl))
{
- make_decl_one_only (to);
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
TREE_STATIC (to) = TREE_STATIC (decl);
TREE_PUBLIC (to) = TREE_PUBLIC (decl);
DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
@@ -384,7 +384,7 @@ emutls_decl (tree decl)
TREE_READONLY (to) = 0;
SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
if (DECL_ONE_ONLY (decl))
- make_decl_one_only (to);
+ make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
DECL_CONTEXT (to) = DECL_CONTEXT (decl);
if (targetm.emutls.var_align_fixed)
/* If we're not allowed to change the proxy object's
@@ -5700,7 +5700,7 @@ supports_one_only (void)
translation units without generating a linker error. */
void
-make_decl_one_only (tree decl)
+make_decl_one_only (tree decl, tree comdat_group)
{
gcc_assert (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL);
@@ -5712,7 +5712,7 @@ make_decl_one_only (tree decl)
#ifdef MAKE_DECL_ONE_ONLY
MAKE_DECL_ONE_ONLY (decl);
#endif
- DECL_ONE_ONLY (decl) = 1;
+ DECL_COMDAT_GROUP (decl) = comdat_group;
}
else if (TREE_CODE (decl) == VAR_DECL
&& (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
@@ -5973,7 +5973,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags,
fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
fprintf (asm_out_file, ",%s,comdat",
- lang_hooks.decls.comdat_group (decl));
+ IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl)));
}
putc ('\n', asm_out_file);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-06-10 15:45 ` Rafael Espindola
@ 2009-06-15 14:12 ` Diego Novillo
2009-06-15 15:10 ` Rafael Espindola
0 siblings, 1 reply; 14+ messages in thread
From: Diego Novillo @ 2009-06-15 14:12 UTC (permalink / raw)
To: Rafael Espindola; +Cc: Jason Merrill, gcc-patches
On Wed, Jun 10, 2009 at 11:44, Rafael Espindola<espindola@google.com> wrote:
>> So, is that acceptable?
>
> Ping.
>
> Updated patch attached.
This patch is OK.
Diego.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-06-15 14:12 ` Diego Novillo
@ 2009-06-15 15:10 ` Rafael Espindola
2009-06-16 11:36 ` Dave Korn
0 siblings, 1 reply; 14+ messages in thread
From: Rafael Espindola @ 2009-06-15 15:10 UTC (permalink / raw)
To: Diego Novillo; +Cc: Jason Merrill, gcc-patches
> This patch is OK.
Committed. I also committed a small fix to cgraph_make_node_local that
was introduce after I last tested the patch:
2009-06-15 Rafael Avila de Espindola <espindola@google.com>
* cgraph.c (cgraph_make_node_local): Use DECL_COMDAT_GROUP.
>
> Diego.
>
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-06-15 15:10 ` Rafael Espindola
@ 2009-06-16 11:36 ` Dave Korn
2009-06-16 12:27 ` Rafael Espindola
0 siblings, 1 reply; 14+ messages in thread
From: Dave Korn @ 2009-06-16 11:36 UTC (permalink / raw)
To: Rafael Espindola; +Cc: Diego Novillo, Jason Merrill, gcc-patches
Rafael Espindola wrote:
>> This patch is OK.
>
> Committed.
Rafael, you missed updating a call to make_decl_one_only(), in
config/i386/winnt.c, causing PR40456; could you take a look and tell us what
we need to use for the new second argument here?
cheers,
DaveK
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [patch][lto merge] Remove the comdat_group langhook
2009-06-16 11:36 ` Dave Korn
@ 2009-06-16 12:27 ` Rafael Espindola
0 siblings, 0 replies; 14+ messages in thread
From: Rafael Espindola @ 2009-06-16 12:27 UTC (permalink / raw)
To: Dave Korn; +Cc: Diego Novillo, Jason Merrill, gcc-patches
2009/6/16 Dave Korn <dave.korn.cygwin@googlemail.com>:
> Rafael Espindola wrote:
>>> This patch is OK.
>>
>> Committed.
>
> Rafael, you missed updating a call to make_decl_one_only(), in
> config/i386/winnt.c, causing PR40456; could you take a look and tell us what
> we need to use for the new second argument here?
Sorry about that. I committed a fix.
This patch makes one_only == "not in a comdat section". To make
something one_only now you must specify the comdat section which is
DECL_ASSEMBLER_NAME in most cases.
> cheers,
> DaveK
>
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-06-16 12:18 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-20 12:37 [patch][lto merge] Remove the comdat_group langhook Rafael Espindola
2009-04-20 13:32 ` Diego Novillo
2009-04-20 15:22 ` Mark Mitchell
2009-04-24 14:54 ` Rafael Espindola
2009-04-29 15:57 ` Jason Merrill
2009-04-29 16:08 ` Jason Merrill
2009-04-30 13:32 ` Rafael Espindola
2009-04-30 16:12 ` Rafael Espindola
2009-05-05 12:44 ` Rafael Espindola
2009-06-10 15:45 ` Rafael Espindola
2009-06-15 14:12 ` Diego Novillo
2009-06-15 15:10 ` Rafael Espindola
2009-06-16 11:36 ` Dave Korn
2009-06-16 12:27 ` Rafael Espindola
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).