From: Andrew Carlotti <andrew.carlotti@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: jason@redhat.com, nathan@acm.org, rguenther@suse.de,
richard.sandiford@arm.com, richard.earnshaw@arm.com
Subject: [PATCH v2 2/5] c-family: Simplify attribute exclusion handling
Date: Fri, 17 Nov 2023 02:53:05 +0000 [thread overview]
Message-ID: <408e5c77-961f-4613-009f-d0dea61a37ca@e124511.cambridge.arm.com> (raw)
In-Reply-To: <88dc78af-82a3-9a9f-4b8e-461c41d296cc@e124511.cambridge.arm.com>
This patch changes the handling of mutual exclusions involving the
target and target_clones attributes to use the generic attribute
exclusion lists. Additionally, the duplicate handling for the
always_inline and noinline attribute exclusion is removed.
The only change in functionality is the choice of warning message
displayed - due to either a change in the wording for mutual exclusion
warnings, or a change in the order in which different checks occur.
Ok for master?
gcc/c-family/ChangeLog:
* c-attribs.cc (attr_always_inline_exclusions): New.
(attr_target_exclusions): Ditto.
(attr_target_clones_exclusions): Ditto.
(c_common_attribute_table): Add new exclusion lists.
(handle_noinline_attribute): Remove custom exclusion handling.
(handle_always_inline_attribute): Ditto.
(handle_target_attribute): Ditto.
(handle_target_clones_attribute): Ditto.
gcc/testsuite/ChangeLog:
* g++.target/i386/mvc2.C:
* g++.target/i386/mvc3.C:
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 461732f60f7c4031cc6692000fbdddb9f726a035..b3b41ef123a0f171f57acb1b7f7fdde716428c00 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -214,6 +214,13 @@ static const struct attribute_spec::exclusions attr_inline_exclusions[] =
ATTR_EXCL (NULL, false, false, false),
};
+static const struct attribute_spec::exclusions attr_always_inline_exclusions[] =
+{
+ ATTR_EXCL ("noinline", true, true, true),
+ ATTR_EXCL ("target_clones", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
static const struct attribute_spec::exclusions attr_noinline_exclusions[] =
{
ATTR_EXCL ("always_inline", true, true, true),
@@ -221,6 +228,19 @@ static const struct attribute_spec::exclusions attr_noinline_exclusions[] =
ATTR_EXCL (NULL, false, false, false),
};
+static const struct attribute_spec::exclusions attr_target_exclusions[] =
+{
+ ATTR_EXCL ("target_clones", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_target_clones_exclusions[] =
+{
+ ATTR_EXCL ("always_inline", true, true, true),
+ ATTR_EXCL ("target", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
extern const struct attribute_spec::exclusions attr_noreturn_exclusions[] =
{
ATTR_EXCL ("alloc_align", true, true, true),
@@ -332,7 +352,7 @@ const struct attribute_spec c_common_attribute_table[] =
handle_leaf_attribute, NULL },
{ "always_inline", 0, 0, true, false, false, false,
handle_always_inline_attribute,
- attr_inline_exclusions },
+ attr_always_inline_exclusions },
{ "gnu_inline", 0, 0, true, false, false, false,
handle_gnu_inline_attribute,
attr_inline_exclusions },
@@ -483,9 +503,11 @@ const struct attribute_spec c_common_attribute_table[] =
{ "error", 1, 1, true, false, false, false,
handle_error_attribute, NULL },
{ "target", 1, -1, true, false, false, false,
- handle_target_attribute, NULL },
+ handle_target_attribute,
+ attr_target_exclusions },
{ "target_clones", 1, -1, true, false, false, false,
- handle_target_clones_attribute, NULL },
+ handle_target_clones_attribute,
+ attr_target_clones_exclusions },
{ "optimize", 1, -1, true, false, false, false,
handle_optimize_attribute, NULL },
/* For internal use only. The leading '*' both prevents its usage in
@@ -1397,16 +1419,7 @@ handle_noinline_attribute (tree *node, tree name,
int ARG_UNUSED (flags), bool *no_add_attrs)
{
if (TREE_CODE (*node) == FUNCTION_DECL)
- {
- if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with attribute %qs", name, "always_inline");
- *no_add_attrs = true;
- }
- else
- DECL_UNINLINABLE (*node) = 1;
- }
+ DECL_UNINLINABLE (*node) = 1;
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -1487,22 +1500,9 @@ handle_always_inline_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) == FUNCTION_DECL)
{
- if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "noinline");
- *no_add_attrs = true;
- }
- else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "target_clones");
- *no_add_attrs = true;
- }
- else
- /* Set the attribute and mark it for disregarding inline
- limits. */
- DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
+ /* Set the attribute and mark it for disregarding inline
+ limits. */
+ DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
}
else
{
@@ -5650,12 +5650,6 @@ handle_target_attribute (tree *node, tree name, tree args, int flags,
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
- else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "target_clones");
- *no_add_attrs = true;
- }
else if (! targetm.target_option.valid_attribute_p (*node, name, args,
flags))
*no_add_attrs = true;
@@ -5696,19 +5690,7 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args),
}
}
- if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "always_inline");
- *no_add_attrs = true;
- }
- else if (lookup_attribute ("target", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "target");
- *no_add_attrs = true;
- }
- else if (get_target_clone_attr_len (args) == -1)
+ if (get_target_clone_attr_len (args) == -1)
{
warning (OPT_Wattributes,
"single %<target_clones%> attribute is ignored");
diff --git a/gcc/testsuite/g++.target/i386/mvc2.C b/gcc/testsuite/g++.target/i386/mvc2.C
index 7c1fb6518d04f404123086660c32853dcd9f65ba..04ee0573d607f6de2e7ea382e891f62884c18ea7 100644
--- a/gcc/testsuite/g++.target/i386/mvc2.C
+++ b/gcc/testsuite/g++.target/i386/mvc2.C
@@ -3,7 +3,7 @@
__attribute__((target_clones("avx","arch=slm","default")))
__attribute__((target("avx")))
-int foo (); /* { dg-warning "'target' attribute ignored due to conflict with 'target_clones' attribute" } */
+int foo (); /* { dg-warning "ignoring attribute 'target' because it conflicts with attribute 'target_clones'" } */
__attribute__((target_clones("avx","arch=slm","default"),always_inline))
-int bar (); /* { dg-warning "'always_inline' attribute ignored due to conflict with 'target_clones' attribute" } */
+int bar (); /* { dg-warning "ignoring attribute 'always_inline' because it conflicts with attribute 'target_clones'" } */
diff --git a/gcc/testsuite/g++.target/i386/mvc3.C b/gcc/testsuite/g++.target/i386/mvc3.C
index 5d634fd7ea68b905a0e93ca1c25f6907bc9d2858..5ad1f88fd2d7da74fafcafcff24b77cb2d12a5a0 100644
--- a/gcc/testsuite/g++.target/i386/mvc3.C
+++ b/gcc/testsuite/g++.target/i386/mvc3.C
@@ -3,7 +3,7 @@
__attribute__((target("avx")))
__attribute__((target_clones("avx","arch=slm","default")))
-int foo (); /* { dg-warning "'target_clones' attribute ignored due to conflict with 'target' attribute" } */
+int foo (); /* { dg-warning "ignoring attribute 'target_clones' because it conflicts with attribute 'target'" } */
__attribute__((always_inline,target_clones("avx","arch=slm","default")))
-int bar (); /* { dg-warning "'target_clones' attribute ignored due to conflict with 'always_inline' attribute" } */
+int bar (); /* { dg-warning "ignoring attribute 'target_clones' because it conflicts with attribute 'always_inline'" } */
next prev parent reply other threads:[~2023-11-17 2:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-17 2:49 [PATCH v2 0/5] target_version and aarch64 function multiversioning Andrew Carlotti
2023-11-17 2:51 ` [PATCH v2[1/5] aarch64: Add cpu feature detection to libgcc Andrew Carlotti
2023-11-20 15:46 ` Richard Sandiford
2023-12-04 10:31 ` Andrew Carlotti
2023-11-17 2:53 ` Andrew Carlotti [this message]
2023-11-19 21:45 ` [PATCH v2 2/5] c-family: Simplify attribute exclusion handling Jeff Law
2023-11-17 2:54 ` [PATCH v2 3/5] ada: Improve " Andrew Carlotti
2023-11-17 10:45 ` Marc Poulhiès
2023-11-17 11:15 ` Andrew Carlotti
2023-11-20 8:26 ` Marc Poulhiès
2023-11-17 2:55 ` [PATCH v2 4/5] Add support for target_version attribute Andrew Carlotti
2023-11-29 17:53 ` Richard Sandiford
2023-12-04 11:14 ` Andrew Carlotti
2023-11-17 2:56 ` [PATCH v2 5/5] aarch64: Add function multiversioning support Andrew Carlotti
2023-11-24 16:22 ` Richard Sandiford
2023-12-04 13:23 ` Andrew Carlotti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=408e5c77-961f-4613-009f-d0dea61a37ca@e124511.cambridge.arm.com \
--to=andrew.carlotti@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=nathan@acm.org \
--cc=rguenther@suse.de \
--cc=richard.earnshaw@arm.com \
--cc=richard.sandiford@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).