From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id ADF5F3857402; Tue, 17 May 2022 08:27:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADF5F3857402 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-524] [Ada] Use Actions field of freeze nodes for subprograms X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: a08f366ae875ae70fba5014c94956cdbf7bf91db X-Git-Newrev: d4090614041c7803373a5064dfb82fdf6017971d Message-Id: <20220517082742.ADF5F3857402@sourceware.org> Date: Tue, 17 May 2022 08:27:42 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2022 08:27:42 -0000 https://gcc.gnu.org/g:d4090614041c7803373a5064dfb82fdf6017971d commit r13-524-gd4090614041c7803373a5064dfb82fdf6017971d Author: Eric Botcazou Date: Sat Mar 19 00:23:39 2022 +0100 [Ada] Use Actions field of freeze nodes for subprograms This has a couple of advantages: 1) the actions are analyzed with checks disabled and 2) they are considered elaboration code by Sem_Elab. gcc/ada/ * exp_ch13.adb (Expand_N_Freeze_Entity): Delete freeze nodes for subprograms only if they have no actions. * exp_ch6.adb (Freeze_Subprogram): Put the actions into the Actions field of the freeze node instead of inserting them after it. * sem_elab.adb (Is_SPARK_Semantic_Target): Fix typo in comment. * gcc-interface/trans.cc (process_freeze_entity): Return early for freeze nodes of subprograms with Interface_Alias set. Diff: --- gcc/ada/exp_ch13.adb | 14 ++++++-------- gcc/ada/exp_ch6.adb | 15 +++++++++++++-- gcc/ada/gcc-interface/trans.cc | 5 +++++ gcc/ada/sem_elab.adb | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gcc/ada/exp_ch13.adb b/gcc/ada/exp_ch13.adb index d3765e25543..6b6da818387 100644 --- a/gcc/ada/exp_ch13.adb +++ b/gcc/ada/exp_ch13.adb @@ -617,14 +617,12 @@ package body Exp_Ch13 is elsif Is_Subprogram (E) then Exp_Ch6.Freeze_Subprogram (N); - -- Ada 2005 (AI-251): Remove the freezing node associated with the - -- entities internally used by the frontend to register primitives - -- covering abstract interfaces. The call to Freeze_Subprogram has - -- already expanded the code that fills the corresponding entry in - -- its secondary dispatch table and therefore the code generator - -- has nothing else to do with this freezing node. - - Delete := Present (Interface_Alias (E)); + -- Ada 2005 (AI-251): Remove the freeze nodes associated with the + -- entities internally used by the front end to register primitives + -- covering abstract interfaces if they have no side effects. For the + -- others, gigi must discard them after evaluating the side effects. + + Delete := Present (Interface_Alias (E)) and then No (Actions (N)); end if; -- Analyze actions generated by freezing. The init_proc contains source diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index db5ec357bea..c3067f1a9c4 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -7856,6 +7856,8 @@ package body Exp_Ch6 is declare Typ : constant Entity_Id := Scope (DTC_Entity (Subp)); + L : List_Id; + begin -- Handle private overridden primitives @@ -7895,8 +7897,17 @@ package body Exp_Ch6 is Register_Predefined_DT_Entry (Subp); end if; - Insert_Actions_After (N, - Register_Primitive (Loc, Prim => Subp)); + L := Register_Primitive (Loc, Prim => Subp); + + if Is_Empty_List (L) then + null; + + elsif No (Actions (N)) then + Set_Actions (N, L); + + else + Append_List (L, Actions (N)); + end if; end if; end if; end; diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 57419861838..e9701cdf72f 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -9045,6 +9045,11 @@ process_freeze_entity (Node_Id gnat_node) if (kind == E_Class_Wide_Type) return; + /* Likewise for the entities internally used by the front-end to register + primitives covering abstract interfaces, see Expand_N_Freeze_Entity. */ + if (Is_Subprogram (gnat_entity) && Present (Interface_Alias (gnat_entity))) + return; + /* Check for an old definition if this isn't an object with address clause, since the saved GCC tree is the address expression in that case. */ gnu_old diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 8e38f8c1285..caebb174577 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -1845,7 +1845,7 @@ package body Sem_Elab is function Is_SPARK_Semantic_Target (Id : Entity_Id) return Boolean; pragma Inline (Is_SPARK_Semantic_Target); - -- Determine whether arbitrary entity Id nodes a source or internally + -- Determine whether arbitrary entity Id denotes a source or internally -- generated subprogram which emulates SPARK semantics. function Is_Subprogram_Inst (Id : Entity_Id) return Boolean;