From 4ef36ac7d0cfd23f8f72744796d2d118fd7f1c7d Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 16 Oct 2015 14:41:13 +0200 Subject: [PATCH] [multiple changes] 2015-10-16 Eric Botcazou * inline.adb (Subp_Info): Remove Listed component. (Add_Inlined_Subprogram): Take an entity instead of an index. Do not set Listed component to True. (New_Entry): Do not initialize Listed component to False. (Analyze_Inlined_Bodies): Do not test Listed component (Must_Inline): Add calls not in the main unit only if they are in a subprogram that can be inlined outside its unit. (Add_Inlined_Body): Move test around and add comment. 2015-10-16 Arnaud Charlet * sinfo.ads, einfo.ads: monir clean ups. From-SVN: r228883 --- gcc/ada/ChangeLog | 15 +++++++++++++++ gcc/ada/einfo.ads | 39 ++++++++++++++++++++------------------- gcc/ada/inline.adb | 47 +++++++++++++++++++++++------------------------ gcc/ada/sinfo.ads | 6 +++--- 4 files changed, 61 insertions(+), 46 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 951b803..d745cca 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,18 @@ +2015-10-16 Eric Botcazou + + * inline.adb (Subp_Info): Remove Listed component. + (Add_Inlined_Subprogram): Take an entity instead of an index. + Do not set Listed component to True. + (New_Entry): Do not initialize Listed component to False. + (Analyze_Inlined_Bodies): Do not test Listed component + (Must_Inline): Add calls not in the main unit only + if they are in a subprogram that can be inlined outside its unit. + (Add_Inlined_Body): Move test around and add comment. + +2015-10-16 Arnaud Charlet + + * sinfo.ads, einfo.ads: monir clean ups. + 2015-10-16 Arnaud Charlet * usage.adb, debug.adb, a-except.adb, a-except.ads, a-except-2005.adb, diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index b118149..07d9a9518 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -120,7 +120,7 @@ package Einfo is -- For functions that are not inlined, there is no restriction on the body, -- and XEINFO generates a direct reference in the C header file which allows --- the C code in the backend to directly call the corresponding Ada body. +-- the C code in the backend to directly call the corresponding Ada body. ---------------------------------- -- Handling of Type'Size Values -- @@ -1613,7 +1613,7 @@ package Einfo is -- generic entities before the corresponding generic body has been seen. -- If a package has a forward instantiation, we cannot inline subprograms -- appearing in the same package because the placement requirements of --- the instance will conflict with the linear elaboration of front-end +-- the instance will conflict with the linear elaboration of front-end -- inlining. -- Has_Fully_Qualified_Name (Flag173) @@ -2436,7 +2436,7 @@ package Einfo is -- Is_Fixed_Point_Type (synthesized) -- Applies to all entities, true for decimal and ordinary fixed --- point types and subtypes +-- point types and subtypes. -- Is_Floating_Point_Type (synthesized) -- Applies to all entities, true for float types and subtypes @@ -2633,7 +2633,7 @@ package Einfo is -- Is_Invariant_Procedure (Flag257) -- Defined in functions an procedures. Set for a generated invariant --- procedure to identify it easily in the +-- procedure to identify it easily in the. -- Is_Itype (Flag91) -- Defined in all entities. Set to indicate that a type is an Itype, @@ -2913,7 +2913,7 @@ package Einfo is -- Is_Private_Type (synthesized) -- Applies to all entities, true for private types and subtypes, --- as well as for record with private types as subtypes +-- as well as for record with private types as subtypes. -- Is_Processed_Transient (Flag252) -- Defined in variables, loop parameters, and constants, including the @@ -2972,7 +2972,7 @@ package Einfo is -- Is_Record_Type (synthesized) -- Applies to all entities, true for record types and subtypes, --- includes class-wide types and subtypes (which are also records) +-- includes class-wide types and subtypes (which are also records). -- Is_Remote_Call_Interface (Flag62) -- Defined in all entities. Set in E_Package and E_Generic_Package @@ -3070,7 +3070,7 @@ package Einfo is -- vtable (i.e. the one to be extended by derivation). -- Is_Tagged_Type (Flag55) --- Defined in all entities. Set for an entity that is a tagged type. +-- Defined in all entities. Set for an entity that is a tagged type -- Is_Task_Interface (synthesized) -- Defined in types that are interfaces. True if interface is declared as @@ -3501,7 +3501,7 @@ package Einfo is -- access type, or if an explicit pragma No_Strict_Aliasing applies. -- No_Tagged_Streams_Pragma (Node32) --- Present in all subtype and type entities. Set for tagged types and +-- Present in all subtype and type entities. Set for tagged types and -- subtypes (i.e. entities with Is_Tagged_Type set True) if a valid -- pragma/aspect applies to the type. @@ -3659,7 +3659,7 @@ package Einfo is -- Parameter_Mode (synthesized) -- Applies to formal parameter entities. This is a synonym for Ekind, -- used when obtaining the formal kind of a formal parameter (the result --- is one of E_[In/Out/In_Out]_Parameter) +-- is one of E_[In/Out/In_Out]_Parameter). -- Parent_Subtype (Node19) [base type only] -- Defined in E_Record_Type. Set only for derived tagged types, in which @@ -3981,7 +3981,7 @@ package Einfo is -- Indicates the number of scopes that statically enclose the declaration -- of the unit or type. Library units have a depth of zero. Note that -- record types can act as scopes but do NOT have this field set (see --- Scope_Depth above) +-- Scope_Depth above). -- Scope_Depth_Set (synthesized) -- Applies to a special predicate function that returns a Boolean value @@ -4501,7 +4501,7 @@ package Einfo is -- The classification of program entities which follows is a refinement of -- the list given in RM 3.1(1). E.g., separate entities denote subtypes of -- different type classes. Ada 95 entities include class wide types, --- protected types, subprogram types, generalized access types, generic +-- protected types, subprogram types, generalized access types, generic -- formal derived types and generic formal packages. -- The order chosen for these kinds allows us to classify related entities @@ -4664,7 +4664,7 @@ package Einfo is E_Access_Attribute_Type, -- An access type created for an access attribute (such as 'Access, - -- 'Unrestricted_Access and Unchecked_Access) + -- 'Unrestricted_Access and Unchecked_Access). E_Allocator_Type, -- A special internal type used to label allocators and references to @@ -4893,7 +4893,7 @@ package Einfo is E_Protected_Body, -- A protected body. This entity serves almost no function, since all - -- semantic analysis uses the protected entity (E_Protected_Type) + -- semantic analysis uses the protected entity (E_Protected_Type). E_Task_Body, -- A task body. This entity serves almost no function, since all @@ -6445,7 +6445,7 @@ package Einfo is -- types, and a field in the type entities contains a value of the -- following type indicating which alignment choice applies. For full -- details of the meaning of these alignment types, see description - -- of the Component_Alignment pragma + -- of the Component_Alignment pragma. type Component_Alignment_Kind is ( Calign_Default, -- default alignment @@ -6469,9 +6469,9 @@ package Einfo is -- attributes are procedural, and require some small amount of -- computation. Of course, from the point of view of a user of this -- package, the distinction is not visible (even the field information - -- provided below should be disregarded, as it is subject to change - -- without notice). A number of attributes appear as lists: lists of - -- formals, lists of actuals, of discriminants, etc. For these, pairs + -- provided below should be disregarded, as it is subject to change + -- without notice). A number of attributes appear as lists: lists of + -- formals, lists of actuals, of discriminants, etc. For these, pairs -- of functions are defined, which take the form: -- function First_Thing (E : Enclosing_Construct) return Thing; @@ -7116,7 +7116,8 @@ package Einfo is -- whether an Ekind value belongs to a specified kind, for example the -- function Is_Elementary_Type tests if its argument is in Elementary_Kind. -- In some cases, the test is of an entity attribute (e.g. in the case of - -- Is_Generic_Type where the Ekind does not provide the needed information) + -- Is_Generic_Type where the Ekind does not provide the needed + -- information). function Is_Access_Type (Id : E) return B; function Is_Access_Protected_Subprogram_Type (Id : E) return B; @@ -8035,7 +8036,7 @@ package Einfo is procedure Write_Entity_Flags (Id : Entity_Id; Prefix : String); -- Writes a series of entries giving a line for each flag that is - -- set to True. Each line is prefixed by the given string + -- set to True. Each line is prefixed by the given string. procedure Write_Entity_Info (Id : Entity_Id; Prefix : String); -- A debugging procedure to write out information about an entity diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 398a466f..d68a972 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -158,7 +158,6 @@ package body Inline is Name : Entity_Id := Empty; Next : Subp_Index := No_Subp; First_Succ : Succ_Index := No_Succ; - Listed : Boolean := False; Main_Call : Boolean := False; Processed : Boolean := False; end record; @@ -180,8 +179,8 @@ package body Inline is -- called, and for the inlined subprogram that contains the call. If -- the call is in the main compilation unit, Caller is Empty. - procedure Add_Inlined_Subprogram (Index : Subp_Index); - -- Add the subprogram to the list of inlined subprogram for the unit + procedure Add_Inlined_Subprogram (E : Entity_Id); + -- Add subprogram E to the list of inlined subprogram for the unit function Add_Subp (E : Entity_Id) return Subp_Index; -- Make entry in Inlined table for subprogram E, or return table index @@ -347,15 +346,19 @@ package body Inline is return Inline_Package; end if; - -- The call is not in the main unit. See if it is in some inlined - -- subprogram. If so, inline the call and, if the inlining level is - -- set to 1, stop there; otherwise also compile the package as above. + -- The call is not in the main unit. See if it is in some subprogram + -- that can be inlined outside its unit. If so, inline the call and, + -- if the inlining level is set to 1, stop there; otherwise also + -- compile the package as above. Scop := Current_Scope; while Scope (Scop) /= Standard_Standard and then not Is_Child_Unit (Scop) loop - if Is_Overloadable (Scop) and then Is_Inlined (Scop) then + if Is_Overloadable (Scop) + and then Is_Inlined (Scop) + and then not Is_Nested (Scop) + then Add_Call (E, Scop); if Inline_Level = 1 then @@ -378,6 +381,15 @@ package body Inline is begin Append_New_Elmt (N, To => Backend_Calls); + -- Skip subprograms that cannot be inlined outside their unit + + if Is_Abstract_Subprogram (E) + or else Convention (E) = Convention_Protected + or else Is_Nested (E) + then + return; + end if; + -- Find unit containing E, and add to list of inlined bodies if needed. -- If the body is already present, no need to load any other unit. This -- is the case for an initialization procedure, which appears in the @@ -391,13 +403,6 @@ package body Inline is -- no enclosing package to retrieve. In this case, it is the body of -- the function that will have to be loaded. - if Is_Abstract_Subprogram (E) - or else Is_Nested (E) - or else Convention (E) = Convention_Protected - then - return; - end if; - Level := Must_Inline; if Level /= Dont_Inline then @@ -475,8 +480,7 @@ package body Inline is -- Add_Inlined_Subprogram -- ---------------------------- - procedure Add_Inlined_Subprogram (Index : Subp_Index) is - E : constant Entity_Id := Inlined.Table (Index).Name; + procedure Add_Inlined_Subprogram (E : Entity_Id) is Decl : constant Node_Id := Parent (Declaration_Node (E)); Pack : constant Entity_Id := Get_Code_Unit_Entity (E); @@ -538,8 +542,6 @@ package body Inline is else Register_Backend_Not_Inlined_Subprogram (E); end if; - - Inlined.Table (Index).Listed := True; end Add_Inlined_Subprogram; ------------------------ @@ -606,7 +608,6 @@ package body Inline is Inlined.Table (Inlined.Last).Name := E; Inlined.Table (Inlined.Last).Next := No_Subp; Inlined.Table (Inlined.Last).First_Succ := No_Succ; - Inlined.Table (Inlined.Last).Listed := False; Inlined.Table (Inlined.Last).Main_Call := False; Inlined.Table (Inlined.Last).Processed := False; end New_Entry; @@ -832,7 +833,7 @@ package body Inline is -- as part of an inlined package, but are not themselves called. An -- accurate computation of just those subprograms that are needed -- requires that we perform a transitive closure over the call graph, - -- starting from calls in the main program. + -- starting from calls in the main compilation unit. for Index in Inlined.First .. Inlined.Last loop if not Is_Called (Inlined.Table (Index).Name) then @@ -879,10 +880,8 @@ package body Inline is -- subprograms for the unit. for Index in Inlined.First .. Inlined.Last loop - if Is_Called (Inlined.Table (Index).Name) - and then not Inlined.Table (Index).Listed - then - Add_Inlined_Subprogram (Index); + if Is_Called (Inlined.Table (Index).Name) then + Add_Inlined_Subprogram (Inlined.Table (Index).Name); end if; end loop; diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 77d0a2d..ab610c3 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -1905,7 +1905,7 @@ package Sinfo is -- body, and no entities of the with'ed unit are referenced by the spec -- (an entity may still be referenced in the body, so this flag is used -- to generate the proper message (see Sem_Util.Check_Unused_Withs for - -- full details) + -- full details). -- No_Initialization (Flag13-Sem) -- Present in N_Object_Declaration and N_Allocator to indicate that the @@ -3634,7 +3634,7 @@ package Sinfo is -- INDEXED_COMPONENT ::= PREFIX (EXPRESSION {, EXPRESSION}) -- Note: the parser may generate this node in some situations where it - -- should be a function call. The semantic pass must correct this + -- should be a function call. The semantic pass must correct this -- misidentification (which is inevitable at the parser level). -- N_Indexed_Component @@ -4571,7 +4571,7 @@ package Sinfo is -- {LABEL} SIMPLE_STATEMENT | {LABEL} COMPOUND_STATEMENT -- There is no explicit node in the tree for a statement. Instead, the - -- individual statement appears directly. Labels are treated as a + -- individual statement appears directly. Labels are treated as a -- kind of statement, i.e. they are linked into a statement list at -- the point they appear, so the labeled statement appears following -- the label or labels in the statement list. -- 2.7.4