From patchwork Thu Jan 5 11:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 39481 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp242164wrt; Thu, 5 Jan 2023 03:04:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXt6zCDry340hT6Pl81noX1gXJaO64idwDUj42UDL8nn5k8l55HGmlCD4eVpJVo18X3Q+t/i X-Received: by 2002:a17:907:9d0b:b0:78d:f455:30db with SMTP id kt11-20020a1709079d0b00b0078df45530dbmr45104013ejc.3.1672916668988; Thu, 05 Jan 2023 03:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672916668; cv=none; d=google.com; s=arc-20160816; b=I6bpyHe7zbsYp7AGcHRXO27EANAqD+W+9yl+I45MonIi98MRez3+xU+fI6b94baB7J IS1wmEpEZMNxjA+ydGpCDvzFLm7U/8wzDopPjFYh75NWhoTgEcLC40NKiDm2M29sLpPb Sx0Jp0gT5Iz+77rEnYNjtQFFlnmmoJXiq3fxTZztABqX+fONaEikXip+TGguzuvNSteL ofRb42O29wyaKd6Rff+Fw+D2P8CdngS3RMmWSpb1yngW4AlF0CbKczaFg2orDj8S+1R5 D1yxnQEMR4djaodRkJ5JKycJPI9iK8GPzRIvsbFpoV2mXlzzfKHDnQvyL2poyHVSCFII UtfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=QScHgD6OzmHnYOB6hNczL7wQIOGVwo/HdHayQv7Ex9Q=; b=Hm1N1r7XaskZc5LK1dx6EJxCCCOsyDNXi93KZQyXni5ahnVUq9olrRJTYbibhA4MUq qYkXr+rjCjHQi+jxzhtvaes+RkR0wP6ucMbc9T/OQlpR//iUFebdA9d0ySZhn/V7A7iq skuePGTqfDTdZUCLwsD4Y79tAmId6xvMtrppG2k9QuEWnuEyoGavJUbVrUFDRnsC3oRR kDXGpYbp7Rqc94MedCqnGO8/3nxRW57GiAk8WB8pvrtvA+i+ZrmDZ4VsIMZPABRLdhpy 6nkzpa7Jgn2dQEIbH4YN2X4N6poNg2XMtaxu0U5Yh4owuBPtV19RV9ShoB3elX7q+lZB fewg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=D5Orv6bv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ji20-20020a170907981400b007adfe2889efsi33470682ejc.607.2023.01.05.03.04.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 03:04:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=D5Orv6bv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E2EC3858298 for ; Thu, 5 Jan 2023 11:04:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E2EC3858298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672916667; bh=QScHgD6OzmHnYOB6hNczL7wQIOGVwo/HdHayQv7Ex9Q=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=D5Orv6bvWAhXE5qsUKp6x4ztH9Z+niUYWTN+TUqzKauTxVVxmiu3baKrYPPvife3c FpYJ4aulCVMCJVqu4LGqnnVCYK2Id+7K5zhv5OWUGrV5YlrRRxkl11MjEKD21V6851 /MtWS6hzoL6jKS+zX/peebVleX/edoUtBoDpREwM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C90D13858D28 for ; Thu, 5 Jan 2023 11:03:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C90D13858D28 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-z3Ku8uDXO4KKjBYuNraSSg-1; Thu, 05 Jan 2023 06:03:41 -0500 X-MC-Unique: z3Ku8uDXO4KKjBYuNraSSg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F35C180D0E6; Thu, 5 Jan 2023 11:03:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A00C2140EBF6; Thu, 5 Jan 2023 11:03:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 305B3brW464573 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 5 Jan 2023 12:03:38 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 305B3aUe464572; Thu, 5 Jan 2023 12:03:36 +0100 Date: Thu, 5 Jan 2023 12:03:36 +0100 To: gcc-patches@gcc.gnu.org Cc: Chung-Lin Tang , Tobias Burnus Subject: [committed] openmp: Fix up finish_omp_target_clauses [PR108286] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754180269211205330?= X-GMAIL-MSGID: =?utf-8?q?1754180269211205330?= Hi! The comment in the loop says that we shouldn't add a map clause if such a clause exists already, but the loop was actually using OMP_CLAUSE_DECL on any clause. Target construct can have various clauses which don't have OMP_CLAUSE_DECL at all (e.g. nowait, device or if) or clause where it means something different (e.g. privatization clauses, allocate, depend). So, only check OMP_CLAUSE_DECL on OMP_CLAUSE_MAP clauses. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk so far. 2023-01-05 Jakub Jelinek PR c++/108286 * semantics.cc (finish_omp_target_clauses): Ignore clauses other than OMP_CLAUSE_MAP. * testsuite/libgomp.c++/pr108286.C: New test. Jakub --- gcc/cp/semantics.cc.jj 2022-12-05 11:10:37.610673062 +0100 +++ gcc/cp/semantics.cc 2023-01-04 19:10:52.882277867 +0100 @@ -9825,7 +9825,9 @@ finish_omp_target_clauses (location_t lo for (tree c = *clauses_ptr; c; c = OMP_CLAUSE_CHAIN (c)) { - /* If map(this->ptr[:N] already exists, avoid creating another + if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP) + continue; + /* If map(this->ptr[:N]) already exists, avoid creating another such map. */ tree decl = OMP_CLAUSE_DECL (c); if ((TREE_CODE (decl) == INDIRECT_REF --- libgomp/testsuite/libgomp.c++/pr108286.C.jj 2023-01-04 19:21:07.401384587 +0100 +++ libgomp/testsuite/libgomp.c++/pr108286.C 2023-01-04 19:20:05.793276171 +0100 @@ -0,0 +1,29 @@ +// PR c++/108286 +// { dg-do run } + +struct S { + int + foo () + { + int res = 0; +#pragma omp target map(size, ptr[:size], res) nowait + res = ptr[size - 1]; +#pragma omp taskwait + return res; + } + + unsigned size; + int *ptr; +}; + +int +main () +{ + S s; + int buf[5]; + s.size = 5; + s.ptr = buf; + buf[4] = 42; + if (s.foo () != 42) + __builtin_abort (); +}