public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Toon Moene <toon@moene.org>
To: gfortran <fortran@gcc.gnu.org>
Subject: Fwd: [PATCH 08/25] Fix co-array allocation
Date: Wed, 05 Sep 2018 16:54:00 -0000	[thread overview]
Message-ID: <7f5064c3-afc6-b7b5-cade-f03af5b86331@moene.org> (raw)
In-Reply-To: <024e798b9539b765a1259cfc9cb2f1dc480b24ca.1536144068.git.ams@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]




-------- 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  <kcy@codesourcery.com>

	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(-)



[-- Attachment #2: 0008-Fix-co-array-allocation.patch --]
[-- Type: text/x-patch, Size: 1832 bytes --]

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]);


       reply	other threads:[~2018-09-05 16:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <024e798b9539b765a1259cfc9cb2f1dc480b24ca.1536144068.git.ams@codesourcery.com>
2018-09-05 16:54 ` Toon Moene [this message]
2018-09-05 17:02   ` Bernhard Reutner-Fischer
2018-09-05 18:07   ` Janne Blomqvist
2018-09-19 16:24     ` Andrew Stubbs
2018-09-19 21:18       ` Damian Rouson
2018-09-19 22:30         ` Andrew Stubbs
2018-09-19 23:09           ` Damian Rouson
2018-09-20 20:02         ` Thomas Koenig
2018-09-20 20:56           ` Damian Rouson
2018-09-21  7:33           ` Toon Moene
2018-09-23 11:40             ` Janne Blomqvist
2018-09-21 16:25           ` OpenCoarrays integration with gfortran Jerry DeLisle
2018-09-21 19:13             ` Janne Blomqvist
2018-09-21 19:37             ` Richard Biener
2018-09-21 20:17             ` Damian Rouson
2018-09-21 23:23               ` Jerry DeLisle
2018-09-23  9:47                 ` Toon Moene
2018-09-23 16:48                   ` Bernhard Reutner-Fischer
2018-09-23 19:17                     ` Toon Moene
2018-09-23 20:19                       ` Bernhard Reutner-Fischer
2018-09-24 10:58                   ` Alastair McKinstry
2018-09-27 12:29                     ` Richard Biener
2018-09-27 13:32                       ` Jorge D'Elia
2018-09-20 15:56       ` [PATCH 08/25] Fix co-array allocation Janne Blomqvist
2018-09-20 16:23         ` Andrew Stubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f5064c3-afc6-b7b5-cade-f03af5b86331@moene.org \
    --to=toon@moene.org \
    --cc=fortran@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).