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 <mli...@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 <mli...@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.
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