The following adds no_icf handling for variables where the attribute
was rejected. It also fixes the check for no_icf by checking both
the source and the targets decl.
PR ipa/92606
gcc/c-family/
* c-attribs.cc (handle_noicf_attribute): Also allow the
attribute on global variables.
gcc/
* ipa-icf.cc (sem_item_optimizer::merge_classes): Check
both source and alias for the no_icf attribute.
* doc/extend.texi (no_icf): Document variable attribute.
tree ARG_UNUSED (args),
int ARG_UNUSED (flags), bool *no_add_attrs)
{
- if (TREE_CODE (*node) != FUNCTION_DECL)
+ if (TREE_CODE (*node) != FUNCTION_DECL
+ && (TREE_CODE (*node) != VAR_DECL || !is_global_var (*node)))
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
right location. Specifically, some type of non-volatile, writeable
memory is required.
+@cindex @code{no_icf} variable attribute
+@item no_icf
+This variable attribute prevents a variable from being merged with another
+equivalent variable.
+
@cindex @code{objc_nullability} variable attribute
@item objc_nullability (@var{nullability kind}) @r{(Objective-C and Objective-C++ only)}
This attribute applies to pointer variables only. It allows marking the
alias->node->dump_asm_name ());
}
- if (lookup_attribute ("no_icf", DECL_ATTRIBUTES (alias->decl)))
+ if (lookup_attribute ("no_icf", DECL_ATTRIBUTES (alias->decl))
+ || lookup_attribute ("no_icf", DECL_ATTRIBUTES (source->decl)))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,