https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65270
--- Comment #26 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I completely missed the discussion concerning restrict. I opened PR65330 with
that testcase. We can check in the following way:
Index: ipa-icf.c
===================================================================
--- ipa-icf.c (revision 221223)
+++ ipa-icf.c (working copy)
@@ -359,6 +359,13 @@ sem_item::compare_cgraph_references (
return return_false_with_msg
("references to virtual tables can not be merged");
+ if (is_a <varpool_node *> (n1)
+ && POINTER_TYPE_P (TREE_TYPE (n1->decl))
+ && TYPE_RESTRICT (TREE_TYPE (n1->decl))
+ != TYPE_RESTRICT (TREE_TYPE (n2->decl)))
+ return return_false_with_msg
+ ("references have different restirct flags");
+
if (address && n1->equal_address_to (n2) == 1)
return true;
if (!address && n1->semantically_equivalent_p (n2))
but I suppose with strong enough restrict handling, we want to actually walk
the type and match restrict flag in all contained pointers? Shall we track it
in PR65330, too? It is a non-bug until the missed optimization is fixed.