From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116019 invoked by alias); 20 Dec 2018 10:07:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 116003 invoked by uid 89); 20 Dec 2018 10:07:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=atm X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Dec 2018 10:07:38 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2BA90AFAE; Thu, 20 Dec 2018 10:07:36 +0000 (UTC) Subject: Fwd: [RFC, openacc] Ensure oacc_replace_fn_attrib replaces References: <61695897-66cc-f42f-40ee-8281092ff41e@suse.de> To: Thomas Schwinge Cc: "gcc-patches@gcc.gnu.org" From: Tom de Vries X-Forwarded-Message-Id: <61695897-66cc-f42f-40ee-8281092ff41e@suse.de> Message-ID: Date: Thu, 20 Dec 2018 10:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <61695897-66cc-f42f-40ee-8281092ff41e@suse.de> Content-Type: multipart/mixed; boundary="------------EFDE9E5524F0308F9CF2C692" X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01446.txt.bz2 This is a multi-part message in MIME format. --------------EFDE9E5524F0308F9CF2C692 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 302 [ 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 To: Thomas Schwinge Hi, this looks like a good cleanup. WDYT? Thanks, - Tom --------------EFDE9E5524F0308F9CF2C692 Content-Type: text/x-patch; name="0015-openacc-Ensure-oacc_replace_fn_attrib-replaces.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0015-openacc-Ensure-oacc_replace_fn_attrib-replaces.patch" Content-length: 1428 [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); } --------------EFDE9E5524F0308F9CF2C692--