summaryrefslogtreecommitdiff
path: root/gcc/varpool.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2016-04-16 18:30:48 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2016-04-16 16:30:48 +0000
commitf13fe18b5b4881a457c2176214349d322b61e187 (patch)
tree4cef7161787b418b3d579ca1e2fc6cd70a647584 /gcc/varpool.c
parent06c3ddc04956997f9a45769cf44cc85f013e0245 (diff)
re PR c++/70018 (Possible issue around IPO and C++ comdats discovered as pure/const)
PR ipa/70018 * cgraph.c (cgraph_node::get_availability): Add REF parameter. (cgraph_node::function_symbol): Likewise. (cgraph_node::function_or_virtual_thunk_symbol): Likewise. * cgraph.h (symtab_node::get_availabbility): Add REF parameter. (symtab_node::ultimate_alias_target): Add REF parameter. (symtab_node::binds_to_current_def_p): Declare. (symtab_node;:ultimate_alias_target_1): Add REF parameter. (cgraph_node::function_symbol): Likewise. (cgraph_node::function_or_virtual_thunk_symbol): Likewise. (cgraph_node::get_availability): Likewise. (cgraph_edge::binds_to_current_def_p): New inline function. (varpool_node::get_availability): Add REF parameter. (varpool_node::ultimate_alias_target): Likewise. * symtab.c (symtab_node::ultimate_alias_target_1): Likewise. (symtab_node::binds_to_current_def_p): Likewise. * varpool.c (varpool_node::get_availability): Likewise. From-SVN: r235063
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r--gcc/varpool.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c
index cbbdda41369..12696a4faaa 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -482,7 +482,7 @@ varpool_node::add (tree decl)
/* Return variable availability. See cgraph.h for description of individual
return values. */
enum availability
-varpool_node::get_availability (void)
+varpool_node::get_availability (symtab_node *ref)
{
if (!definition)
return AVAIL_NOT_AVAILABLE;
@@ -495,9 +495,16 @@ varpool_node::get_availability (void)
{
enum availability avail;
- ultimate_alias_target (&avail);
+ ultimate_alias_target (&avail, ref);
return avail;
}
+ /* If this is a reference from symbol itself and there are no aliases, we
+ may be sure that the symbol was not interposed by soemthing else because
+ the symbol itself would be unreachable otherwise. */
+ if ((this == ref && !has_aliases_p ())
+ || (ref && get_comdat_group ()
+ && get_comdat_group () == ref->get_comdat_group ()))
+ return AVAIL_AVAILABLE;
/* If the variable can be overwritten, return OVERWRITABLE. Takes
care of at least one notable extension - the COMDAT variables
used to share template instantiations in C++. */