https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65150
--- Comment #18 from Iain Sandoe <iains at gcc dot gnu.org> --- if I understood the conversation in irc correctly, Honza you were suggesting the following modification (to use alias->can_remove_if_no_direct_calls_p() as the criterion for deciding on eligibility for removal)? on x86_64-darwin12, bootstrap succeeds with the following; C test regressions seem much the same as for comment #6 - preliminary tests only. ---- diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index e1af8bf..0c3d668 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -662,6 +662,7 @@ sem_function::merge (sem_item *alias_item) redirect_callers = (!original_discardable && !DECL_COMDAT_GROUP (alias->decl) + && !DECL_VIRTUAL_P (alias->decl) && alias->get_availability () > AVAIL_INTERPOSABLE && original->get_availability () > AVAIL_INTERPOSABLE && !alias->instrumented_version); @@ -724,15 +725,18 @@ sem_function::merge (sem_item *alias_item) /* The alias function is removed if symbol address does not matter. */ - if (!alias_address_matters) - alias->remove (); + if (alias->can_remove_if_no_direct_calls_p()) + { + alias->remove (); - if (dump_file && redirected) - fprintf (dump_file, "Callgraph local calls have been redirected.\n\n"); + if (dump_file && redirected) + fprintf (dump_file, "Callgraph local calls have been redirected.\n\n"); + return true; + } } - /* If the condtion above is not met, we are lucky and can turn the + /* If the condition above is not met, we are lucky and can turn the function into real alias. */ - else if (create_alias) + if (create_alias) { alias->icf_merged = true; if (local_original->lto_file_data @@ -762,7 +766,7 @@ sem_function::merge (sem_item *alias_item) if (dump_file) fprintf (dump_file, "Callgraph thunk cannot be created because of COMDAT\n"); - return 0; + return false; } if (DECL_STATIC_CHAIN (alias->decl)) @@ -770,7 +774,7 @@ sem_function::merge (sem_item *alias_item) if (dump_file) fprintf (dump_file, "Thunk creation is risky for static-chain functions.\n\n"); - return 0; + return false; } alias->icf_merged = true;