> Similarly to cgraph_nodes, it may happen that body_removed is set > during merging of symbols. > > PR ipa/105600 > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > gcc/ChangeLog: > > * ipa-icf.cc (sem_item_optimizer::filter_removed_items): > Skip variables with body_removed. > --- > gcc/ipa-icf.cc | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc > index 765ae746745..6528a7a10b2 100644 > --- a/gcc/ipa-icf.cc > +++ b/gcc/ipa-icf.cc > @@ -2411,10 +2411,11 @@ sem_item_optimizer::filter_removed_items (void) > { > /* Filter out non-readonly variables. */ > tree decl = item->decl; > - if (TREE_READONLY (decl)) > - filtered.safe_push (item); > - else > + varpool_node *vnode = static_cast <sem_variable > *>(item)->get_node (); > + if (!TREE_READONLY (decl) || vnode->body_removed) > remove_item (item); > + else > + filtered.safe_push (item);
So the situation here is that we merge symbols but keep syntactic alias because the declarations are not compatible (have different attributes perhaps because of fortify source)? Will ICF still see through the aliases and do merging? I think you can craft a testcase by triggering the attribute mismatch and see what happens. At the time we implemented ICF these aliases did not exists, so maybe some TLC is needed here. Honza