summaryrefslogtreecommitdiff
path: root/gcc/ipa-icf.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ipa-icf.c')
-rw-r--r--gcc/ipa-icf.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 889a07de697..ef04c559bf4 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -1,5 +1,5 @@
/* Interprocedural Identical Code Folding pass
- Copyright (C) 2014-2015 Free Software Foundation, Inc.
+ Copyright (C) 2014-2016 Free Software Foundation, Inc.
Contributed by Jan Hubicka <hubicka@ucw.cz> and Martin Liska <mliska@suse.cz>
@@ -1305,6 +1305,7 @@ sem_function::merge (sem_item *alias_item)
/* If all callers was redirected, do not produce wrapper. */
if (alias->can_remove_if_no_direct_calls_p ()
+ && !DECL_VIRTUAL_P (alias->decl)
&& !alias->has_aliases_p ())
{
create_wrapper = false;
@@ -3398,14 +3399,21 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
if (c->members.length () == 1)
continue;
- gcc_assert (c->members.length ());
-
sem_item *source = c->members[0];
- for (unsigned int j = 1; j < c->members.length (); j++)
+ if (DECL_NAME (source->decl)
+ && MAIN_NAME_P (DECL_NAME (source->decl)))
+ /* If merge via wrappers, picking main as the target can be
+ problematic. */
+ source = c->members[1];
+
+ for (unsigned int j = 0; j < c->members.length (); j++)
{
sem_item *alias = c->members[j];
+ if (alias == source)
+ continue;
+
if (dump_file)
{
fprintf (dump_file, "Semantic equality hit:%s->%s\n",