https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330
--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> --- Thank you for the missing externally visible attribute. I've been testing following patch: diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index b193200..0685019 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1131,8 +1131,12 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) tree decl = node->decl; bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl); - bool can_handle = readonly && (DECL_VIRTUAL_P (decl) - || !TREE_ADDRESSABLE (decl)); + if (!readonly) + return NULL; + + bool can_handle = DECL_VIRTUAL_P (decl) + || flag_merge_constants >= 2 + || (!TREE_ADDRESSABLE (decl) && !node->externally_visible); if (!can_handle) return NULL; As soon as tests finish, I will send it to ML. Martin