public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Thomas Schwinge <thomas@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Fwd: [RFC, openacc] Ensure oacc_replace_fn_attrib replaces
Date: Thu, 20 Dec 2018 10:07:00 -0000	[thread overview]
Message-ID: <fcca14be-af5d-88ec-3ddc-8617c6cbc62a@suse.de> (raw)
In-Reply-To: <61695897-66cc-f42f-40ee-8281092ff41e@suse.de>

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

[ add gcc-patches ]
-------- Forwarded Message --------
Subject: [RFC, openacc] Ensure oacc_replace_fn_attrib replaces
Date: Thu, 20 Dec 2018 00:40:56 +0100
From: Tom de Vries <tdevries@suse.de>
To: Thomas Schwinge <thomas@codesourcery.com>

Hi,

this looks like a good cleanup.

WDYT?

Thanks,
- Tom


[-- Attachment #2: 0015-openacc-Ensure-oacc_replace_fn_attrib-replaces.patch --]
[-- Type: text/x-patch, Size: 1428 bytes --]

[openacc] Ensure oacc_replace_fn_attrib replaces

Atm, in oacc_replace_fn_attrib we only replace the oacc function attribute if
it's the first.

So, for a parallel region we have:
...
__attribute__((oacc function (, 20, ), omp target entrypoint))
...
which is replaced by:
...
__attribute__((oacc function (1, 20, 32), omp target entrypoint))
...

But for a routine:
...
__attribute__((omp declare target, oacc function (0 1, 0 1, 0 1)))
...
we get instead:
...
__attribute__((oacc function (0 1, 0 1, 0 1), omp declare target,
	       oacc function (0 1, 0 1, 0 1)))
...

Fix this confusing behaviour by ensuring the oacc function attribute is
indeed replaced.

---
 gcc/omp-general.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/omp-general.c b/gcc/omp-general.c
index 99d8226ef21..e37a6e0b96c 100644
--- a/gcc/omp-general.c
+++ b/gcc/omp-general.c
@@ -545,9 +545,13 @@ oacc_replace_fn_attrib (tree fn, tree dims)
   tree ident = get_identifier (OACC_FN_ATTRIB);
   tree attribs = DECL_ATTRIBUTES (fn);
 
-  /* If we happen to be present as the first attrib, drop it.  */
-  if (attribs && TREE_PURPOSE (attribs) == ident)
-    attribs = TREE_CHAIN (attribs);
+  tree *elem = &attribs;
+  while (*elem && TREE_PURPOSE (*elem) != ident)
+    elem = &TREE_CHAIN (attribs);
+
+  if (*elem)
+    *elem = TREE_CHAIN (*elem);
+
   DECL_ATTRIBUTES (fn) = tree_cons (ident, dims, attribs);
 }
 


           reply	other threads:[~2018-12-20 10:07 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <61695897-66cc-f42f-40ee-8281092ff41e@suse.de>]

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=fcca14be-af5d-88ec-3ddc-8617c6cbc62a@suse.de \
    --to=tdevries@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=thomas@codesourcery.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).