From: Arnaud Charlet Date: Fri, 1 Aug 2008 08:19:04 +0000 (+0200) Subject: sem_ch12.ads (Need_Subprogram_Instance_Body): new function... X-Git-Tag: releases/gcc-4.4.0~3506 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfb02ad18bf4064d5358fe9b4c3e9d07b373332c;p=thirdparty%2Fgcc.git sem_ch12.ads (Need_Subprogram_Instance_Body): new function... 2008-08-01 Ed Schonberg * sem_ch12.ads (Need_Subprogram_Instance_Body): new function, to create a pending instantiation for the body of a subprogram that is to be inlined. * sem_ch12.adb: (Analyze_Subprogram_Instantiation): use Need_Subprogram_Instance_Body. * sem_prag.adb (Make_Inline): If the pragma applies to an instance, create a pending instance for its body, so that calls to the subprogram can be inlined by the back-end. From-SVN: r138480 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 630f30f6c671..3eb081d0278a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,21 @@ +2008-08-01 Ed Schonberg + + * sem_ch12.ads (Need_Subprogram_Instance_Body): new function, to create + a pending instantiation for the body of a subprogram that is to be + inlined. + + * sem_ch12.adb: + (Analyze_Subprogram_Instantiation): use Need_Subprogram_Instance_Body. + + * sem_prag.adb (Make_Inline): If the pragma applies to an instance, + create a pending instance for its body, so that calls to the subprogram + can be inlined by the back-end. + +2008-08-01 Jose Ruiz + + * gnat_ugn.texi: Document the RTX run times (rts-rtx-rtss and + rts-rtx-w32). + 2008-08-01 Robert Dewar * scng.adb (Error_Illegal_Wide_Character): Bump scan pointer diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index b2e7d8524877..48011e71ade7 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -3753,6 +3753,38 @@ package body Sem_Ch12 is Analyze_Subprogram_Instantiation (N, E_Procedure); end Analyze_Procedure_Instantiation; + ----------------------------------- + -- Need_Subprogram_Instance_Body -- + ----------------------------------- + + function Need_Subprogram_Instance_Body + (N : Node_Id; + Subp : Entity_Id) return Boolean + is + begin + if (Is_In_Main_Unit (N) + or else Is_Inlined (Subp) + or else Is_Inlined (Alias (Subp))) + and then (Operating_Mode = Generate_Code + or else (Operating_Mode = Check_Semantics + and then ASIS_Mode)) + and then (Expander_Active or else ASIS_Mode) + and then not ABE_Is_Certain (N) + and then not Is_Eliminated (Subp) + then + Pending_Instantiations.Append + ((Inst_Node => N, + Act_Decl => Unit_Declaration_Node (Subp), + Expander_Status => Expander_Active, + Current_Sem_Unit => Current_Sem_Unit, + Scope_Suppress => Scope_Suppress, + Local_Suppress_Stack_Top => Local_Suppress_Stack_Top)); + return True; + else + return False; + end if; + end Need_Subprogram_Instance_Body; + -------------------------------------- -- Analyze_Subprogram_Instantiation -- -------------------------------------- @@ -4144,22 +4176,7 @@ package body Sem_Ch12 is -- If the context requires a full instantiation, mark node for -- subsequent construction of the body. - if (Is_In_Main_Unit (N) - or else Is_Inlined (Act_Decl_Id)) - and then (Operating_Mode = Generate_Code - or else (Operating_Mode = Check_Semantics - and then ASIS_Mode)) - and then (Expander_Active or else ASIS_Mode) - and then not ABE_Is_Certain (N) - and then not Is_Eliminated (Act_Decl_Id) - then - Pending_Instantiations.Append - ((Inst_Node => N, - Act_Decl => Act_Decl, - Expander_Status => Expander_Active, - Current_Sem_Unit => Current_Sem_Unit, - Scope_Suppress => Scope_Suppress, - Local_Suppress_Stack_Top => Local_Suppress_Stack_Top)); + if Need_Subprogram_Instance_Body (N, Act_Decl_Id) then Check_Forward_Instantiation (Gen_Decl); @@ -8699,6 +8716,13 @@ package body Sem_Ch12 is begin Gen_Body_Id := Corresponding_Body (Gen_Decl); + -- Subprogram body may have been created already because of + -- an inline pragma. + + if Present (Corresponding_Body (Act_Decl)) then + return; + end if; + Expander_Mode_Save_And_Set (Body_Info.Expander_Status); -- Re-establish the state of information on which checks are suppressed. diff --git a/gcc/ada/sem_ch12.ads b/gcc/ada/sem_ch12.ads index 7ebb2e88342e..c3b34173e18e 100644 --- a/gcc/ada/sem_ch12.ads +++ b/gcc/ada/sem_ch12.ads @@ -106,6 +106,16 @@ package Sem_Ch12 is -- function and procedure instances. The flag Body_Optional has the -- same purpose as described for Instantiate_Package_Body. + function Need_Subprogram_Instance_Body + (N : Node_Id; + Subp : Entity_Id) return Boolean; + + -- If a subprogram instance is inlined, indicate that the body of it + -- must be created, to be used in inlined calls by the back-end. The + -- subprogram may be inlined because the generic itself carries the + -- pragma, or because a pragma appears for the instance in the scope. + -- of the instance. + procedure Save_Global_References (N : Node_Id); -- Traverse the original generic unit, and capture all references to -- entities that are defined outside of the generic in the analyzed diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 803f054ce4f1..b54cda616cf6 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -53,6 +53,7 @@ with Sem_Aux; use Sem_Aux; with Sem_Ch3; use Sem_Ch3; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; +with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Dist; use Sem_Dist; with Sem_Elim; use Sem_Elim; @@ -3752,6 +3753,22 @@ package body Sem_Prag is and then Present (Corresponding_Body (Decl)) then Set_Inline_Flags (Corresponding_Body (Decl)); + + elsif Is_Generic_Instance (Subp) then + + -- Indicate that the body needs to be created for + -- inlining subsequent calls. The instantiation + -- node follows the declaration of the wrapper + -- package created for it. + + if Scope (Subp) /= Standard_Standard + and then + Need_Subprogram_Instance_Body + (Next (Unit_Declaration_Node (Scope (Alias (Subp)))), + Subp) + then + null; + end if; end if; end if;