https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63892
--- Comment #17 from Iain Sandoe <iains at gcc dot gnu.org> ---
so .. the problem on Darwin seems to be when we have an alias which is a vtable
reference to a method.
Then we have alias->callers == NULL, and it seems we don't have anything in
place to replace the reference to the alias with a reference to the original.
I don't know how to do this - so I hacked the following in to keep such cases.
This allows boostrap to complete (without the
sem_item::target_supports_symbol_aliases_p ()) and all the sibcall cases pass
(the ADT/SmallVectortest.cpp also builds from llvm).
Not sure what the "proper" fix is ?
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index e1af8bf..1539877 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)
+ //&& sem_item::target_supports_symbol_aliases_p ()
&& alias->get_availability () > AVAIL_INTERPOSABLE
&& original->get_availability () > AVAIL_INTERPOSABLE
&& !alias->instrumented_version);
@@ -703,6 +704,14 @@ sem_function::merge (sem_item *alias_item)
/* If alias is non-overwritable then
all direct calls are safe to be redirected to the original. */
bool redirected = false;
+ bool keep = false;
+ /* If we have no callers, then I guess this is addressed by the vtable
+ and we need to move the reference, but I don't know how to do that
+ yet. */
+ if (!alias->callers
+ && alias->address_taken)
+ keep = true;
+
while (alias->callers)
{
cgraph_edge *e = alias->callers;
@@ -722,9 +731,9 @@ sem_function::merge (sem_item *alias_item)
&& local_original->lto_file_data != alias->lto_file_data)
local_original->merged = true;
- /* The alias function is removed if symbol address
- does not matter. */
- if (!alias_address_matters)
+ /* The alias function is removed if the function is neither externally
+ visible or locally addressed. */
+ if (!alias_address_matters && !keep)
alias->remove ();
if (dump_file && redirected)