aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-05-22 16:48:40 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-05-22 14:48:40 +0000
commit9f90e80a1823bfb50fdbdac0eae44205fc436e56 (patch)
treec6700f8a244d310bf2e05c428d125caeecbd1ffe /gcc/cp
parenta2c9fe42531a2ef2259e4128c50632b2df37202b (diff)
downloadgcc-9f90e80a1823bfb50fdbdac0eae44205fc436e56.zip
gcc-9f90e80a1823bfb50fdbdac0eae44205fc436e56.tar.gz
gcc-9f90e80a1823bfb50fdbdac0eae44205fc436e56.tar.bz2
decl2.c (maybe_emit_vtables): Produce same comdat group when outputting comdat vtables.
* decl2.c (maybe_emit_vtables): Produce same comdat group when outputting comdat vtables. (cxx_callgraph_analyze_expr): Remove code marking vtables needed. * cgraph.h (struct varpool_node): Add same_comdat_group. * lto-cgrpah.c (lto_output_varpool_node): Output same_comdat_group pointer. (output_varpool): Update call of lto_output_varpool_node. (input_varpool): Read same_comdat_group pointer. (input_varpool_1): Fixup same_comdat_group pointer. * ipa.c (cgraph_remove_unreachable_nodes): WHen one of same comdat group is needed, all are. * varpool.c (varpool_remove_node): Remove node from same comdat group linklist too. (varpool_analyze_pending_decls): Walk same comdat groups. From-SVN: r159699
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c29
2 files changed, 22 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5275eca..47f5308 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-22 Jan Hubicka <jh@suse.cz>
+
+ * decl2.c (maybe_emit_vtables): Produce same comdat group when outputting
+ comdat vtables.
+ (cxx_callgraph_analyze_expr): Remove code marking vtables needed.
+
2010-05-21 Joseph Myers <joseph@codesourcery.com>
* cxx-pretty-print.c: Correct merge error.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 25c1175..2fd6305 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1808,6 +1808,7 @@ maybe_emit_vtables (tree ctype)
tree vtbl;
tree primary_vtbl;
int needed = 0;
+ struct varpool_node *current = NULL, *last = NULL, *first = NULL;
/* If the vtables for this class have already been emitted there is
nothing more to do. */
@@ -1865,8 +1866,20 @@ maybe_emit_vtables (tree ctype)
actually marking the variable as written. */
if (flag_syntax_only)
TREE_ASM_WRITTEN (vtbl) = 1;
+ else if (DECL_COMDAT (vtbl))
+ {
+ current = varpool_node (vtbl);
+ if (last)
+ last->same_comdat_group = current;
+ last = current;
+ if (!first)
+ first = current;
+ }
}
+ if (first != last)
+ last->same_comdat_group = first;
+
/* Since we're writing out the vtable here, also write the debug
info. */
note_debug_info_needed (ctype);
@@ -3358,19 +3371,9 @@ cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED)
cgraph_mark_address_taken_node (cgraph_node (BASELINK_FUNCTIONS (t)));
break;
case VAR_DECL:
- if (DECL_VTABLE_OR_VTT_P (t))
- {
- /* The ABI requires that all virtual tables be emitted
- whenever one of them is. */
- tree vtbl;
- for (vtbl = CLASSTYPE_VTABLES (DECL_CONTEXT (t));
- vtbl;
- vtbl = TREE_CHAIN (vtbl))
- mark_decl_referenced (vtbl);
- }
- else if (DECL_CONTEXT (t)
- && flag_use_repository
- && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
+ if (DECL_CONTEXT (t)
+ && flag_use_repository
+ && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
/* If we need a static variable in a function, then we
need the containing function. */
mark_decl_referenced (DECL_CONTEXT (t));