ipa-icf: skip variables with body_removed

Similarly to cgraph_nodes, it may happen that body_removed is set
during merging of symbols.

	PR ipa/105600

gcc/ChangeLog:

	* ipa-icf.cc (sem_item_optimizer::filter_removed_items):
	Skip variables with body_removed.

(cherry picked from commit 31ce821a79)
This commit is contained in:
Martin Liska 2022-05-18 15:07:53 +02:00
parent 70deb85b99
commit c600ff8dc5
1 changed files with 4 additions and 3 deletions

View File

@ -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);
}
}
}