diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/ada/inline.adb | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r-- | gcc/ada/inline.adb | 118 |
1 files changed, 49 insertions, 69 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index bb4d97c..6c330b2 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2021, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -24,39 +24,43 @@ ------------------------------------------------------------------------------ with Alloc; -with Aspects; use Aspects; -with Atree; use Atree; -with Debug; use Debug; -with Einfo; use Einfo; -with Elists; use Elists; -with Errout; use Errout; -with Expander; use Expander; -with Exp_Ch6; use Exp_Ch6; -with Exp_Ch7; use Exp_Ch7; -with Exp_Tss; use Exp_Tss; -with Exp_Util; use Exp_Util; -with Fname; use Fname; -with Fname.UF; use Fname.UF; -with Lib; use Lib; -with Namet; use Namet; -with Nmake; use Nmake; -with Nlists; use Nlists; -with Output; use Output; -with Sem_Aux; use Sem_Aux; -with Sem_Ch8; use Sem_Ch8; -with Sem_Ch10; use Sem_Ch10; -with Sem_Ch12; use Sem_Ch12; -with Sem_Prag; use Sem_Prag; -with Sem_Res; use Sem_Res; -with Sem_Util; use Sem_Util; -with Sinfo; use Sinfo; -with Sinput; use Sinput; -with Snames; use Snames; -with Stand; use Stand; +with Aspects; use Aspects; +with Atree; use Atree; +with Debug; use Debug; +with Einfo; use Einfo; +with Einfo.Entities; use Einfo.Entities; +with Einfo.Utils; use Einfo.Utils; +with Elists; use Elists; +with Errout; use Errout; +with Expander; use Expander; +with Exp_Ch6; use Exp_Ch6; +with Exp_Ch7; use Exp_Ch7; +with Exp_Tss; use Exp_Tss; +with Exp_Util; use Exp_Util; +with Fname; use Fname; +with Fname.UF; use Fname.UF; +with Lib; use Lib; +with Namet; use Namet; +with Nmake; use Nmake; +with Nlists; use Nlists; +with Output; use Output; +with Sem_Aux; use Sem_Aux; +with Sem_Ch8; use Sem_Ch8; +with Sem_Ch10; use Sem_Ch10; +with Sem_Ch12; use Sem_Ch12; +with Sem_Prag; use Sem_Prag; +with Sem_Res; use Sem_Res; +with Sem_Util; use Sem_Util; +with Sinfo; use Sinfo; +with Sinfo.Nodes; use Sinfo.Nodes; +with Sinfo.Utils; use Sinfo.Utils; +with Sinput; use Sinput; +with Snames; use Snames; +with Stand; use Stand; with Table; -with Tbuild; use Tbuild; -with Uintp; use Uintp; -with Uname; use Uname; +with Tbuild; use Tbuild; +with Uintp; use Uintp; +with Uname; use Uname; with GNAT.HTable; @@ -1451,7 +1455,7 @@ package body Inline is -- Skip inlining if the function returns an unconstrained type -- using an extended return statement, since this part of the -- new inlining model is not yet supported by the current - -- implementation. ??? + -- implementation. or else (Returns_Unconstrained_Type (Spec_Id) and then Has_Extended_Return) @@ -1469,7 +1473,7 @@ package body Inline is end if; Set_Body_To_Inline (Decl, Original_Body); - Set_Ekind (Defining_Entity (Original_Body), Ekind (Spec_Id)); + Mutate_Ekind (Defining_Entity (Original_Body), Ekind (Spec_Id)); Set_Is_Inlined (Spec_Id); end Build_Body_To_Inline; @@ -1531,7 +1535,6 @@ package body Inline is function Is_Unit_Subprogram (Id : Entity_Id) return Boolean; -- Return True if subprogram Id defines a compilation unit - -- Shouldn't this be in Sem_Aux??? function In_Package_Spec (Id : Entity_Id) return Boolean; -- Return True if subprogram Id is defined in the package specification, @@ -2161,10 +2164,7 @@ package body Inline is Body_To_Inline := Copy_Generic_Node (N, Empty, Instantiating => True); else - -- ??? Shouldn't this use New_Copy_Tree? What about global - -- references captured in the body to inline? - - Body_To_Inline := Copy_Separate_Tree (N); + Body_To_Inline := New_Copy_Tree (N); end if; -- Remove aspects/pragmas that have no meaning in an inlined body @@ -2251,7 +2251,7 @@ package body Inline is pragma Assert (No (Body_To_Inline (Decl))); Set_Body_To_Inline (Decl, Original_Body); - Set_Ekind (Defining_Entity (Original_Body), Ekind (Spec_Id)); + Mutate_Ekind (Defining_Entity (Original_Body), Ekind (Spec_Id)); end Build_Body_To_Inline; -------------------------------- @@ -2827,7 +2827,7 @@ package body Inline is ------------------------- function Formal_Is_Used_Once (Formal : Entity_Id) return Boolean is - Use_Counter : Int := 0; + Use_Counter : Nat := 0; function Count_Uses (N : Node_Id) return Traverse_Result; -- Traverse the tree and count the uses of the formal parameter. @@ -2856,13 +2856,10 @@ package body Inline is then Use_Counter := Use_Counter + 1; - if Use_Counter > 1 then - - -- Denote more than one use and abandon the traversal + -- If this is a second use then abandon the traversal - Use_Counter := 2; + if Use_Counter > 1 then return Abandon; - end if; end if; @@ -3011,10 +3008,7 @@ package body Inline is if Nkind (A) = N_Type_Conversion and then Ekind (F) /= E_In_Parameter then - New_A := - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => New_Occurrence_Of (Etype (F), Loc), - Expression => Relocate_Node (Expression (A))); + New_A := Unchecked_Convert_To (Etype (F), Expression (A)); -- In GNATprove mode, keep the most precise type of the actual for -- the temporary variable, when the formal type is unconstrained. @@ -3557,7 +3551,6 @@ package body Inline is procedure Reset_Dispatching_Calls (N : Node_Id) is function Do_Reset (N : Node_Id) return Traverse_Result; - -- Comment required ??? -------------- -- Do_Reset -- @@ -3578,17 +3571,10 @@ package body Inline is return OK; end Do_Reset; - function Do_Reset_Calls is new Traverse_Func (Do_Reset); - - -- Local variables - - Dummy : constant Traverse_Result := Do_Reset_Calls (N); - pragma Unreferenced (Dummy); - - -- Start of processing for Reset_Dispatching_Calls + procedure Do_Reset_Calls is new Traverse_Proc (Do_Reset); begin - null; + Do_Reset_Calls (N); end Reset_Dispatching_Calls; --------------------------- @@ -3630,7 +3616,6 @@ package body Inline is -- If the context is an assignment, and the left-hand side is free of -- side-effects, the replacement is also safe. - -- Can this be generalized further??? elsif Nkind (Parent (N)) = N_Assignment_Statement and then @@ -4821,7 +4806,7 @@ package body Inline is end if; end Instantiate_Body; - J, K : Nat; + J, K : Nat; Info : Pending_Body_Info; -- Start of processing for Instantiate_Bodies @@ -5168,17 +5153,12 @@ package body Inline is -------------------------- procedure Remove_Dead_Instance (N : Node_Id) is - J : Int; - begin - J := 0; - while J <= Pending_Instantiations.Last loop + for J in 0 .. Pending_Instantiations.Last loop if Pending_Instantiations.Table (J).Inst_Node = N then Pending_Instantiations.Table (J).Inst_Node := Empty; return; end if; - - J := J + 1; end loop; end Remove_Dead_Instance; |