aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-07-08 23:33:44 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-07-08 23:33:44 -0400
commit2fda8e144a7db5ba6025cfe643da0c6111cc2b0f (patch)
tree91cf7e9a3eeaae34dd4f07d9086f498096305f0d /gcc/cp
parente8f8774a901e9645bfadc23d4e72be552b0e9b72 (diff)
downloadgcc-2fda8e144a7db5ba6025cfe643da0c6111cc2b0f.zip
gcc-2fda8e144a7db5ba6025cfe643da0c6111cc2b0f.tar.gz
gcc-2fda8e144a7db5ba6025cfe643da0c6111cc2b0f.tar.bz2
cgraph.c (cgraph_add_to_same_comdat_group): New.
gcc/ * cgraph.c (cgraph_add_to_same_comdat_group): New. * cgraph.h: Declare it. * ipa.c (function_and_variable_visibility): Make sure thunks have the right visibility. gcc/cp/ * method.c (use_thunk): Use cgraph_add_to_same_comdat_group. * optimize.c (maybe_clone_body): Likewise. * semantics.c (maybe_add_lambda_conv_op): Likewise. From-SVN: r176071
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/method.c13
-rw-r--r--gcc/cp/optimize.c41
-rw-r--r--gcc/cp/semantics.c10
4 files changed, 29 insertions, 39 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 41157a1..3f776b0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-07-08 Jason Merrill <jason@redhat.com>
+ * method.c (use_thunk): Use cgraph_add_to_same_comdat_group.
+ * optimize.c (maybe_clone_body): Likewise.
+ * semantics.c (maybe_add_lambda_conv_op): Likewise.
+
PR c++/45603
* decl.c (expand_static_init): Don't get confused by user
declaration of __cxa_guard_acquire.
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index d41a4dd..3d272a3 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -283,7 +283,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
tree virtual_offset;
HOST_WIDE_INT fixed_offset, virtual_value;
bool this_adjusting = DECL_THIS_THUNK_P (thunk_fndecl);
- struct cgraph_node *funcn;
+ struct cgraph_node *funcn, *thunk_node;
/* We should have called finish_thunk to give it a name. */
gcc_assert (DECL_NAME (thunk_fndecl));
@@ -344,8 +344,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
= DECL_VISIBILITY_SPECIFIED (function);
DECL_COMDAT (thunk_fndecl) = DECL_COMDAT (function);
- if (DECL_ONE_ONLY (function) || DECL_WEAK (function))
- make_decl_one_only (thunk_fndecl, cxx_comdat_group (thunk_fndecl));
+ DECL_WEAK (thunk_fndecl) = DECL_WEAK (function);
if (flag_syntax_only)
{
@@ -386,9 +385,11 @@ use_thunk (tree thunk_fndecl, bool emit_p)
TREE_ASM_WRITTEN (thunk_fndecl) = 1;
funcn = cgraph_get_node (function);
gcc_checking_assert (funcn);
- cgraph_add_thunk (funcn, thunk_fndecl, function,
- this_adjusting, fixed_offset, virtual_value,
- virtual_offset, alias);
+ thunk_node = cgraph_add_thunk (funcn, thunk_fndecl, function,
+ this_adjusting, fixed_offset, virtual_value,
+ virtual_offset, alias);
+ if (DECL_ONE_ONLY (function))
+ cgraph_add_to_same_comdat_group (thunk_node, funcn);
if (!this_adjusting
|| !targetm.asm_out.can_output_mi_thunk (thunk_fndecl, fixed_offset,
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index b9e3551..6a06988 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -309,12 +309,12 @@ maybe_clone_body (tree fn)
&& (!DECL_ONE_ONLY (fns[0])
|| (HAVE_COMDAT_GROUP
&& DECL_WEAK (fns[0])))
- && (flag_syntax_only
- /* Set linkage flags appropriately before
- cgraph_create_function_alias looks at them. */
- || (expand_or_defer_fn_1 (clone)
- && cgraph_same_body_alias (cgraph_get_node (fns[0]),
- clone, fns[0]))))
+ && !flag_syntax_only
+ /* Set linkage flags appropriately before
+ cgraph_create_function_alias looks at them. */
+ && expand_or_defer_fn_1 (clone)
+ && cgraph_same_body_alias (cgraph_get_node (fns[0]),
+ clone, fns[0]))
{
alias = true;
if (DECL_ONE_ONLY (fns[0]))
@@ -324,13 +324,22 @@ maybe_clone_body (tree fn)
*[CD][12]*. */
comdat_group = cdtor_comdat_group (fns[1], fns[0]);
DECL_COMDAT_GROUP (fns[0]) = comdat_group;
+ cgraph_add_to_same_comdat_group (cgraph_get_node (clone),
+ cgraph_get_node (fns[0]));
}
}
/* Build the delete destructor by calling complete destructor
and delete function. */
if (idx == 2)
- build_delete_destructor_body (clone, fns[1]);
+ {
+ build_delete_destructor_body (clone, fns[1]);
+ /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is
+ virtual, it goes into the same comdat group as well. */
+ if (comdat_group)
+ cgraph_add_to_same_comdat_group (cgraph_get_create_node (clone),
+ cgraph_get_node (fns[0]));
+ }
else if (alias)
/* No need to populate body. */ ;
else
@@ -419,24 +428,6 @@ maybe_clone_body (tree fn)
}
pop_from_top_level ();
- if (comdat_group)
- {
- DECL_COMDAT_GROUP (fns[1]) = comdat_group;
- if (fns[2])
- {
- struct cgraph_node *base_dtor_node, *deleting_dtor_node;
- /* If *[CD][12]* dtors go into the *[CD]5* comdat group and dtor is
- virtual, it goes into the same comdat group as well. */
- DECL_COMDAT_GROUP (fns[2]) = comdat_group;
- base_dtor_node = cgraph_get_node (fns[0]);
- deleting_dtor_node = cgraph_get_node (fns[2]);
- gcc_assert (base_dtor_node->same_comdat_group == NULL);
- gcc_assert (deleting_dtor_node->same_comdat_group == NULL);
- base_dtor_node->same_comdat_group = deleting_dtor_node;
- deleting_dtor_node->same_comdat_group = base_dtor_node;
- }
- }
-
/* We don't need to process the original function any further. */
return 1;
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5c53a18..84b0dd8 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8880,14 +8880,8 @@ maybe_add_lambda_conv_op (tree type)
if (DECL_ONE_ONLY (statfn))
{
/* Put the thunk in the same comdat group as the call op. */
- struct cgraph_node *callop_node, *thunk_node;
- DECL_COMDAT_GROUP (statfn) = cxx_comdat_group (callop);
- callop_node = cgraph_get_create_node (callop);
- thunk_node = cgraph_get_create_node (statfn);
- gcc_assert (callop_node->same_comdat_group == NULL);
- gcc_assert (thunk_node->same_comdat_group == NULL);
- callop_node->same_comdat_group = thunk_node;
- thunk_node->same_comdat_group = callop_node;
+ cgraph_add_to_same_comdat_group (cgraph_get_create_node (statfn),
+ cgraph_get_create_node (callop));
}
body = begin_function_body ();
compound_stmt = begin_compound_stmt (0);