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 (item)->get_node (); + if (!TREE_READONLY (decl) || vnode->body_removed) remove_item (item); + else + filtered.safe_push (item); } } }