From patchwork Wed Sep 5 11:49:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 966333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-485169-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yhbes/Z3"; dkim-atps=neutral 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 42529G3v9xz9s5c for ; Wed, 5 Sep 2018 21:51:30 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type; q=dns; s=default; b=UwrN13qa9qQLB6g+2AG+4qGd6gtpI dYRoEz7q7hwuvQA7cvJ45lEGQ5TrC/4tI/PqFpCibNE6bcch+Md8vaOPBEX8FVhE tOBhx2BJKwTFXmTDUyA2pK5EN0OC8CVzIimzogeolIi1+A6FSr0syIy/Oz7I64kE hIZ19wjZnZmXlk= 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:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type; s=default; bh=3UPwfcsvjjRuBAjjiK9owcrJhw0=; b=yhb es/Z3oJBsn4SnJq2voMSzakCTnAi6pZUEfdzf234db54Ar3WPq1iwiBwOgAMjcRG cbTuSNUS+5c4sYLKXyzntQhyGt7mSRIYje5l9ZqQHOcctanI3h6rn2utJyjVr7TW 75cBwsOTH/l6i1Rvx6EfzkyoRV37LzV3DL/ySSwI= Received: (qmail 84456 invoked by alias); 5 Sep 2018 11:50:07 -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 84361 invoked by uid 89); 5 Sep 2018 11:50:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=HX-detected-operating-system:Windows X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Sep 2018 11:50:05 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxWJu-0002oN-CO for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 07:50:03 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:45367) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fxWJu-0002nR-4r for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 07:50:02 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fxWJt-0005ZF-9t from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 04:50:01 -0700 Received: from build6-trusty-cs.sje.mentorg.com (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 5 Sep 2018 12:49:57 +0100 From: To: Subject: [PATCH 08/25] Fix co-array allocation Date: Wed, 5 Sep 2018 12:49:40 +0100 Message-ID: <024e798b9539b765a1259cfc9cb2f1dc480b24ca.1536144068.git.ams@codesourcery.com> In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 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(-) 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]);