From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 6BF5F3858D33; Tue, 14 Feb 2023 19:55:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BF5F3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1676404535; bh=lF/wX8+WSG28ZkqFdfmPZm0NU4b/BsUUO9pHr5nKbiA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=D41nNBM2HhD4GsDjaTGdJRFAgYRZ3lXeQ28VzYFXG4TRj1PNcrCJb2wwy28HxVRSt 4RmcQFLEUBfxzBeT0Ja9KpkssSMVFLcfxmUqRHXznaeiCVqEeidReDxhRiNVNBn7Us 6vVGJ6WB79AeoWWOkA3e1BVVlcK/TLUM8TOTzSyz38KUvJ3zeGTEbydDQrI9MGEl7u zCQYRRJNHLmweTerKODQGHd3VGVbQ3h4QNk7hbbH4nzE9e5uXvRNdAFTTkb8CLTqb/ qMZ9AK12zcsTLjvHcxTbzoTWBLXyQuBTmofBE532WOryCd64mznzde7D3f1v3MsS2l 2BBTMGWjPhs4A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.251.13.60]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdvmY-1otELR1TwE-00b6Og; Tue, 14 Feb 2023 20:55:35 +0100 Message-ID: <1d59f51b-fffc-3a3a-4c92-edfe5c525783@gmx.de> Date: Tue, 14 Feb 2023 20:55:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: nvptx: Adjust 'scan-assembler' in 'gfortran.dg/weak-1.f90' (was: Support for NOINLINE attribute) To: Thomas Schwinge , Rimvydas Jasinskas , fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Tom de Vries Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <0115618b-059b-fd11-a813-33374f16af78@gmx.de> <87h6vo8u8u.fsf@euler.schwinge.homeip.net> Content-Language: en-US From: Harald Anlauf In-Reply-To: <87h6vo8u8u.fsf@euler.schwinge.homeip.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:he9zzeaM8UC1QuO7Jqs0t3sJovCXi52NZRFuOOz9I7Ci/D/lu1C 7Bm9Oe6Ph5x518x5GdYypPOMMWvIYWKj61bAFZkYKYSv0KZgp5iHNhVZSmlVNWJ5Hgc5/pM S2WZ7fQf1vTzxODh/3G3N/HnoZKLNKrty5L7ZqiQLIg+85RV0ynim3eStRBv0+1OsFz4bsG rFRGcMxDD9Ujyf5PL2AFA== UI-OutboundReport: notjunk:1;M01:P0:nx9XxGDZ5Vc=;2Padfc9IB+palH4ZQSTL0RhLs/3 /fyW83D9X6rM5k7HmI2hWwmQSr3qALVXt41Cfy3JPSbvPpHmtn/BCgwQ/M/ccxoxufU3mTxGR Rm4ak2W2AdwC/dZwA3z3VMarxGjddX/zTCPh6rKzK6ZUrLXtbDaIokzvcG6/MnCy641U9CDZ/ DZ/wMFVb6GNK8527hOQHvU51CUE/98EjWaWg+E/Uu/5bG5P26FjdDLOfeaPfxiuhKPprBAaGe 8WOmKGCA7nzDxTWfKkgIsAWG1MbOGB0GmfBgfrmsEACTwWLd5LDo4yqey3L0FvYBdSa4mQvBm lkAaajYhgd6i4MNK9T/KdZ3jjThdYvH1jSsdz+OyiHzL+61AfdM4CpgpSt9KDKvWKCO1IvE5F CWsDzMbBRxDUIM1HZbIj9UWAHYnxyURUTU8Q5Ozn+lVcHu/20yT+cCAHJxV0L8aResp/19N4w 1mOf+PLcdmmtRqq7xeN/7LkoO/CfvKG83CO+dTTn607ZVDTRLLxEb8HpApqWgeCb6+IPoSdtT rWoVOZ3W2HnmtmJSfAjO5J3nvvPY7I7ZQwIsthc3tAbyPjyeJOdrAqElzBWTv76ixMNB1t7Y6 l6FBOfi+jTDhph43Qm0V6lCP21kSjr9mkG31R6YHGwumeRaaEIvExJG/p55a4Hat+4nqM0ki3 YrbFKLfyXpo+gf2x4YvVElL9JSp1OaELoMi+1UwvTqmG0ZbvekV0MGBjtO2vQ9E2mogXfxVqm RGpGZDVRH6PCWm51EK10AWDXdTW2zZVlkoZ/IetOgvUkmpSpdRj7Kf8L5VzYnYtFeU+1I3wrD G2WbgYUU9FK90l/Q4H0vzFGkxzkWsEG1tQ6PT8gd/eMF9DFn3Ca1Yr25nY9bKvLTbO8Y9rVLi JmlQXYHmaeN0GOmR6eNqC83Q9HgTel2NdyPj8v87xIaD2/yY88IzJHhO/fFeCPtPwlNnB7/6o zNgbcA== X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,NICE_REPLY_A,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 List-Id: Hi Thomas, On 2/14/23 10:35, Thomas Schwinge wrote: > Hi! > > On 2023-02-13T18:50:23+0100, Harald Anlauf via Gcc-patches wrote: >> Pushed as: >> >> commit 086a1df4374962787db37c1f0d1bd9beb828f9e3 > >> On 2/12/23 22:28, Harald Anlauf via Gcc-patches wrote: >>> There is one thing I cannot test, which is the handling of weak symbol= s >>> on other platforms. A quick glance at the C testcases suggests that >>> someone with access to either an NVPTX or MingGW target might tell >>> whether that particular target should be excluded. > > Indeed nvptx does use a different assembler syntax; I've pushed to > master branch commit 8d8175869ca94c600e64e27b7676787b2a398f6e > "nvptx: Adjust 'scan-assembler' in 'gfortran.dg/weak-1.f90'", see > attached. thanks for taking care of this. > And I'm curious, is '!GCC$ ATTRIBUTES weak' meant to be used only for > weak definitions (like in 'gfortran.dg/weak-1.f90'), or also for weak > declarations (which, for example, in the C world then evaluate to > zero-address unless actually defined)? When I did a quick experiment, > that didn't seem to work? (But may be my fault, of course.) > > And, orthogonally: is '!GCC$ ATTRIBUTES weak' meant to be used only for > subroutines (like in 'gfortran.dg/weak-1.f90') and also functions (I > suppose; test case?), or also for weak "data" in some way (which, for > example, in the C world then evaluates to a zero-address unless actually > defined)? It also works for functions, e.g. integer function f () !GCC$ ATTRIBUTES weak :: f print *, "weak f" f =3D 0 end Regarding symbols beyond procedures (subroutines, functions), I had a look at what Crayftn supports. Its manpage has: ``` WEAK Syntax and use of the WEAK directive. !DIR$ WEAK procedure_name[, procedure_name] ... !DIR$ WEAK procedure_name=3D stub_name[, procedure_name1=3D stub_name1] ..= . [...] The WEAK directive supports the following arguments: procedure_name A weak object in the form of a variable or procedure. stub_name A stub procedure that exists in the code. The stub_name will be called if a strong reference does not exist for procedure_name. The stub_name procedure must have the same name and dummy argument list as procedure_name. ``` However, testing e.g. with a module variable either gave an error message or assembly that suggests that this does not work, at least not with version cce/14.0.0. > Could help to at least add a few more test cases, and clarify the > documentation? I'm not sure whether we need to support weak symbols other than procedures in gfortran. Maybe Rimvydas can comment on this. We could clarify the documentation an reject e.g. variables using: diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index ff64588b9a8..75c04ad7ece 100644 =2D-- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -814,6 +814,13 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) set_decl_tls_model (decl, decl_default_tls_model (decl)); + if ((sym->attr.ext_attr & (1 << EXT_ATTR_WEAK)) + && sym->attr.flavor !=3D FL_PROCEDURE) + { + gfc_error ("Symbol %qs at %L has the WEAK attribute but is not a " + "procedure", sym->name, &sym->declared_at); + } + gfc_finish_decl_attrs (decl, &sym->attr); } This would reject code like module m integer :: i, j !GCC$ ATTRIBUTES weak :: j end weak-1.f90:18:17: 18 | integer :: i, j | 1 Error: Symbol 'j' at (1) has the WEAK attribute but is not a procedure Comments and thoughts? Cheers, Harald > > Gr=C3=BC=C3=9Fe > Thomas > > > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe = 201, 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch= =C3=A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesells= chaft: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 167113858D35 for ; Tue, 14 Feb 2023 19:55:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 167113858D35 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pS1Ov-0007vP-7f for gcc-patches@gcc.gnu.org; Tue, 14 Feb 2023 20:55:41 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: nvptx: Adjust 'scan-assembler' in 'gfortran.dg/weak-1.f90' (was: Support for NOINLINE attribute) Date: Tue, 14 Feb 2023 20:55:34 +0100 Message-ID: <1d59f51b-fffc-3a3a-4c92-edfe5c525783@gmx.de> References: <0115618b-059b-fd11-a813-33374f16af78@gmx.de> <87h6vo8u8u.fsf@euler.schwinge.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US In-Reply-To: <87h6vo8u8u.fsf@euler.schwinge.homeip.net> Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,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 List-Id: Message-ID: <20230214195534.gMdXEFig7ueWFOq29W5IGQCf731GKr5pNyP4l3vp6b4@z> Hi Thomas, On 2/14/23 10:35, Thomas Schwinge wrote: > Hi! > > On 2023-02-13T18:50:23+0100, Harald Anlauf via Gcc-patches wrote: >> Pushed as: >> >> commit 086a1df4374962787db37c1f0d1bd9beb828f9e3 > >> On 2/12/23 22:28, Harald Anlauf via Gcc-patches wrote: >>> There is one thing I cannot test, which is the handling of weak symbols >>> on other platforms. A quick glance at the C testcases suggests that >>> someone with access to either an NVPTX or MingGW target might tell >>> whether that particular target should be excluded. > > Indeed nvptx does use a different assembler syntax; I've pushed to > master branch commit 8d8175869ca94c600e64e27b7676787b2a398f6e > "nvptx: Adjust 'scan-assembler' in 'gfortran.dg/weak-1.f90'", see > attached. thanks for taking care of this. > And I'm curious, is '!GCC$ ATTRIBUTES weak' meant to be used only for > weak definitions (like in 'gfortran.dg/weak-1.f90'), or also for weak > declarations (which, for example, in the C world then evaluate to > zero-address unless actually defined)? When I did a quick experiment, > that didn't seem to work? (But may be my fault, of course.) > > And, orthogonally: is '!GCC$ ATTRIBUTES weak' meant to be used only for > subroutines (like in 'gfortran.dg/weak-1.f90') and also functions (I > suppose; test case?), or also for weak "data" in some way (which, for > example, in the C world then evaluates to a zero-address unless actually > defined)? It also works for functions, e.g. integer function f () !GCC$ ATTRIBUTES weak :: f print *, "weak f" f = 0 end Regarding symbols beyond procedures (subroutines, functions), I had a look at what Crayftn supports. Its manpage has: ``` WEAK Syntax and use of the WEAK directive. !DIR$ WEAK procedure_name[, procedure_name] ... !DIR$ WEAK procedure_name= stub_name[, procedure_name1= stub_name1] ... [...] The WEAK directive supports the following arguments: procedure_name A weak object in the form of a variable or procedure. stub_name A stub procedure that exists in the code. The stub_name will be called if a strong reference does not exist for procedure_name. The stub_name procedure must have the same name and dummy argument list as procedure_name. ``` However, testing e.g. with a module variable either gave an error message or assembly that suggests that this does not work, at least not with version cce/14.0.0. > Could help to at least add a few more test cases, and clarify the > documentation? I'm not sure whether we need to support weak symbols other than procedures in gfortran. Maybe Rimvydas can comment on this. We could clarify the documentation an reject e.g. variables using: diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index ff64588b9a8..75c04ad7ece 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -814,6 +814,13 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) set_decl_tls_model (decl, decl_default_tls_model (decl)); + if ((sym->attr.ext_attr & (1 << EXT_ATTR_WEAK)) + && sym->attr.flavor != FL_PROCEDURE) + { + gfc_error ("Symbol %qs at %L has the WEAK attribute but is not a " + "procedure", sym->name, &sym->declared_at); + } + gfc_finish_decl_attrs (decl, &sym->attr); } This would reject code like module m integer :: i, j !GCC$ ATTRIBUTES weak :: j end weak-1.f90:18:17: 18 | integer :: i, j | 1 Error: Symbol 'j' at (1) has the WEAK attribute but is not a procedure Comments and thoughts? Cheers, Harald > > Grüße > Thomas > > > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955