From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 501 invoked by alias); 5 Sep 2018 16:54:00 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 488 invoked by uid 89); 5 Sep 2018 16:53:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=fwd, H*Ad:U*toon X-HELO: moene.org Received: from moene.org (HELO moene.org) (80.101.130.238) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Sep 2018 16:53:58 +0000 Received: from localhost ([127.0.0.1] helo=moene.org) by moene.org with esmtp (Exim 4.91) (envelope-from ) id 1fxb3z-0004gL-MZ for fortran@gcc.gnu.org; Wed, 05 Sep 2018 18:53:55 +0200 Subject: Fwd: [PATCH 08/25] Fix co-array allocation References: <024e798b9539b765a1259cfc9cb2f1dc480b24ca.1536144068.git.ams@codesourcery.com> To: gfortran From: Toon Moene X-Forwarded-Message-Id: <024e798b9539b765a1259cfc9cb2f1dc480b24ca.1536144068.git.ams@codesourcery.com> Message-ID: <7f5064c3-afc6-b7b5-cade-f03af5b86331@moene.org> Date: Wed, 05 Sep 2018 16:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <024e798b9539b765a1259cfc9cb2f1dc480b24ca.1536144068.git.ams@codesourcery.com> Content-Type: multipart/mixed; boundary="------------392C9C6673D918800F634AB5" X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00052.txt.bz2 This is a multi-part message in MIME format. --------------392C9C6673D918800F634AB5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1055 -------- Forwarded Message -------- Subject: [PATCH 08/25] Fix co-array allocation Date: Wed, 5 Sep 2018 12:49:40 +0100 From: ams@codesourcery.com To: gcc-patches@gcc.gnu.org The Fortran front-end has a bug in which it uses "int" values for "size_t" parameters. I don't know why this isn't problem for all 64-bit architectures, but GCN ends up with the data in the wrong argument register and/or stack slot, and bad things happen. This patch corrects the issue by setting the correct type. 2018-09-05 Kwok Cheung Yeung gcc/fortran/ * trans-expr.c (gfc_trans_structure_assign): Ensure that integer_zero_node is of sizetype when used as the first argument of a call to _gfortran_caf_register. * trans-intrinsic.c (conv_intrinsic_event_query): Convert computed index to a size_t type. * trans-stmt.c (gfc_trans_event_post_wait): Likewise. --- gcc/fortran/trans-expr.c | 2 +- gcc/fortran/trans-intrinsic.c | 3 ++- gcc/fortran/trans-stmt.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) --------------392C9C6673D918800F634AB5 Content-Type: text/x-patch; name="0008-Fix-co-array-allocation.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0008-Fix-co-array-allocation.patch" Content-length: 1832 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 56ce98c..91be3fb 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -7729,7 +7729,7 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr, bool init, bool coarray) suffices to recognize the data as array. */ if (rank < 0) rank = 1; - size = integer_zero_node; + size = fold_convert (sizetype, integer_zero_node); desc = field; gfc_add_modify (&block, gfc_conv_descriptor_rank (desc), build_int_cst (signed_char_type_node, rank)); diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index b2cea93..23c13da 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -10732,7 +10732,8 @@ conv_intrinsic_event_query (gfc_code *code) tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node, extent, tmp); index = fold_build2_loc (input_location, PLUS_EXPR, - integer_type_node, index, tmp); + size_type_node, index, + fold_convert (size_type_node, tmp)); if (i < ar->dimen - 1) { ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]); diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 795d3cc..2c59675 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -1096,7 +1096,8 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op) tmp = fold_build2_loc (input_location, MULT_EXPR, integer_type_node, extent, tmp); index = fold_build2_loc (input_location, PLUS_EXPR, - integer_type_node, index, tmp); + size_type_node, index, + fold_convert (size_type_node, tmp)); if (i < ar->dimen - 1) { ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]); --------------392C9C6673D918800F634AB5--