From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 05BAA393BC05; Wed, 24 Feb 2021 21:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 05BAA393BC05 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: wZR2p1Iu/tXTiVPMUwp5AELOivMrP5A3qGnWkW3thZTC3dq332GQDTxguFevW3+8LVaFc6ivzs Drr2D7AbsvQYIzh+azFHzpBUFxDu2kXD2vUaCMfFa4NWymTZZuAo0qOpGUNFiFr4+MqfKV7JfJ tBe/MsRU8EQyZmeysYnZTdMp4OaJJt8BJiZHUPcI8WwFAOcghUOt1VCxgKCCWuqkVvQdwPhLHn KE8NGCdkPonnMLfroa6doGMP/9BTU2yxq9O+XOKWf9I9/t8m1d77kasdGnzblFKyxkpgpxaa+L owc= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="58597695" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 24 Feb 2021 13:57:41 -0800 IronPort-SDR: 8kdO04ziMcqSqCwhjwfHePZZbFAGelyUrU3ST+UaYrVebXHvbCUSV/50bw/kJjIRoomRIsPxTB 98FoJDQbROlLERU+WaBD/SwJdBxw3bkNkqx4GfyjzS4lYjdSxTNAguPBZ+7E+QMrnPxudBhiJH OMAuv5XUjWW9J5VQIEYAGAmi199zhw7nuw98djKG7rHgJXh2IUhNyX8dWUKPZ2TOg3U6djtNxf SKl+0AG4tkIGYdzapu8zri69ctqKgYWkkCZEF66azrx/cWSOm8wI18TOHq9rSQqRtVhUkxiqcD B/k= From: Julian Brown To: CC: , Tobias Burnus Subject: [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Date: Wed, 24 Feb 2021 13:57:22 -0800 Message-ID: <20210224215726.129681-2-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210224215726.129681-1-julian@codesourcery.com> References: <20210224215726.129681-1-julian@codesourcery.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 21:57:45 -0000 The stanza in gfc_trans_omp_clauses that handles derived type members that are themselves derived type pointers or class pointers now adds an explicit dereference only for the latter. The former is already dereferenced transparently in gfc_conv_component_ref. gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Fix dereferencing for BT_DERIVED members. gcc/testsuite/ * gfortran.dg/goacc/derived-classtypes-1.f95: New test. (cherry picked from commit cff6e8db880b6e262730b1ce9a9cb00c1f5571e2) --- gcc/fortran/ChangeLog.omp | 7 + gcc/fortran/trans-openmp.c | 7 +- gcc/testsuite/ChangeLog.omp | 6 + .../goacc/derived-classtypes-1.f95 | 129 ++++++++++++++++++ 4 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index a02606190319..9e0cf7198acf 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,10 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * trans-openmp.c (gfc_trans_omp_clauses): Fix dereferencing for + BT_DERIVED members. + 2021-02-12 Tobias Burnus Backport from mainline diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 452e2a69baa2..e53f7ebb7d7f 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2980,6 +2980,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, if (lastcomp->u.c.component->ts.type == BT_CLASS) { data = gfc_class_data_get (inner); + gcc_assert (POINTER_TYPE_P (TREE_TYPE (data))); + data = build_fold_indirect_ref (data); size = gfc_class_vtab_size_get (inner); } else /* BT_DERIVED. */ @@ -2988,8 +2990,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, size = TYPE_SIZE_UNIT (TREE_TYPE (inner)); } - OMP_CLAUSE_DECL (node) - = build_fold_indirect_ref (data); + OMP_CLAUSE_DECL (node) = data; OMP_CLAUSE_SIZE (node) = size; node2 = build_omp_clause (input_location, OMP_CLAUSE_MAP); @@ -2997,7 +2998,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, openacc ? GOMP_MAP_ATTACH_DETACH : GOMP_MAP_ALWAYS_POINTER); - OMP_CLAUSE_DECL (node2) = data; + OMP_CLAUSE_DECL (node2) = build_fold_addr_expr (data); OMP_CLAUSE_SIZE (node2) = size_int (0); } else diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 8f5512990b85..8caef33f95e4 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,9 @@ +2021-02-24 Julian Brown + + Backport from mainline + + * gfortran.dg/goacc/derived-classtypes-1.f95: New test. + 2021-02-12 Tobias Burnus Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 new file mode 100644 index 000000000000..e6cf09c6d3c1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 @@ -0,0 +1,129 @@ +type :: type1 + integer :: a +end type type1 + +type :: type2 + integer, pointer :: b +end type type2 + +type :: aux1 + integer :: y +end type aux1 + +type, extends(aux1) :: aux + integer :: x +end type aux + +type :: type3 + class(aux), pointer :: c(:) +end type type3 + +type :: type4 + integer, pointer :: d(:) +end type type4 + +type :: type5 + type(aux) :: e +end type type5 + +type :: type6 + type(aux), pointer :: f +end type type6 + +type :: type7 + class(aux), pointer :: g +end type type7 + +type(type1) :: foo +type(type2) :: bar +type(type3) :: qux +type(type4) :: quux +type(type5) :: fred +type(type6) :: jim +type(type7) :: shiela + +type(type1), pointer :: pfoo +type(type2), pointer :: pbar +type(type3), pointer :: pqux +type(type4), pointer :: pquux +type(type5), pointer :: pfred +type(type6), pointer :: pjim +type(type7), pointer :: pshiela + +class(type1), pointer :: cfoo +class(type2), pointer :: cbar +class(type3), pointer :: cqux +class(type4), pointer :: cquux +class(type5), pointer :: cfred +class(type6), pointer :: cjim +class(type7), pointer :: cshiela + +class(type1), allocatable :: acfoo +class(type2), allocatable :: acbar +class(type3), allocatable :: acqux +class(type4), allocatable :: acquux +class(type5), allocatable :: acfred +class(type6), allocatable :: acjim +class(type7), allocatable :: acshiela + +!$acc enter data copyin(foo) +!$acc enter data copyin(foo%a) +!$acc enter data copyin(bar) +!$acc enter data copyin(bar%b) +!$acc enter data copyin(qux) +!!$acc enter data copyin(qux%c) +!$acc enter data copyin(quux) +!$acc enter data copyin(quux%d) +!$acc enter data copyin(fred) +!$acc enter data copyin(fred%e) +!$acc enter data copyin(jim) +!$acc enter data copyin(jim%f) +!$acc enter data copyin(shiela) +!$acc enter data copyin(shiela%g) + +!$acc enter data copyin(pfoo) +!$acc enter data copyin(pfoo%a) +!$acc enter data copyin(pbar) +!$acc enter data copyin(pbar%b) +!$acc enter data copyin(pqux) +!!$acc enter data copyin(pqux%c) +!$acc enter data copyin(pquux) +!$acc enter data copyin(pquux%d) +!$acc enter data copyin(pfred) +!$acc enter data copyin(pfred%e) +!$acc enter data copyin(pjim) +!$acc enter data copyin(pjim%f) +!$acc enter data copyin(pshiela) +!$acc enter data copyin(pshiela%g) + +!$acc enter data copyin(cfoo) +!$acc enter data copyin(cfoo%a) +!$acc enter data copyin(cbar) +!$acc enter data copyin(cbar%b) +!$acc enter data copyin(cqux) +!!$acc enter data copyin(cqux%c) +!$acc enter data copyin(cquux) +!$acc enter data copyin(cquux%d) +!$acc enter data copyin(cfred) +!$acc enter data copyin(cfred%e) +!$acc enter data copyin(cjim) +!$acc enter data copyin(cjim%f) +!$acc enter data copyin(cshiela) +!$acc enter data copyin(cshiela%g) + +!$acc enter data copyin(acfoo) +!$acc enter data copyin(acfoo%a) +!$acc enter data copyin(acbar) +!$acc enter data copyin(acbar%b) +!$acc enter data copyin(acqux) +!!$acc enter data copyin(acqux%c) +!$acc enter data copyin(acquux) +!$acc enter data copyin(acquux%d) +!$acc enter data copyin(acfred) +!$acc enter data copyin(acfred%e) +!$acc enter data copyin(acjim) +!$acc enter data copyin(acjim%f) +!$acc enter data copyin(acshiela) +!$acc enter data copyin(acshiela%g) + +end -- 2.29.2