aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/c-family/c-attribs.cc3
-rw-r--r--gcc/doc/extend.texi5
-rw-r--r--gcc/ipa-icf.cc3
3 files changed, 9 insertions, 2 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 854e987..a3671fe 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -1649,7 +1649,8 @@ handle_noicf_attribute (tree *node, tree name,
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;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index e8b5e77..f0c789f 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -8152,6 +8152,11 @@ script to place the sections with the @code{.persistent} prefix in the
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
diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
index 81232d5..e27536d 100644
--- a/gcc/ipa-icf.cc
+++ b/gcc/ipa-icf.cc
@@ -3422,7 +3422,8 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count,
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,