From patchwork Wed Dec 14 12:50:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 88015 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp176510qgi; Wed, 14 Dec 2016 04:51:02 -0800 (PST) X-Received: by 10.84.178.195 with SMTP id z61mr209540014plb.176.1481719861959; Wed, 14 Dec 2016 04:51:01 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e22si52686656pli.289.2016.12.14.04.51.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 04:51:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444393-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444393-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444393-patch=linaro.org@gcc.gnu.org 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:cc:subject:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=Pu6W2tOCKqgRpYwZ ahpflDAUwDy/wQRA/8AVnH1J1FZVc9fNvGPGDYOh+4xXP4T7kuX0LLmhV9iKe5Qu menacE17MFqld/w3olaYZaHyM9Ato/R+JhZraPMGc0ZCZIi/aGf+/QJ0VfSUVrk8 xg3kuYy7sGEqWvAeUtz8erhb13c= 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:cc:subject:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=0NTq0qvubut7/3DElN2FqK vKIlY=; b=aT/NAlMSaMzPUYdOMmizX6D1eNkFks3JaE/SOeiUHXCqQMNj9niZKs vIbUSMGGwTME19ipNa2wMEsNcB3T4rZLVKFjrHKREyDdRt+ezNcvUcgRUvwwCywd N3dKWyhhKkxio3lozysHRrxYHvZ1M9NvLrSkZEYiEg4TpBaptsFz8= Received: (qmail 108377 invoked by alias); 14 Dec 2016 12:50:33 -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 108318 invoked by uid 89); 14 Dec 2016 12:50:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=bed, nicht, Arbeitskopie, arbeitskopie X-Spam-User: qpsmtpd, 3 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.22) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Dec 2016 12:50:19 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MSuYT-1c9CMU1Jbh-00RtTC; Wed, 14 Dec 2016 13:50:07 +0100 Date: Wed, 14 Dec 2016 13:50:04 +0100 From: Andre Vehreschild To: Steve Kargl Cc: "janus at gcc dot gnu.org" , GCC-Fortran-ML , GCC-Patches-ML Subject: Re: [PATCH, Fortran, pr78780, v1] [7 Regression] [Coarray] ICE in conv_caf_send, at fortran/trans-intrinsic.c:1936 Message-ID: <20161214135004.114db87a@vepi2> In-Reply-To: <20161213185208.GA4673@troutmask.apl.washington.edu> References: <20161213193233.1fdf5013@vepi2> <20161213185208.GA4673@troutmask.apl.washington.edu> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:Ugow0HtQCmQ=:Mxq+qnrCdSledaGOdJY9PT rOo+uRFe+gg2uD/QBupL1+T+V63TmqKxYlfARWulIosNxrVfWpPMmdbLCnoj44MKVUKX96aAz P/94NNVfy5SUID4dN3hc8VVOXS90pB7w2WtrdVFP4hZfTWh80Y0wqKmepa0p2eR1FUIaquNdk QFYC7LWhG5wxsuwbyH+E3A/MuaP3S7YSyky35/jLKAXnYXwMCBFY4tBsrQm0NhHdD+1+sh8Mg H62M5YgO7kw85CTyjhpNh3PQtBWQqx4FN18m8YqdCym2LDsz55YQjW1t8Gwk8musnboI70Fm4 y/8CKuzDpgceOCKip1HLxMfPydKXX1YuhhSH4nHLqJdEsw/ITGgIimhtHjvtctgMBaRc7FGHR blq4YlIA9Kp9f98DOoIEPmXk3zanOvAx6GkEd0G7qiPsh4KtcAo9FQ9HXiNteKqMe7Q+LxsG7 v2jY7yMuOfeAH/5ZDdU7Q0rBnAefMJtvQDKMkz4qMGEWdFmUIKFaoW1USzOFpPVAShh218JJV FFoGHcZcSW3d2KISdrt6eMDAxGaAbeTLPkKDZ/NVm05IVr3AFQn41ZoWeqDWEHbPM7pI5j4Ss kYyVOS7NQKHVZ9LJlvehqbD/uy//ImUWkiiKB62FZJuPtPNQiTo6k0RmCMcFteOc+JBnHUHcQ 8oFf5qogMIKOGuW4k8WYWypqrEHMh9nD+EUC7BaMfaKa4FmEt8R4fu2Bxhjyo6BO8WtZzHMSc ZnoMlKliQaERd2DnhQI8kxEkS1ZeafBzMfIVkxfCdvhqDD38AL9mT18nmao= Hi Steve, hi all, thanks for the review. While going to bed, it came to me that the testcase checks only half of result of this patch. I therefore took the liberty to add another testcase, that checks that the other part of the change is also tested as testsuite/gfortran.dg/coarray_42.f90. The change bootstrapped and regtested fine on x86_64-linux/f23 therefore committed as r243648. Regards, Andre On Tue, 13 Dec 2016 10:52:08 -0800 Steve Kargl wrote: > On Tue, Dec 13, 2016 at 07:32:33PM +0100, Andre Vehreschild wrote: > > > > attached patch fixes the issue by improving the check whether a call of the > > caf-runtime-routines needs to be generated instead of a regular assignment. > > > > Bootstraps and regtests ok on x86_64-linux/f23. Ok for trunk? > > > > gcc/testsuite/ChangeLog: > > > > 2016-12-13 Andre Vehreschild > > > > PR fortran/78780 > > * gfortran.dg/coarray/alloc_comp_5.f90: New test. > > > > gcc/fortran/ChangeLog: > > > > 2016-12-13 Andre Vehreschild > > > > PR fortran/78780 > > * trans-expr.c (gfc_trans_assignment_1): Improve check whether > > detour caf-runtime routines is needed. > > > > OK. > -- Andre Vehreschild * Email: vehre ad gmx dot de Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 243647) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,5 +1,11 @@ 2016-12-14 Andre Vehreschild + PR fortran/78780 + * trans-expr.c (gfc_trans_assignment_1): Improve check whether detour + caf-runtime routines is needed. + +2016-12-14 Andre Vehreschild + PR fortran/78672 * array.c (gfc_find_array_ref): Add flag to return NULL when no ref is found instead of erroring out. Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 243647) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -9718,7 +9718,7 @@ bool scalar_to_array; tree string_length; int n; - bool maybe_workshare = false; + bool maybe_workshare = false, lhs_refs_comp = false, rhs_refs_comp = false; symbol_attribute lhs_caf_attr, rhs_caf_attr, lhs_attr; bool is_poly_assign; @@ -9758,8 +9758,8 @@ mode. */ if (flag_coarray == GFC_FCOARRAY_LIB) { - lhs_caf_attr = gfc_caf_attr (expr1); - rhs_caf_attr = gfc_caf_attr (expr2); + lhs_caf_attr = gfc_caf_attr (expr1, false, &lhs_refs_comp); + rhs_caf_attr = gfc_caf_attr (expr2, false, &rhs_refs_comp); } if (lss != gfc_ss_terminator) @@ -9959,10 +9959,19 @@ } else if (flag_coarray == GFC_FCOARRAY_LIB && lhs_caf_attr.codimension && rhs_caf_attr.codimension - && lhs_caf_attr.alloc_comp && rhs_caf_attr.alloc_comp) + && ((lhs_caf_attr.allocatable && lhs_refs_comp) + || (rhs_caf_attr.allocatable && rhs_refs_comp))) { + /* Only detour to caf_send[get][_by_ref] () when the lhs or rhs is an + allocatable component, because those need to be accessed via the + caf-runtime. No need to check for coindexes here, because resolve + has rewritten those already. */ gfc_code code; gfc_actual_arglist a1, a2; + /* Clear the structures to prevent accessing garbage. */ + memset (&code, '\0', sizeof (gfc_code)); + memset (&a1, '\0', sizeof (gfc_actual_arglist)); + memset (&a2, '\0', sizeof (gfc_actual_arglist)); a1.expr = expr1; a1.next = &a2; a2.expr = expr2; Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 243647) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,9 @@ +2016-12-14 Andre Vehreschild + + PR fortran/78780 + * gfortran.dg/coarray/alloc_comp_5.f90: New test. + * gfortran.dg/coarray_42.f90: New test. + 2016-12-14 Jakub Jelinek PR target/78796 Index: gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 =================================================================== --- gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 (nicht existent) +++ gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 (Arbeitskopie) @@ -0,0 +1,17 @@ +! { dg-do run } + +program Jac + type Domain + integer :: n=64 + integer,allocatable :: endsi(:) + end type + type(Domain),allocatable :: D[:,:,:] + + allocate(D[2,2,*]) + allocate(D%endsi(2), source = 0) + ! No caf-runtime call needed her. + D%endsi(2) = D%n + if (any(D%endsi /= [ 0, 64])) error stop + deallocate(D) +end program + Index: gcc/testsuite/gfortran.dg/coarray_42.f90 =================================================================== --- gcc/testsuite/gfortran.dg/coarray_42.f90 (nicht existent) +++ gcc/testsuite/gfortran.dg/coarray_42.f90 (Arbeitskopie) @@ -0,0 +1,20 @@ +! { dg-do run } +! { dg-options "-fdump-tree-original -fcoarray=lib -lcaf_single" } + +program Jac + type Domain + integer :: n=64 + integer,allocatable :: endsi(:) + end type + type(Domain),allocatable :: D[:,:,:] + + allocate(D[2,2,*]) + allocate(D%endsi(2), source = 0) + ! Lhs may be reallocate, so caf_send_by_ref needs to be used. + D%endsi = D%n + if (any(D%endsi /= [ 64, 64])) error stop + deallocate(D) +end program + +! { dg-final { scan-tree-dump-times "caf_send_by_ref" 1 "original" } } +