From 9f90e80a1823bfb50fdbdac0eae44205fc436e56 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 22 May 2010 16:48:40 +0200 Subject: 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 --- gcc/cp/decl2.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'gcc/cp/decl2.c') 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)); -- cgit v1.1