From patchwork Thu Sep 14 20:21:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 813941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-462176-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UQrCGwQ4"; dkim-atps=neutral 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 3xtVKw6q9fz9sBZ for ; Fri, 15 Sep 2017 06:21:24 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=WdfrGEiIdRW6i382gZ4evq4SFgx6zGUHaK8Zq58GKQ6 nzN1tRSfWdBthmR7Ad0HozdO5AsdfiBxEOxPNkf6t4p9HUS38OrmIpDqWSbggE9f SR+CBqOS6TXGck8A7xuUCPIPjaj7G+7l8xX4vYtjje1SK5R0pHG6fvxRJ19iZNjs = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=KwNMYQBDOo4PYTjSzXAfv6+XhkQ=; b=UQrCGwQ4ZwVm0yNfO AaQNy976LZvyGkXnC3OahAO7YJj997sPfWENmBmaen+2K9+n2dFUrh542BhoSWWQ Co2V2Jc0wbLqK4WX0BzhCpzpPltNI1a9R+PG4PmKv8sANC0N9FQ53q8tHtES0tBt gyu9+Ohpb99j9rQYQPCikwoNDk= Received: (qmail 37503 invoked by alias); 14 Sep 2017 20:21:17 -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 37493 invoked by uid 89); 14 Sep 2017 20:21:17 -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; Thu, 14 Sep 2017 20:21:15 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCD553683C for ; Thu, 14 Sep 2017 20:21:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCD553683C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub@redhat.com Received: from tucnak.zalov.cz (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 653C45D744 for ; Thu, 14 Sep 2017 20:21:14 +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 v8EKLC1a003616 for ; Thu, 14 Sep 2017 22:21:12 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v8EKLBNC003615 for gcc-patches@gcc.gnu.org; Thu, 14 Sep 2017 22:21:11 +0200 Date: Thu, 14 Sep 2017 22:21:11 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix handling of reference vars in C++ implicit task/taskloop firstprivate (PR c++/81314) Message-ID: <20170914202111.GN1701@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! For firstprivate vars, even when implicit, the privatized entity is what the reference refers to; if its copy ctor or dtor need instantiation, doing this at gimplification time is too late, therefore we should handle it during genericization like we handle non-reference firstprivatized vars. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for backporting. 2017-09-14 Jakub Jelinek PR c++/81314 * cp-gimplify.c (omp_var_to_track): Look through references. (omp_cxx_notice_variable): Likewise. * testsuite/libgomp.c++/pr81314.C: New test. Jakub --- gcc/cp/cp-gimplify.c.jj 2017-09-01 09:26:24.000000000 +0200 +++ gcc/cp/cp-gimplify.c 2017-09-14 15:31:54.526100238 +0200 @@ -895,6 +895,8 @@ omp_var_to_track (tree decl) tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); + else if (TREE_CODE (type) == REFERENCE_TYPE) + type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); if (type == error_mark_node || !CLASS_TYPE_P (type)) @@ -947,6 +949,8 @@ omp_cxx_notice_variable (struct cp_gener tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); + else if (TREE_CODE (type) == REFERENCE_TYPE) + type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); get_copy_ctor (type, tf_none); --- libgomp/testsuite/libgomp.c++/pr81314.C.jj 2017-09-14 15:51:17.883604562 +0200 +++ libgomp/testsuite/libgomp.c++/pr81314.C 2017-09-14 15:50:56.000000000 +0200 @@ -0,0 +1,38 @@ +// PR c++/81314 +// { dg-do link } + +template +struct S { + S () { s = 0; } + S (const S &x) { s = x.s; } + ~S () {} + int s; +}; + +void +foo (S<2> &x) +{ + #pragma omp taskloop + for (int i = 0; i < 100; ++i) + x.s++; +} + +void +bar (S<3> &x) +{ + #pragma omp task + x.s++; +} + +int +main () +{ + S<2> s; + S<3> t; + #pragma omp parallel + #pragma omp master + { + foo (s); + bar (t); + } +}