diff options
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r-- | gcc/ada/inline.adb | 74 |
1 files changed, 17 insertions, 57 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 494f1f8..e8eeebd 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -320,6 +320,7 @@ package body Inline is -- Exit_Cases -- Postcondition -- Precondition + -- Program_Exit -- Refined_Global -- Refined_Depends -- Refined_Post @@ -1005,9 +1006,9 @@ package body Inline is end loop; -- The list of inlined subprograms is an overestimate, because it - -- includes inlined functions called from functions that are compiled - -- as part of an inlined package, but are not themselves called. An - -- accurate computation of just those subprograms that are needed + -- includes inlined subprograms called from subprograms that are + -- declared in 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 compilation unit. @@ -3396,10 +3397,6 @@ package body Inline is -- If the function body is a single expression, replace call with -- expression, else insert block appropriately. - procedure Rewrite_Procedure_Call (N : Node_Id; Blk : Node_Id); - -- If procedure body has no local variables, inline body without - -- creating block, otherwise rewrite call with block. - --------------------- -- Make_Exit_Label -- --------------------- @@ -3784,35 +3781,6 @@ package body Inline is end if; end Rewrite_Function_Call; - ---------------------------- - -- Rewrite_Procedure_Call -- - ---------------------------- - - procedure Rewrite_Procedure_Call (N : Node_Id; Blk : Node_Id) is - HSS : constant Node_Id := Handled_Statement_Sequence (Blk); - - begin - -- If there is a transient scope for N, this will be the scope of the - -- actions for N, and the statements in Blk need to be within this - -- scope. For example, they need to have visibility on the constant - -- declarations created for the formals. - - -- If N needs no transient scope, and if there are no declarations in - -- the inlined body, we can do a little optimization and insert the - -- statements for the body directly after N, and rewrite N to a - -- null statement, instead of rewriting N into a full-blown block - -- statement. - - if not Scope_Is_Transient - and then Is_Empty_List (Declarations (Blk)) - then - Insert_List_After (N, Statements (HSS)); - Rewrite (N, Make_Null_Statement (Loc)); - else - Rewrite (N, Blk); - end if; - end Rewrite_Procedure_Call; - -- Start of processing for Expand_Inlined_Call begin @@ -4077,6 +4045,7 @@ package body Inline is -- Replace call with temporary and create its declaration Temp := Make_Temporary (Loc, 'C'); + Mutate_Ekind (Temp, E_Constant); Set_Is_Internal (Temp); -- For the unconstrained case, the generated temporary has the @@ -4271,7 +4240,7 @@ package body Inline is end; if Ekind (Subp) = E_Procedure then - Rewrite_Procedure_Call (N, Blk); + Rewrite (N, Blk); else Rewrite_Function_Call (N, Blk); @@ -4922,11 +4891,17 @@ package body Inline is and then Ekind (Info.Fin_Scop) = E_Package_Body then Set_In_Package_Body (Spec_Entity (Info.Fin_Scop), True); + Instantiate_Package_Body (Info); + Set_In_Package_Body (Spec_Entity (Info.Fin_Scop), False); + else + Instantiate_Package_Body (Info); end if; - Instantiate_Package_Body (Info); + -- No need to generate cleanups if the main unit is generic - if Present (Info.Fin_Scop) then + if Present (Info.Fin_Scop) + and then not Is_Generic_Unit (Main_Unit_Entity) + then Scop := Info.Fin_Scop; -- If the enclosing finalization scope is dynamic, the instance @@ -4939,12 +4914,6 @@ package body Inline is end if; Add_Scope_To_Clean (Scop); - - -- Reset the In_Package_Body flag if it was set above - - if Ekind (Info.Fin_Scop) = E_Package_Body then - Set_In_Package_Body (Spec_Entity (Info.Fin_Scop), False); - end if; end if; -- For subprogram instances, always instantiate the body @@ -4965,10 +4934,6 @@ package body Inline is Push_Scope (Standard_Standard); To_Clean := New_Elmt_List; - if Is_Generic_Unit (Cunit_Entity (Main_Unit)) then - Start_Generic; - end if; - -- A body instantiation may generate additional instantiations, so -- the following loop must scan to the end of a possibly expanding -- set (that's why we cannot simply use a FOR loop here). We must @@ -5007,16 +4972,10 @@ package body Inline is Pending_Instantiations.Init; end if; - -- We can now complete the cleanup actions of scopes that contain - -- pending instantiations (skipped for generic units, since we - -- never need any cleanups in generic units). + -- Expand the cleanup actions of scopes that contain instantiations - if Expander_Active - and then not Is_Generic_Unit (Main_Unit_Entity) - then + if Expander_Active then Cleanup_Scopes; - elsif Is_Generic_Unit (Cunit_Entity (Main_Unit)) then - End_Generic; end if; Pop_Scope; @@ -5271,6 +5230,7 @@ package body Inline is | Name_Exit_Cases | Name_Postcondition | Name_Precondition + | Name_Program_Exit | Name_Refined_Global | Name_Refined_Depends | Name_Refined_Post |