From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31102 invoked by alias); 22 May 2017 19:03:32 -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 31084 invoked by uid 89); 22 May 2017 19:03:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 May 2017 19:03:30 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7364081252 for ; Mon, 22 May 2017 19:03:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7364081252 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7364081252 Received: from tucnak.zalov.cz (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CBEF18987 for ; Mon, 22 May 2017 19:03:31 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v4MJ3Sen024925 for ; Mon, 22 May 2017 21:03:29 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v4MJ3R4k024924 for gcc-patches@gcc.gnu.org; Mon, 22 May 2017 21:03:27 +0200 Date: Mon, 22 May 2017 19:06:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix OpenMP VLA implicit determination in task (PR middle-end/80809) Message-ID: <20170522190327.GG8499@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01699.txt.bz2 Hi! If a VLA is shared e.g. on parallel or task construct, we firstprivatize a pointer pointing to it, and add a private VLA variable that will have a DECL_VALUE_EXPR for debug info purposes. But, standardwise, the VLA is still shared on the parallel/task, it is just implementation detail what we are doing with it. So, for the purpose of implicit data sharing determination we want to treat it still as shared and only when emitting or changing the clause we want to emit private with OMP_CLAUSE_PRIVATE_DEBUG. The following patch does that, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for release branches. 2017-05-22 Jakub Jelinek PR middle-end/80809 * gimplify.c (omp_add_variable): For GOVD_DEBUG_PRIVATE use GOVD_SHARED rather than GOVD_PRIVATE with it. (gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Expect GOVD_SHARED rather than GOVD_PRIVATE with GOVD_DEBUG_PRIVATE. * testsuite/libgomp.c/pr80809-1.c: New test. --- gcc/gimplify.c.jj 2017-05-22 10:50:07.000000000 +0200 +++ gcc/gimplify.c 2017-05-22 13:07:00.520162436 +0200 @@ -6693,7 +6693,7 @@ omp_add_variable (struct gimplify_omp_ct of PRIVATE. The sharing would take place via the pointer variable which we remapped above. */ if (flags & GOVD_SHARED) - flags = GOVD_PRIVATE | GOVD_DEBUG_PRIVATE + flags = GOVD_SHARED | GOVD_DEBUG_PRIVATE | (flags & (GOVD_SEEN | GOVD_EXPLICIT)); /* We're going to make use of the TYPE_SIZE_UNIT at least in the @@ -8616,7 +8616,7 @@ gimplify_adjust_omp_clauses_1 (splay_tre return 0; if (flags & GOVD_DEBUG_PRIVATE) { - gcc_assert ((flags & GOVD_DATA_SHARE_CLASS) == GOVD_PRIVATE); + gcc_assert ((flags & GOVD_DATA_SHARE_CLASS) == GOVD_SHARED); private_debug = true; } else if (flags & GOVD_MAP) @@ -8878,7 +8878,7 @@ gimplify_adjust_omp_clauses (gimple_seq { gcc_assert ((n->value & GOVD_DEBUG_PRIVATE) == 0 || ((n->value & GOVD_DATA_SHARE_CLASS) - == GOVD_PRIVATE)); + == GOVD_SHARED)); OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_PRIVATE); OMP_CLAUSE_PRIVATE_DEBUG (c) = 1; } --- libgomp/testsuite/libgomp.c/pr80809-1.c.jj 2017-05-22 12:52:11.445135718 +0200 +++ libgomp/testsuite/libgomp.c/pr80809-1.c 2017-05-22 12:51:10.000000000 +0200 @@ -0,0 +1,29 @@ +/* PR middle-end/80809 */ +/* { dg-do run } */ + +__attribute__((noinline, noclone)) void +foo (int x) +{ + int i, j, v[x], *w[16]; + for (i = 0; i < x; i++) + v[i] = i; +#pragma omp parallel +#pragma omp single + for (i = 0; i < 16; i++) + /* Make sure v is implicitly determined shared in task, because it + is shared on the parallel. */ +#pragma omp task private (j) + w[i] = v; + for (i = 0; i < 16; i++) + if (w[i] != v) + __builtin_abort (); +} + +int +main () +{ + foo (4); + foo (27); + foo (196); + return 0; +} Jakub