public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-coroutines] fortran: Fix up ISO_Fortran_binding_15.f90 failures [PR92123]
@ 2020-01-30 21:06 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2020-01-30 21:06 UTC (permalink / raw)
  To: gcc-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 4538 bytes --]

https://gcc.gnu.org/g:2595f25cdaf4f16d04a1078a487b2ecc126cae29

commit 2595f25cdaf4f16d04a1078a487b2ecc126cae29
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 30 09:35:03 2020 +0100

    fortran: Fix up ISO_Fortran_binding_15.f90 failures [PR92123]
    
    This is something that has been discussed already a few months ago, but
    seems to have stalled.  Here is Paul's patch from the PR except for the
    TREE_STATIC hunk which is wrong, and does the most conservative fn spec
    tweak for the problematic two builtins we are aware of (to repeat what is in
    the PR, both .wR and .ww are wrong for these builtins that transform one
    layout of an descriptor to another one; while the first pointer is properly
    marked that we only store to what it points to, from the second pointer
    we copy and reshuffle the content and store into the first one; if there
    wouldn't be any pointers, ".wr" would be just fine, but as there is a
    pointer and that pointer is copied to the area pointed by first argument,
    the pointer effectively leaks that way, so we e.g. can't optimize stores
    into what the data pointer in the descriptor points to).  I haven't
    analyzed other fn spec attributes in the FE, but think it is better to
    fix at least this one we have analyzed.
    
    2020-01-30  Paul Thomas  <pault@gcc.gnu.org>
    	    Jakub Jelinek  <jakub@redhat.com>
    
    	PR fortran/92123
    	* trans-decl.c (gfc_get_symbol_decl): Call gfc_defer_symbol_init for
    	CFI descs.
    	(gfc_build_builtin_function_decls): Use ".w." instead of ".ww" or ".wR"
    	for gfor_fndecl_{cfi_to_gfc,gfc_to_cfi}.
    	(convert_CFI_desc): Handle references to CFI descriptors.
    
    Co-authored-by: Paul Thomas <pault@gcc.gnu.org>

Diff:
---
 gcc/fortran/ChangeLog    | 10 ++++++++++
 gcc/fortran/trans-decl.c | 14 ++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 12e5996..2b66fc7 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2020-01-30  Paul Thomas  <pault@gcc.gnu.org>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/92123
+	* trans-decl.c (gfc_get_symbol_decl): Call gfc_defer_symbol_init for
+	CFI descs.
+	(gfc_build_builtin_function_decls): Use ".w." instead of ".ww" or ".wR"
+	for gfor_fndecl_{cfi_to_gfc,gfc_to_cfi}.
+	(convert_CFI_desc): Handle references to CFI descriptors.
+
 2020-01-29  Jakub Jelinek  <jakub@redhat.com>
 
 	PR fortran/93463
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 63ce962..1147c24 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1552,6 +1552,9 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       sym->ts.u.cl->backend_decl = build_fold_indirect_ref (sym->ts.u.cl->backend_decl);
     }
 
+  if (is_CFI_desc (sym, NULL))
+    gfc_defer_symbol_init (sym);
+
   fun_or_res = byref && (sym->attr.result
 			 || (sym->attr.function && sym->ts.deferred));
   if ((sym->attr.dummy && ! sym->attr.function) || fun_or_res)
@@ -3763,12 +3766,17 @@ gfc_build_builtin_function_decls (void)
 	get_identifier (PREFIX("internal_unpack")), ".wR",
 	void_type_node, 2, pvoid_type_node, pvoid_type_node);
 
+  /* These two builtins write into what the first argument points to and
+     read from what the second argument points to, but we can't use R
+     for that, because the directly pointed structure contains a pointer
+     which is copied into the descriptor pointed by the first argument,
+     effectively escaping that way.  See PR92123.  */
   gfor_fndecl_cfi_to_gfc = gfc_build_library_function_decl_with_spec (
-	get_identifier (PREFIX("cfi_desc_to_gfc_desc")), ".ww",
+	get_identifier (PREFIX("cfi_desc_to_gfc_desc")), ".w.",
 	void_type_node, 2, pvoid_type_node, ppvoid_type_node);
 
   gfor_fndecl_gfc_to_cfi = gfc_build_library_function_decl_with_spec (
-	get_identifier (PREFIX("gfc_desc_to_cfi_desc")), ".wR",
+	get_identifier (PREFIX("gfc_desc_to_cfi_desc")), ".w.",
 	void_type_node, 2, ppvoid_type_node, pvoid_type_node);
 
   gfor_fndecl_associated = gfc_build_library_function_decl_with_spec (
@@ -4398,6 +4406,8 @@ convert_CFI_desc (gfc_wrapped_block * block, gfc_symbol *sym)
      while CFI_desc is the descriptor itself.  */
   if (DECL_LANG_SPECIFIC (sym->backend_decl))
     CFI_desc = GFC_DECL_SAVED_DESCRIPTOR (sym->backend_decl);
+  else if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (sym->backend_decl))))
+    CFI_desc = sym->backend_decl;
   else
     CFI_desc = NULL;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-30 21:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-30 21:06 [gcc/devel/c++-coroutines] fortran: Fix up ISO_Fortran_binding_15.f90 failures [PR92123] Iain D Sandoe

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