From 4a6db9fd05bff1cd7a487eb87a4a0413c3c2301a Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 14 Aug 2019 09:50:51 +0000 Subject: [PATCH] [Ada] Small internal improvements to the inlining machinery No functional changes. 2019-08-14 Eric Botcazou gcc/ada/ * inline.adb (Add_Inlined_Body): Tweak comments. (List_Inlining_Info): Also list information about non-main units. From-SVN: r274447 --- gcc/ada/ChangeLog | 6 ++++ gcc/ada/inline.adb | 75 +++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8ad19833248..ff7de27c00e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-08-14 Eric Botcazou + + * inline.adb (Add_Inlined_Body): Tweak comments. + (List_Inlining_Info): Also list information about non-main + units. + 2019-08-14 Gary Dismukes * sem_ch4.adb (Analyze_Selected_Component): In the case where diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 3a3ec0cf8ed..aa8f7ddf40d 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -481,12 +481,6 @@ package body Inline is 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 - -- package declaration that contains the type. It is also the case if - -- the body has already been analyzed. Finally, if the unit enclosing - -- E is an instance, the instance body will be analyzed in any case. - -- Library-level functions must be handled specially, because there is -- no enclosing package to retrieve. In this case, it is the body of -- the function that will have to be loaded. @@ -504,6 +498,9 @@ package body Inline is else pragma Assert (Ekind (Pack) = E_Package); + -- If the unit containing E is an instance, then the instance body + -- will be analyzed in any case, see Sem_Ch12.Might_Inline_Subp. + if Is_Generic_Instance (Pack) then null; @@ -514,7 +511,7 @@ package body Inline is -- Do not inline it either if it is in the main unit. -- Extend the -gnatn2 processing to -gnatn1 for Inline_Always -- calls if the back-end takes care of inlining the call. - -- Note that Level in Inline_Package | Inline_Call here. + -- Note that Level is in Inline_Call | Inline_Packag here. elsif ((Level = Inline_Call and then Has_Pragma_Inline_Always (E) @@ -4350,7 +4347,7 @@ package body Inline is while Present (Elmt) loop Nod := Node (Elmt); - if In_Extended_Main_Code_Unit (Nod) then + if not In_Internal_Unit (Nod) then Count := Count + 1; if Count = 1 then @@ -4379,7 +4376,7 @@ package body Inline is while Present (Elmt) loop Nod := Node (Elmt); - if In_Extended_Main_Code_Unit (Nod) then + if not In_Internal_Unit (Nod) then Count := Count + 1; if Count = 1 then @@ -4407,22 +4404,24 @@ package body Inline is while Present (Elmt) loop Nod := Node (Elmt); - Count := Count + 1; + if not In_Internal_Unit (Nod) then + Count := Count + 1; - if Count = 1 then - Write_Str - ("List of inlined subprograms passed to the backend"); - Write_Eol; - end if; + if Count = 1 then + Write_Str + ("List of inlined subprograms passed to the backend"); + Write_Eol; + end if; - Write_Str (" "); - Write_Int (Count); - Write_Str (":"); - Write_Name (Chars (Nod)); - Write_Str (" ("); - Write_Location (Sloc (Nod)); - Write_Str (")"); - Output.Write_Eol; + Write_Str (" "); + Write_Int (Count); + Write_Str (":"); + Write_Name (Chars (Nod)); + Write_Str (" ("); + Write_Location (Sloc (Nod)); + Write_Str (")"); + Output.Write_Eol; + end if; Next_Elmt (Elmt); end loop; @@ -4437,22 +4436,24 @@ package body Inline is while Present (Elmt) loop Nod := Node (Elmt); - Count := Count + 1; + if not In_Internal_Unit (Nod) then + Count := Count + 1; - if Count = 1 then - Write_Str - ("List of subprograms that cannot be inlined by the backend"); - Write_Eol; - end if; + if Count = 1 then + Write_Str + ("List of subprograms that cannot be inlined by backend"); + Write_Eol; + end if; - Write_Str (" "); - Write_Int (Count); - Write_Str (":"); - Write_Name (Chars (Nod)); - Write_Str (" ("); - Write_Location (Sloc (Nod)); - Write_Str (")"); - Output.Write_Eol; + Write_Str (" "); + Write_Int (Count); + Write_Str (":"); + Write_Name (Chars (Nod)); + Write_Str (" ("); + Write_Location (Sloc (Nod)); + Write_Str (")"); + Output.Write_Eol; + end if; Next_Elmt (Elmt); end loop; -- 2.30.2