From patchwork Fri Apr 8 09:32:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 607938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qhDll6T85z9syq for ; Fri, 8 Apr 2016 19:33:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rLJjNJ68; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=G3XSg5E7/2Hn7VU8B 0TLuJmA+iHijTitv+e1Kd7NKy0kKeAxegvL9k3bvGs9tWw/mdQbf1ax/WvVurlgd XzODSxHP+Bb0UjMpbgzTicpCDN4H612G7VcUIH9t4ABBIkYi28/77MolpYnSmL98 mmVSZL8oifk8PJWmU6njhrGisY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=OASgwYcuMBGYGzMj1KbsZto SPiM=; b=rLJjNJ68aS6BUQCZoxEb4+3FLiNahAm9Oq4QNWOXVHgEVKl/3Y8sln2 iGO7eevw/LE3SQM3Ec3iAeyD4ml1b0WumVHa+u28GYcZInNLBmvQL2Fj8lIW9CFA FZ1bro+ec9e45lMmSsGHNSkAlbaoc1z7BNsSlsJ8RRuAlfGEzSlc= Received: (qmail 124827 invoked by alias); 8 Apr 2016 09:33:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 124617 invoked by uid 89); 8 Apr 2016 09:33:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=2016-03-24, tree_no_warning, TREE_NO_WARNING, PING X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 08 Apr 2016 09:32:50 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1aoSmU-0001Mg-HU from Tom_deVries@mentor.com ; Fri, 08 Apr 2016 02:32:46 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Fri, 8 Apr 2016 10:32:45 +0100 Subject: Re: [PING][PATCH] Remove incorrect warning for parallel firstprivate clause To: Jakub Jelinek References: <56F41DB9.5000100@mentor.com> <570390AC.9000402@mentor.com> <20160405154435.GP19207@tucnak.redhat.com> CC: GCC Patches From: Tom de Vries Message-ID: <57077AB2.6000808@mentor.com> Date: Fri, 8 Apr 2016 11:32:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160405154435.GP19207@tucnak.redhat.com> On 05/04/16 17:44, Jakub Jelinek wrote: > On Tue, Apr 05, 2016 at 12:17:16PM +0200, Tom de Vries wrote: >> On 24/03/16 18:02, Tom de Vries wrote: >>> Remove incorrect warning for parallel firstprivate clause >>> >>> 2016-03-24 Tom de Vries >>> >>> * omp-low.c (lower_omp_target): Set TREE_NO_WARNING for oacc >>> firstprivate clause. >>> >>> * c-c++-common/goacc/uninit-firstprivate-clause.c: New test. >>> * gfortran.dg/goacc/uninit-firstprivate-clause.f95: New test. >>> >>> --- >>> gcc/omp-low.c | 5 ++++- >>> .../goacc/uninit-firstprivate-clause.c | 25 ++++++++++++++++++++++ >>> .../goacc/uninit-firstprivate-clause.f95 | 18 ++++++++++++++++ >>> 3 files changed, 47 insertions(+), 1 deletion(-) >>> >>> diff --git a/gcc/omp-low.c b/gcc/omp-low.c >>> index d107961..41eb3c8 100644 >>> --- a/gcc/omp-low.c >>> +++ b/gcc/omp-low.c >>> @@ -16068,7 +16068,10 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) >>> { >>> gcc_assert (is_gimple_omp_oacc (ctx->stmt)); >>> if (!is_reference (var)) >>> - var = build_fold_addr_expr (var); >>> + { >>> + TREE_NO_WARNING (var) = 1; >>> + var = build_fold_addr_expr (var); >>> + } > > IMHO it should be done only if var is is_gimple_reg (var), otherwise all > that happens on the caller side is that you take the address of the actual > variable. Done. > Also, I think it would be better to do this only > for implicit firstprivate (and map) clauses, if somebody uses explicit > firstprivate on a var, I think it is better to warn if the var is > uninitialized, the user can then use private clause instead. > Done. Patch updated as attached. OK for stage4/stage1 trunk? Thanks, - Tom Remove incorrect warning for parallel implicit firstprivate clause 2016-03-24 Tom de Vries * omp-low.c (lower_omp_target): Set TREE_NO_WARNING for oacc implicit firstprivate clause. * c-c++-common/goacc/uninit-firstprivate-clause.c: New test. * gfortran.dg/goacc/uninit-firstprivate-clause.f95: New test. --- gcc/omp-low.c | 7 +++++- .../goacc/uninit-firstprivate-clause.c | 25 ++++++++++++++++++++++ .../goacc/uninit-firstprivate-clause.f95 | 18 ++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 979926d..7105194 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -16077,7 +16077,12 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) { gcc_assert (is_gimple_omp_oacc (ctx->stmt)); if (!is_reference (var)) - var = build_fold_addr_expr (var); + { + if (is_gimple_reg (var) + && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)) + TREE_NO_WARNING (var) = 1; + var = build_fold_addr_expr (var); + } else talign = TYPE_ALIGN_UNIT (TREE_TYPE (TREE_TYPE (ovar))); gimplify_assign (x, var, &ilist); diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c new file mode 100644 index 0000000..2584033 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/uninit-firstprivate-clause.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wuninitialized" } */ + +void +foo (void) +{ + int i; + +#pragma acc parallel + { + i = 1; + } +} + + +void +foo2 (void) +{ + int i; + +#pragma acc parallel firstprivate (i) /* { dg-warning "is used uninitialized in this function" } */ + { + i = 1; + } +} diff --git a/gcc/testsuite/gfortran.dg/goacc/uninit-firstprivate-clause.f95 b/gcc/testsuite/gfortran.dg/goacc/uninit-firstprivate-clause.f95 new file mode 100644 index 0000000..14d960a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/uninit-firstprivate-clause.f95 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-additional-options "-Wuninitialized" } + +subroutine test + INTEGER :: i + + !$acc parallel + i = 1 + !$acc end parallel +end subroutine test + +subroutine test2 + INTEGER :: i + + !$acc parallel firstprivate (i) ! { dg-warning "is used uninitialized in this function" } + i = 1 + !$acc end parallel +end subroutine test2