Hi, this patch fixes ICE where we produce RTL because of notice_global_symbol but this RTL is no longer valid after turning symbol into an alias.
Bootstrapped/regtested x86_64-linux, will commit it shortly. Honza PR ipa/65232 * ipa-icf.c (clear_decl_rtl): New function. (sem_function::merge): Clear RTL before forming alias. (sem_variable::merge): Clear RTL before forming alias. Index: ipa-icf.c =================================================================== --- ipa-icf.c (revision 221076) +++ ipa-icf.c (working copy) @@ -632,7 +632,7 @@ set_local (cgraph_node *node, void *data return false; } -/* TREE_ADDRESSABLE of NODE to true if DATA is non-NULL. +/* TREE_ADDRESSABLE of NODE to true. Helper for call_for_symbol_thunks_and_aliases. */ static bool @@ -642,6 +642,16 @@ set_addressable (varpool_node *node, voi return false; } +/* Clear DECL_RTL of NODE. + Helper for call_for_symbol_thunks_and_aliases. */ + +static bool +clear_decl_rtl (symtab_node *node, void *) +{ + SET_DECL_RTL (node->decl, NULL); + return false; +} + /* Redirect all callers of N and its aliases to TO. Remove aliases if possible. Return number of redirections made. */ @@ -893,6 +908,9 @@ sem_function::merge (sem_item *alias_ite ipa_merge_profiles (original, alias); alias->release_body (true); alias->reset (); + /* Notice global symbol possibly produced RTL. */ + ((symtab_node *)alias)->call_for_symbol_and_aliases (clear_decl_rtl, + NULL, true); /* Create the alias. */ cgraph_node::create_alias (alias_func->decl, decl); @@ -1512,6 +1543,8 @@ sem_variable::merge (sem_item *alias_ite alias->analyzed = false; DECL_INITIAL (alias->decl) = NULL; + ((symtab_node *)alias)->call_for_symbol_and_aliases (clear_decl_rtl, + NULL, true); alias->need_bounds_init = false; alias->remove_all_references (); if (TREE_ADDRESSABLE (alias->decl))