> Again for completeness for building the kernel.
>
> -----
>
> ICF assumes that all nodes in summaries are defined.
> lto_symtab_merge_symbols can set node's definition flag to false.
> remove_unreachable_nodes then releases its body without setting
> body_removed. This results in SegFault in ICF.
>
> It might be better to solve it in those other places, this patch is here
> for completeness to be able to compile 6.15+ linux kernel.
>
> gcc/ChangeLog:
>
> * ipa-icf.cc (sem_item_optimizer::filter_removed_items): Check
> for definition flag.
It seems that the whole m_item array should probably be replaced by
summary. I think only reason it is written this way is since the code
predates summaries.
This seems like a symtom of a bug where m_item is not correctly updated
with the result of symbol merging which may end up with mixing up
sem_item from one body and apply it to another...
Honza
> ---
> gcc/ipa-icf.cc | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
> index d420b173af4..466a08f2dcc 100644
> --- a/gcc/ipa-icf.cc
> +++ b/gcc/ipa-icf.cc
> @@ -2423,7 +2423,8 @@ sem_item_optimizer::filter_removed_items (void)
> {
> cgraph_node *cnode = static_cast <sem_function *>(item)->get_node ();
>
> - if (in_lto_p && (cnode->alias || cnode->body_removed))
> + if (in_lto_p && (cnode->alias || cnode->body_removed
> + || !cnode->definition))
> remove_item (item);
> else
> filtered.safe_push (item);
> --
> 2.51.1
>