diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e4d5bed365..8c9e6e5b55e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2009-11-11 Jan Hubicka + + PR middle-end/41729 + * ipa.c (function_and_variable_visibility): Do not privatize COMDAT + and WEAK variables at -fwhole-program. + + PR middle-end/41735 + * ipa.c (whole_program_function_and_variable_visility): COMDAT + functions/variables are not needed even if they are externally visible. + 2009-11-11 Jan Hubicka (patch by Richard Guenther) diff --git a/gcc/ipa.c b/gcc/ipa.c index b082efe78bd..1e5f22c8bf4 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -319,6 +319,11 @@ function_and_variable_visibility (bool whole_program) if (vnode->needed && (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl)) && (!whole_program + /* We can privatize comdat readonly variables whose address is not taken, + but doing so is not going to bring us optimization oppurtunities until + we start reordering datastructures. */ + || DECL_COMDAT (vnode->decl) + || DECL_WEAK (vnode->decl) || lookup_attribute ("externally_visible", DECL_ATTRIBUTES (vnode->decl)))) vnode->externally_visible = true; @@ -396,10 +401,11 @@ whole_program_function_and_variable_visibility (void) function_and_variable_visibility (flag_whole_program); for (node = cgraph_nodes; node; node = node->next) - if (node->local.externally_visible && node->local.finalized) + if ((node->local.externally_visible && !DECL_COMDAT (node->decl)) + && node->local.finalized) cgraph_mark_needed_node (node); for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) - if (vnode->externally_visible) + if (vnode->externally_visible && !DECL_COMDAT (vnode->decl)) varpool_mark_needed_node (vnode); return 0; }