diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-10-16 14:41:13 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-10-16 14:41:13 +0200 |
commit | 4ef36ac7d0cfd23f8f72744796d2d118fd7f1c7d (patch) | |
tree | 53c0e66ce676fad0a93522f1beb9fe11cdb13b38 /gcc/ada/inline.adb | |
parent | ed616c6c35baa352a8a60c5e2e7ae661acc5089c (diff) | |
download | gcc-4ef36ac7d0cfd23f8f72744796d2d118fd7f1c7d.zip gcc-4ef36ac7d0cfd23f8f72744796d2d118fd7f1c7d.tar.gz gcc-4ef36ac7d0cfd23f8f72744796d2d118fd7f1c7d.tar.bz2 |
[multiple changes]
2015-10-16 Eric Botcazou <ebotcazou@adacore.com>
* 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 <charlet@adacore.com>
* sinfo.ads, einfo.ads: monir clean ups.
From-SVN: r228883
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r-- | gcc/ada/inline.adb | 47 |
1 files changed, 23 insertions, 24 deletions
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; |