From patchwork Thu Sep 19 14:01:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 1987456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=vehre@gmx.de header.a=rsa-sha256 header.s=s31663417 header.b=nuozDjiM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X8cdv3K2kz1xrD for ; Fri, 20 Sep 2024 00:02:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 980313858C5F for ; Thu, 19 Sep 2024 14:02:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 877133858D28; Thu, 19 Sep 2024 14:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 877133858D28 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 877133858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726754504; cv=none; b=LZBiAJoajlX8ttupo2a9ukLiGRaXy6+vAEzOptJFiimR9bFDeMDQiBJxVIT8D/uiknL1arP6vA2/LfSRrZhAz/o2MxpFkxwuwBu/juq69XnWEq0B3xvDAvNy7b8BTKmfuEwA5NkKoaABAW9yYqsQXhCcIQMnA9W1GggO5wrbU0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726754504; c=relaxed/simple; bh=oy1hqhNnXZdxOAfJimt+KW25xKA9FFPMS+BxnffNfho=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=xnTpYOL6fMoaO4EVulOdXJtGoPrMTl8Z9EVenybO96nUWASs9LcsEMOm5KQp/LAcbIn2jQ5q9N6+NRZxlYoDRlWEiH5Fgu0l8oczJHFWGDhxhQFvVa2v6ha/PYqUqlOq9hfDn5XBj2eEc4x/8mIq3Cv47ZkwSW1M3Tm7t0n3X3o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1726754492; x=1727359292; i=vehre@gmx.de; bh=S3iYXis/xmpNHA/LB21cOrAsoF+fTD+jS4v8GBGYaPY=; h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type:cc:content-transfer-encoding:content-type:date:from: message-id:mime-version:reply-to:subject:to; b=nuozDjiMklEBD9vNy6g3zAm/vbYpZ9cTx+huQiW86TNms0joTQ2OhOt8WtpkqIsP x761eOMA2dCbNwjIdgo6YDMq6JYfTCfTs3vz1/aZKeGVj5U5VMw2pjb1gRHXE6cKJ pJnY66ZZhpmboOBT+Yw0C3UZIqL+oQgeDRfizYtSN43JGJLXwrUXaLeCEVr2LFgFo 5ebu3GwQ2ZYM/KDFDEemEgb92v2vplVfl2l4LcnAutAXXtLZn0tX8ZOsZ0pLkunKM jTgDLz+97oICRFWHVzMEfChylm8YiY7ZH4pMIoj+wU1j1eW7sqoXQfkUrzh3KU8Jz q/p6ipfy+NnL33on4w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from vepi2 ([62.155.199.54]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MiacR-1sMMPr0Ufn-00fkbh; Thu, 19 Sep 2024 16:01:32 +0200 Date: Thu, 19 Sep 2024 16:01:31 +0200 From: Andre Vehreschild To: GCC-Patches-ML , GCC-Fortran-ML Subject: [Fortran, Patch, PR84870, v1] Fix ICE and allocated memory not assigned correctly. Message-ID: <20240919160131.656b36e0@vepi2> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Provags-ID: V03:K1:w42H26SFNsOtms/f5sm4TxMHqHfyxeISJaVVLCQ1ogG/fDDi+Y3 jgFAN6R/EB1YhGknw+2A5Fk9NRc5MZKcpd724zW9e2bkW6NcbweFVmIM/rRCVi5k2yH5YKM bhp4m1XuA8U8i4yjITd215oOFHLndstFU38h0Rn4XnGpLQlj4ZDsqDgKbF5NrKiubmG9VPJ kHw+KbNetqmTjuACZXaYQ== UI-OutboundReport: notjunk:1;M01:P0:Cz5pedV56zU=;Jf3feXd29ukrqWWyK/6E5yDmZvi VqdKMf05CcJVzldbcvVJQWJXuRxRrTKnM/Ai7t8Bq6i4UD0SErLd5lmRDvHJRJ6rsmy0N7gkn eHZSygXIoMkyfiveeJmOSmS8jH8jKKZc3kf/C1lAy9qkctfZTn6YnqTj917Gg76P6cw3zlXKg 848cH3Smb0fr5oJbpyD550a+ssBoeLk6KH0lVL5LW7mQLe6XpLLja8DLhDfVDabBMoOuyeoAc /VxvtSCGYtb2mpqFd8zo/Aq8u8Q+uZDCWE1LmefCG7oo3odPFqCdi5G2sHFGcOKARP49kXA6R wK209zHNkGrkzKPsn2VQsAiKWoLucWQXMYY2bpf8ahTm1QaUNUtE6UqyUrhjd+CCPcMowDguo 9GBozR9XBf6D4YcCR2Une9vWmSW+k9P3ZA1l/0qs+R+CoZ7RoGTdMn0hAn0fU8pGD71u0cA3w HY5At/n0NPOSwG9u5n9jFl3RinN8zm4vPl1vn+RLTgG1TFrCKhCdV0oA/ui3uvBs0TJhw89O/ 0BOd/QXsvu8uwfcdav2NVCTZ/BmZt59i8rMUfTopjakNFGFX802dQYq+vSYc/CTGsm3A1yrtF xgSXAu0LB4IzPh14QlWaN5K2Jr9GMVihO0HlOCtbkRWfGcI1rAvlpPe2EJ3AgP7OnEhwP5ogq S9DUaOipokrD4WkDOBnEStN+2xvCKomMVRZy2wBhzr0ofkhOMK+p2L5oaiyUl6lO+4q3iq9kW O6waZBnoOeegj78eXFUQ8mid553400/5f3Dw0I7H0lVr36GNvgn5+EuBRPygRFO9vS2DbpwqV ODv/tSSXVf7svDIHd5ju8TTQ== X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi all, in PR84870 an ICE was reported, that has been fixed in the meantime by some other patch. Nevertheless did a testcase reveal that the memory handling still was not correct. I.e. the test case in the patch was answering 2 for both x.b.a and y.b.a which is not correct. For a coarray all memory is allocated using an array descriptor. For scalars just a temporary descriptor is created and handed to the caf-register routine. The error here was, that the memory now handed back in the temporary descriptor was not used for the memory in the component, thus the pointer in the component was not updated. The patch fixes this. Regtests ok on x86_64-pc-linux-gnu / Fedora 39. Ok for mainline? Regards, Andre --- Andre Vehreschild * Email: vehre ad gmx dot de From c26e97a8196fc26abf36a0bad6ffd6f9da7ba5d8 Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Thu, 19 Sep 2024 15:09:52 +0200 Subject: [PATCH] Fortran: Assign allocated caf-memory to scalar members [PR84870] Allocating a coarray required an array-descriptor. For scalars a temporary descriptor was created. Assigning the allocated memory from the temporary descriptor back to the scalar is now added. gcc/fortran/ChangeLog: PR fortran/84870 * trans-array.cc (duplicate_allocatable_coarray): For scalar allocatable components the memory allocated is now assigned to the component's pointer. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/alloc_comp_10.f90: New test. --- gcc/fortran/trans-array.cc | 2 ++ .../gfortran.dg/coarray/alloc_comp_10.f90 | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 838b6d3da80..3da7479fd10 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -9451,6 +9451,7 @@ duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src, tree type, gfc_build_addr_expr (NULL_TREE, dest_tok), NULL_TREE, NULL_TREE, NULL_TREE, GFC_CAF_COARRAY_ALLOC_REGISTER_ONLY); + gfc_add_modify (&block, dest, gfc_conv_descriptor_data_get (dummy_desc)); null_data = gfc_finish_block (&block); gfc_init_block (&block); @@ -9460,6 +9461,7 @@ duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src, tree type, gfc_build_addr_expr (NULL_TREE, dest_tok), NULL_TREE, NULL_TREE, NULL_TREE, GFC_CAF_COARRAY_ALLOC); + gfc_add_modify (&block, dest, gfc_conv_descriptor_data_get (dummy_desc)); tmp = builtin_decl_explicit (BUILT_IN_MEMCPY); tmp = build_call_expr_loc (input_location, tmp, 3, dest, src, diff --git a/gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 new file mode 100644 index 00000000000..a31d005498c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_10.f90 @@ -0,0 +1,24 @@ +!{ dg-do run } + +! Check that copying of memory for allocated scalar is assigned +! to coarray object. + +! Contributed by G. Steinmetz + +program p + type t + integer, allocatable :: a + end type + type t2 + type(t), allocatable :: b + end type + type(t2) :: x, y[*] + + x%b = t(1) + y = x + y%b%a = 2 + + if (x%b%a /= 1) stop 1 + if (y%b%a /= 2) stop 2 +end + -- 2.46.0