diff mbox

Fix for ipa/63795, ipa/63622

Message ID 54621BB7.7050607@suse.cz
State New
Headers show

Commit Message

Martin Liška Nov. 11, 2014, 2:22 p.m. UTC
Hello.

Following patch adds checking for aliasing support. Patch can bootstrap on x86_64-apple-darwin1 and is part of patches needed for bootstrap restory on the target. I plan to introduce additional patch that will cover testsuite failures for the target.

Ready for trunk?
Thanks,
Martin
gcc/ChangeLog:

2014-11-11  Martin Liska  <mliska@suse.cz>

	* ipa-icf.c (sem_function::merge): Add new target aliasing
	support guide. 
	(sem_variable::merge): Likewise.
	* ipa-icf.h (target_supports_aliasing_p): New function.

gcc/testsuite/ChangeLog:

2014-11-11  Martin Liska  <mliska@suse.cz>

	* g++.dg/ipa/ipa-icf-4.C: Add more precise dump scan.
	* g++.dg/ipa/ipa-icf-5.C: Add condition for targets with aliasing support.

Comments

Richard Biener Nov. 11, 2014, 2:30 p.m. UTC | #1
On Tue, Nov 11, 2014 at 3:22 PM, Martin Liška <mliska@suse.cz> wrote:
> Hello.
>
> Following patch adds checking for aliasing support. Patch can bootstrap on
> x86_64-apple-darwin1 and is part of patches needed for bootstrap restory on
> the target. I plan to introduce additional patch that will cover testsuite
> failures for the target.
>
> Ready for trunk?

"Aliasing" sounds odd here.  I'd expand it to "Symbol aliases", likewise
rename target_supports_aliasing_p to target_supports_symbol_aliases_p.

Ok with that change.

Thanks,
Richard.

> Thanks,
> Martin
Mike Stump Nov. 11, 2014, 6:26 p.m. UTC | #2
On Nov 11, 2014, at 6:22 AM, Martin Liška <mliska@suse.cz> wrote:
> 
> Following patch adds checking for aliasing support. Patch can bootstrap on x86_64-apple-darwin1

I’m impressed, must have been a lot of work to port darwin1 to x86_64.  :-)
Jan Hubicka Nov. 12, 2014, 4:51 a.m. UTC | #3
> On Tue, Nov 11, 2014 at 3:22 PM, Martin Liška <mliska@suse.cz> wrote:
> > Hello.
> >
> > Following patch adds checking for aliasing support. Patch can bootstrap on
> > x86_64-apple-darwin1 and is part of patches needed for bootstrap restory on
> > the target. I plan to introduce additional patch that will cover testsuite
> > failures for the target.
> >
> > Ready for trunk?
> 
> "Aliasing" sounds odd here.  I'd expand it to "Symbol aliases", likewise
> rename target_supports_aliasing_p to target_supports_symbol_aliases_p.

I think it would move those predicates to symtab.  Also please add parameter
whether alias is weak.  Darwin supports aliases but no weak aliases, right?

Honza
> 
> Ok with that change.
> 
> Thanks,
> Richard.
> 
> > Thanks,
> > Martin
diff mbox

Patch

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 84cc0ca..f19c3c1 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -191,6 +191,18 @@  sem_item::dump (void)
     }
 }
 
+/* Return true if target supports aliasing.  */
+
+bool
+sem_item::target_supports_aliasing_p (void)
+{
+#if !defined (ASM_OUTPUT_DEF) || (!defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL))
+  return false;
+#else
+  return true;
+#endif
+}
+
 /* Semantic function constructor that uses STACK as bitmap memory stack.  */
 
 sem_function::sem_function (bitmap_obstack *stack): sem_item (FUNC, stack),
@@ -589,7 +601,8 @@  sem_function::merge (sem_item *alias_item)
       redirect_callers = false;
     }
 
-  if (create_alias && DECL_COMDAT_GROUP (alias->decl))
+  if (create_alias && (DECL_COMDAT_GROUP (alias->decl)
+		       || !sem_item::target_supports_aliasing_p ()))
     {
       create_alias = false;
       create_thunk = true;
@@ -605,6 +618,14 @@  sem_function::merge (sem_item *alias_item)
     local_original
       = dyn_cast <cgraph_node *> (original->noninterposable_alias ());
 
+    if (!local_original)
+      {
+	if (dump_file)
+	  fprintf (dump_file, "Noninterposable alias cannot be created.\n\n");
+
+	return false;
+      }
+
   if (redirect_callers)
     {
       /* If alias is non-overwritable then
@@ -649,7 +670,7 @@  sem_function::merge (sem_item *alias_item)
       alias->resolve_alias (original);
 
       /* Workaround for PR63566 that forces equal calling convention
-	 to be used.  */
+       to be used.  */
       alias->local.local = false;
       original->local.local = false;
 
@@ -1155,6 +1176,13 @@  sem_variable::merge (sem_item *alias_item)
 {
   gcc_assert (alias_item->type == VAR);
 
+  if (!sem_item::target_supports_aliasing_p ())
+    {
+      if (dump_file)
+	fprintf (dump_file, "Aliasing is not supported by target\n\n");
+      return false;
+    }
+
   sem_variable *alias_var = static_cast<sem_variable *> (alias_item);
 
   varpool_node *original = get_node ();
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index d8e7b16..6e15166 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -138,9 +138,11 @@  public:
 
   /* Return base tree that can be used for compatible_types_p and
      contains_polymorphic_type_p comparison.  */
-
   static bool get_base_types (tree *t1, tree *t2);
 
+  /* Return true if target supports aliasing.  */
+  static bool target_supports_aliasing_p (void);
+
   /* Item type.  */
   sem_item_type type;
 
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C
index 9434289..67f2744 100644
--- a/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C
@@ -43,6 +43,6 @@  int main()
   return 123;
 }
 
-/* { dg-final { scan-ipa-dump "Varpool alias has been created" "icf"  } } */
+/* { dg-final { scan-ipa-dump "\(Varpool alias has been created\)|\(Aliasing is not supported by target\)" "icf"  } } */
 /* { dg-final { scan-ipa-dump "Equal symbols: 6" "icf"  } } */
 /* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C
index f835814..57dcb78 100644
--- a/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C
@@ -1,5 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-require-visibility "" } */
+/* { dg-require-alias "" } */
 /* { dg-options "-O2 -fdump-ipa-icf" } */
 
 struct test