Commit cfb02ad1 by Arnaud Charlet

sem_ch12.ads (Need_Subprogram_Instance_Body): new function...

2008-08-01  Ed Schonberg  <schonberg@adacore.com>

	* 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
parent 47ad7893
2008-08-01 Ed Schonberg <schonberg@adacore.com>
* 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 <ruiz@adacore.com>
* gnat_ugn.texi: Document the RTX run times (rts-rtx-rtss and
rts-rtx-w32).
2008-08-01 Robert Dewar <dewar@adacore.com>
* scng.adb (Error_Illegal_Wide_Character): Bump scan pointer
......@@ -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.
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment