* [PATCH] ipa/92606 - properly handle no_icf attribute for variables
@ 2023-12-11 9:17 Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-12-11 9:17 UTC (permalink / raw)
To: gcc-patches; +Cc: Jan Hubicka, Jakub Jelinek
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.
Bootstrap / regtest running on x86_64-unknown-linux-gnu.
This would solve the AVR issue with merging of "progmem" attributed
and non-"progmem" attributed variables if they'd also add no_icf there.
OK?
Thanks,
Richard.
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.
---
gcc/c-family/c-attribs.cc | 3 ++-
gcc/doc/extend.texi | 5 +++++
gcc/ipa-icf.cc | 3 ++-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 854e987dc79..a3671fe3a57 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 e8b5e771f7a..f0c789f6cb4 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 81232d5706e..e27536d73a9 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,
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ipa/92606 - properly handle no_icf attribute for variables
@ 2023-12-12 14:19 Jan Hubicka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2023-12-12 14:19 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, Jakub Jelinek
> 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.
>
> Bootstrap / regtest running on x86_64-unknown-linux-gnu.
>
> This would solve the AVR issue with merging of "progmem" attributed
> and non-"progmem" attributed variables if they'd also add no_icf there.
>
> OK?
>
> Thanks,
> Richard.
>
> 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.
OK,
thanks!
Honza
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-12 14:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 9:17 [PATCH] ipa/92606 - properly handle no_icf attribute for variables Richard Biener
2023-12-12 14:19 Jan Hubicka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).