From patchwork Tue Dec 13 18:32:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 705494 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tdSxy3cQ2z9s3v for ; Wed, 14 Dec 2016 05:33:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BkB+EyR/"; dkim-atps=neutral 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=dnNcCdTJfbTKRwMf M/++hBJQXGecZg7YYaoFsGxc2G5nRYlDCBU0bp1bZhelai+lZ8o5w1PRq2diUwjP BDFVSUGdUsty0xIvQ8p0EULSiI/ahE6+gt0wghM/nUc7Sw3DnP5IhqCbnJ9zg/P6 KVtdTDMEOyw6XBtKJs25ztYaHU8= 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=91YbRbod29KNKrCdr9TJqw mCNlY=; b=BkB+EyR/IwOfcyxJLzRrtilwTx7z15FJSQCPeWEo5Hw3navfvrZy0G kgRNB3J4GWgKEDkvAyNUdi687qGNpuVniE9fzNV34neb7jbDR69YWcUwkHmhVIn8 ScHZZVOwyAleU1KIRia6y4Cd7zfj7cBh5t/OMPWv9+oYaYCRRx9b0= Received: (qmail 75847 invoked by alias); 13 Dec 2016 18:32:49 -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 75820 invoked by uid 89); 13 Dec 2016 18:32:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Fortran, gfc_expr, sk:gfc_act, gfc_code X-Spam-User: qpsmtpd, 3 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Dec 2016 18:32:38 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0La3c1-1d2Wyc3fLB-00llmg; Tue, 13 Dec 2016 19:32:36 +0100 Date: Tue, 13 Dec 2016 19:32:33 +0100 From: Andre Vehreschild To: "janus at gcc dot gnu.org" Cc: GCC-Fortran-ML , GCC-Patches-ML Subject: [PATCH, Fortran, pr78780, v1] [7 Regression] [Coarray] ICE in conv_caf_send, at fortran/trans-intrinsic.c:1936 Message-ID: <20161213193233.1fdf5013@vepi2> In-Reply-To: References: MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:wIULJH+33Dw=:tVkVXg0+s3UO1/Zm36QSEf D5TRmXLhoUI1g3MHotowKkisSR4Byei/DzHxpDt6mXHcbVpQi9EiUvadiYbnN1XYwy6a96kPq HbmGwGvCEe3ylazhtWsgi4ZupKt0AWvPg97tb+4YzGEhEirNU+PBsdvr0tA2aGHK1lfKEQt94 FkjTvgbnfjG3fDUGy6yJ6BePX1K5xTvr2WMGprwZYWiBlR7ULTqZVyr8rM/ifowmekD2BZKgf 4JVW8v5RlIk8/R2bblaOVmoZiqGv9wbuFcvZbntUWaPAj+I88K8Lnrx9U7pb5NEioGzkWML9E /ImYJkE7m4HwRwwMRxl1398kTVvfRLYmZj6cjiP5FH91417qPDo5CxX92TSzDSp0MSlVJJGgi mUTo0cREATE4a4LMNj8B/Mm4uPDtWX3WsXN6zJhS/zts+JLfWgfrEmSt7RXWsyFi+HrN6gRII Qqn46+ttG/76o5OrrwZpMt6hsgjfWeEO2pi3NXmCNF/opvQN3zIKrcHyHMwnZPzKx/CNckXm8 UzVqpbT98/fy8bTMBd/FLQs4eP2byiRp0ldSXOiAklv5sFlwch0GOztPiWuAX2GHhnmP4EyKK vpUcAKJAHlqoIWLOTpTwamvyY+oW4eGx73LFrepyMUy6b5bx5rJCmIfKx+95ARd4CUq3Qso4R h5/84CO+HG+JLU4K1E+RGgokVYd84VwUCPTCCcdGicd8fsqp85HXgi0bJ2xDLQ7ts4nrpp+3r CadAInRdeDlNiXuxQQOgQ9cBLnOSxZKgeAgICXQ4fUR+1p3IjQbsqfmlSxo= Hi all, 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? - Andre diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 2f45d40..f908c25 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -9718,7 +9718,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, 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 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, 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 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, } 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; diff --git a/gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 new file mode 100644 index 0000000..159f5a3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_5.f90 @@ -0,0 +1,16 @@ +! { 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) + D%endsi(2) = D%n + if (any(D%endsi /= [ 0, 64])) error stop + deallocate(D) +end program +