Commit aa398781 by Nathan Sidwell Committed by Nathan Sidwell

ipa-icf.c (sem_item_optimizer::merge): Don't pick 'main' as the source function.

	gcc/
	* ipa-icf.c (sem_item_optimizer::merge): Don't pick 'main' as the
	source function.

	gcc/testsuite/
	* gcc.dg/ipa/ipa-icf-merge-1.c: New.

From-SVN: r231787
parent 94c40e19
2015-12-17 Nathan Sidwell <nathan@acm.org>
* ipa-icf.c (sem_item_optimizer::merge): Don't pick 'main' as the
source function.
2015-12-17 Sebastian Pop <s.pop@samsung.com> 2015-12-17 Sebastian Pop <s.pop@samsung.com>
* Makefile.in: Replace ISL with isl. * Makefile.in: Replace ISL with isl.
...@@ -3398,14 +3398,20 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count) ...@@ -3398,14 +3398,20 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count)
if (c->members.length () == 1) if (c->members.length () == 1)
continue; continue;
gcc_assert (c->members.length ());
sem_item *source = c->members[0]; sem_item *source = c->members[0];
for (unsigned int j = 1; j < c->members.length (); j++) if (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]; sem_item *alias = c->members[j];
if (alias == source)
continue;
if (dump_file) if (dump_file)
{ {
fprintf (dump_file, "Semantic equality hit:%s->%s\n", fprintf (dump_file, "Semantic equality hit:%s->%s\n",
......
2015-12-17 Nathan Sidwell <nathan@acm.org>
* gcc.dg/ipa/ipa-icf-merge-1.c: New.
2015-12-17 David Malcolm <dmalcolm@redhat.com> 2015-12-17 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/diagnostic-range-bad-return.c: New test case. * gcc.dg/diagnostic-range-bad-return.c: New test case.
......
/* { dg-do compile } */
/* { dg-additional-options "-O2 -fdump-ipa-icf" } */
/* Picking 'main' as a candiate target for equivalent functios is not a
good idea. */
int baz (int);
int foo ()
{
return baz (baz (0));
}
int main ()
{
return baz (baz (0));
}
/* Notice the two functions are the same. */
/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->main" "icf" } } */
/* Make sure we don't tail call main. */
/* { dg-final { scan-ipa-dump-not "= main \\(\\);" "icf" } } */
/* Make sure we tail call foo. */
/* { dg-final { scan-ipa-dump "= foo \\(\\);" "icf" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment