[multiple changes]

2014-07-31  Javier Miranda  <miranda@adacore.com>

	* debug.adb Remove documentation of -gnatd.k (no longer needed).
	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Code cleanup.
	* inline.ads (Backend_Inlined_Subps): New
	Elist.	(Backend_Not_Inlined_Subps): New Elist.
	(Has_Excluded_Declaration): Declaration previously located in
	* inline.adb (Has_Excluded_Statement): Declaration previously
	located in inline.adb
	* inline.adb (Has_Single_Return): Moved out of
	Build_Body_To_Inline to avoid having duplicated code.
	(Number_Of_Statements): New subprogram.
	(Register_Backend_Inlined_Subprogram): New subprogram.
	(Register_Backend_Not_Inlined_Subprogram): New subprogram.
	(Add_Inlined_Subprogram): Register backend inlined subprograms and
	also register subprograms that cannot be inlined by the backend.
	(Has_Excluded_Declaration): Moved out of Build_Body_To_Inline
	to avoid having duplicated code.  Replace occurrences of
	Debug_Flag_Dot_K by Back_End_Inlining.
	* sem_res.adb (Resolve_Call): Code cleanup.
	* exp_ch6.adb (Expand_Call): Complete previous patch. Replace
	occurrence of Debug_Flag_Dot_K by Back_End_Inlining.
	(List_Inlining_Info): Add listing of subprograms passed to the
	backend and listing of subprograms that cannot be inlined by
	the backend.
	* sem_ch12.adb, sem_ch3.adb Replace occurrences of
	Debug_Flag_Dot_K by Back_End_Inlining.

2014-07-31  Robert Dewar  <dewar@adacore.com>

	* nlists.ads: Minor code fix (remove unwise Inline for
	List_Length).

From-SVN: r213373
This commit is contained in:
Arnaud Charlet 2014-07-31 15:56:11 +02:00
parent 0c9aebea0f
commit 6c26bac268
10 changed files with 622 additions and 516 deletions

View File

@ -1,3 +1,36 @@
2014-07-31 Javier Miranda <miranda@adacore.com>
* debug.adb Remove documentation of -gnatd.k (no longer needed).
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Code cleanup.
* inline.ads (Backend_Inlined_Subps): New
Elist. (Backend_Not_Inlined_Subps): New Elist.
(Has_Excluded_Declaration): Declaration previously located in
* inline.adb (Has_Excluded_Statement): Declaration previously
located in inline.adb
* inline.adb (Has_Single_Return): Moved out of
Build_Body_To_Inline to avoid having duplicated code.
(Number_Of_Statements): New subprogram.
(Register_Backend_Inlined_Subprogram): New subprogram.
(Register_Backend_Not_Inlined_Subprogram): New subprogram.
(Add_Inlined_Subprogram): Register backend inlined subprograms and
also register subprograms that cannot be inlined by the backend.
(Has_Excluded_Declaration): Moved out of Build_Body_To_Inline
to avoid having duplicated code. Replace occurrences of
Debug_Flag_Dot_K by Back_End_Inlining.
* sem_res.adb (Resolve_Call): Code cleanup.
* exp_ch6.adb (Expand_Call): Complete previous patch. Replace
occurrence of Debug_Flag_Dot_K by Back_End_Inlining.
(List_Inlining_Info): Add listing of subprograms passed to the
backend and listing of subprograms that cannot be inlined by
the backend.
* sem_ch12.adb, sem_ch3.adb Replace occurrences of
Debug_Flag_Dot_K by Back_End_Inlining.
2014-07-31 Robert Dewar <dewar@adacore.com>
* nlists.ads: Minor code fix (remove unwise Inline for
List_Length).
2014-07-31 Arnaud Charlet <charlet@adacore.com>
* einfo.adb: Remove VMS specific code.
@ -14,6 +47,7 @@
* gcc-interface/trans.c, gcc-interface/misc.c: Remove references
to VMS. Misc clean ups.
* gcc-interface/Makefile.in (gnatlib-shared-vms): Remove.
2014-07-31 Robert Dewar <dewar@adacore.com>

View File

@ -101,7 +101,7 @@ package body Debug is
-- d.h
-- d.i Ignore Warnings pragmas
-- d.j Generate listing of frontend inlined calls
-- d.k Enable new support for frontend inlining
-- d.k
-- d.l Use Ada 95 semantics for limited function returns
-- d.m For -gnatl, print full source only for main unit
-- d.n Print source file names
@ -533,10 +533,6 @@ package body Debug is
-- to the backend. This is useful to locate skipped calls that must be
-- inlined by the frontend.
-- d.k Enable new semantics of frontend inlining. This is useful to test
-- this new feature in all the platforms. What *is* this new semantics
-- which doesn't seem to be documented anywhere???
-- d.l Use Ada 95 semantics for limited function returns. This may be
-- used to work around the incompatibility introduced by AI-318-2.
-- It is useful only in -gnat05 mode.

View File

@ -3830,15 +3830,14 @@ package body Exp_Ch6 is
return;
end if;
-- Back end inlining: let the back end handle it
-- Handle inlining. No action needed if the subprogram is not inlined
if Back_End_Inlining and then Is_Inlined (Subp) then
Add_Inlined_Body (Subp);
Register_Backend_Call (Call_Node);
if not Is_Inlined (Subp) then
null;
-- Handle inlining (old semantics)
-- Handle frontend inlining
elsif Is_Inlined (Subp) and then not Debug_Flag_Dot_K then
elsif not Back_End_Inlining then
Inlined_Subprogram : declare
Bod : Node_Id;
Must_Inline : Boolean := False;
@ -3924,9 +3923,22 @@ package body Exp_Ch6 is
end if;
end Inlined_Subprogram;
-- Handle inlining (new semantics)
-- Back end inlining: let the back end handle it
elsif Is_Inlined (Subp) then
elsif No (Unit_Declaration_Node (Subp))
or else
Nkind (Unit_Declaration_Node (Subp)) /= N_Subprogram_Declaration
or else
No (Body_To_Inline (Unit_Declaration_Node (Subp)))
then
Add_Inlined_Body (Subp);
Register_Backend_Call (Call_Node);
-- Frontend expansion of supported functions returning unconstrained
-- types
else pragma Assert (Ekind (Subp) = E_Function
and then Returns_Unconstrained_Type (Subp));
declare
Spec : constant Node_Id := Unit_Declaration_Node (Subp);
@ -9720,6 +9732,70 @@ package body Exp_Ch6 is
Next_Elmt (Elmt);
end loop;
end if;
-- Generate listing of subprograms passed to the backend
if Present (Backend_Inlined_Subps)
and then Back_End_Inlining
then
Count := 0;
Elmt := First_Elmt (Backend_Inlined_Subps);
while Present (Elmt) loop
Nod := Node (Elmt);
Count := Count + 1;
if Count = 1 then
Write_Str
("Listing 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;
Next_Elmt (Elmt);
end loop;
end if;
-- Generate listing of subprogram that cannot be inlined by the backend
if Present (Backend_Not_Inlined_Subps)
and then Back_End_Inlining
then
Count := 0;
Elmt := First_Elmt (Backend_Not_Inlined_Subps);
while Present (Elmt) loop
Nod := Node (Elmt);
Count := Count + 1;
if Count = 1 then
Write_Str
("Listing of subprograms that cannot inline 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;
Next_Elmt (Elmt);
end loop;
end if;
end List_Inlining_Info;
end Exp_Ch6;

File diff suppressed because it is too large Load Diff

View File

@ -132,8 +132,16 @@ package Inline is
Table_Name => "Pending_Descriptor");
Inlined_Calls : Elist_Id := No_Elist;
-- List of frontend inlined calls
Backend_Calls : Elist_Id := No_Elist;
-- List of frontend inlined calls and inline calls passed to the backend
-- List of inline calls passed to the backend
Backend_Inlined_Subps : Elist_Id := No_Elist;
-- List of subprograms inlined by the backend
Backend_Not_Inlined_Subps : Elist_Id := No_Elist;
-- List of subprograms that cannot be inlined by the backend
-----------------
-- Subprograms --
@ -231,6 +239,17 @@ package Inline is
-- expressions in the body must be converted to the desired type (which
-- is simply not noted in the tree without inline expansion).
function Has_Excluded_Declaration
(Subp : Entity_Id;
Decls : List_Id) return Boolean;
-- Check for declarations that make inlining not worthwhile inlining Subp
function Has_Excluded_Statement
(Subp : Entity_Id;
Stats : List_Id) return Boolean;
-- Check for statements that make inlining not worthwhile: any tasking
-- statement, nested at any level.
procedure Register_Backend_Call (N : Node_Id);
-- Append N to the list Backend_Calls

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -149,7 +149,6 @@ package Nlists is
-- No_List. (No_List is not considered to be the same as an empty list).
function List_Length (List : List_Id) return Nat;
pragma Inline (List_Length);
-- Returns number of items in the given list. It is an error to call
-- this function with No_List (No_List is not considered to be the same
-- as an empty list).

View File

@ -25,7 +25,6 @@
with Aspects; use Aspects;
with Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
@ -3877,7 +3876,7 @@ package body Sem_Ch12 is
and then Might_Inline_Subp
and then not Is_Actual_Pack
then
if not Debug_Flag_Dot_K
if not Back_End_Inlining
and then Front_End_Inlining
and then (Is_In_Main_Unit (N)
or else In_Main_Context (Current_Scope))
@ -3885,7 +3884,7 @@ package body Sem_Ch12 is
then
Inline_Now := True;
elsif Debug_Flag_Dot_K
elsif Back_End_Inlining
and then Must_Inline_Subp
and then (Is_In_Main_Unit (N)
or else In_Main_Context (Current_Scope))

View File

@ -3514,7 +3514,7 @@ package body Sem_Ch3 is
-- declaration without initializing expression and it has been
-- analyzed (see Expand_Inlined_Call).
if Debug_Flag_Dot_K
if Back_End_Inlining
and then Expander_Active
and then Nkind (E) = N_Function_Call
and then Nkind (Name (E)) in N_Has_Entity

View File

@ -3561,56 +3561,75 @@ package body Sem_Ch6 is
-- mode where we want to expand some calls in place, even with expansion
-- disabled, since the inlining eases formal verification.
-- Old semantics
if not Debug_Flag_Dot_K then
-- If the backend inlining is available then at this stage we only
-- have to mark the subprogram as inlined. The expander will take
-- care of registering it in the table of subprograms inlined by
-- the backend a part of processing calls to it (cf. Expand_Call)
if Present (Spec_Id)
and then Expander_Active
and then Back_End_Inlining
then
Set_Is_Inlined (Spec_Id);
elsif Present (Spec_Id)
and then Expander_Active
and then
(Has_Pragma_Inline_Always (Spec_Id)
or else (Has_Pragma_Inline (Spec_Id) and Front_End_Inlining))
then
Build_Body_To_Inline (N, Spec_Id);
-- In GNATprove mode, inline only when there is a separate subprogram
-- declaration for now, as inlining of subprogram bodies acting as
-- declarations, or subprogram stubs, are not supported by frontend
-- inlining. This inlining should occur after analysis of the body,
-- so that it is known whether the value of SPARK_Mode applicable to
-- the body, which can be defined by a pragma inside the body.
elsif GNATprove_Mode
and then Full_Analysis
and then not Inside_A_Generic
and then Present (Spec_Id)
and then
Nkind (Parent (Parent (Spec_Id))) = N_Subprogram_Declaration
and then Can_Be_Inlined_In_GNATprove_Mode (Spec_Id, Body_Id)
and then not Body_Has_Contract
then
Build_Body_To_Inline (N, Spec_Id);
end if;
-- New semantics (enabled by debug flag gnatd.k for testing)
elsif Expander_Active
if not GNATprove_Mode
and then Expander_Active
and then Serious_Errors_Detected = 0
and then Present (Spec_Id)
and then Has_Pragma_Inline (Spec_Id)
then
Check_And_Build_Body_To_Inline (N, Spec_Id, Body_Id);
-- Legacy implementation (relying on frontend inlining)
if not Back_End_Inlining then
if Has_Pragma_Inline_Always (Spec_Id)
or else (Has_Pragma_Inline (Spec_Id) and Front_End_Inlining)
then
Build_Body_To_Inline (N, Spec_Id);
end if;
-- New implementation (relying on backend inlining). Enabled by
-- debug flag gnatd.z for testing
else
if Has_Pragma_Inline_Always (Spec_Id)
or else Optimization_Level > 0
then
-- Handle function returning an unconstrained type
if Comes_From_Source (Body_Id)
and then Ekind (Spec_Id) = E_Function
and then Returns_Unconstrained_Type (Spec_Id)
then
Check_And_Build_Body_To_Inline (N, Spec_Id, Body_Id);
else
declare
Body_Spec : constant Node_Id := Parent (Body_Id);
Subp_Body : constant Node_Id := Parent (Body_Spec);
Subp_Decl : constant List_Id := Declarations (Subp_Body);
begin
-- Do not pass inlining to the backend if the subprogram
-- has declarations or statements which cannot be inlined
-- by the backend. This check is done here to emit an
-- error instead of the generic warning message reported
-- by the GCC backend (ie. "function might not be
-- inlinable").
if Present (Subp_Decl)
and then Has_Excluded_Declaration (Spec_Id, Subp_Decl)
then
null;
elsif Has_Excluded_Statement
(Spec_Id,
Statements
(Handled_Statement_Sequence (Subp_Body)))
then
null;
-- If the backend inlining is available then at this
-- stage we only have to mark the subprogram as inlined.
-- The expander will take care of registering it in the
-- table of subprograms inlined by the backend a part of
-- processing calls to it (cf. Expand_Call)
else
Set_Is_Inlined (Spec_Id);
end if;
end;
end if;
end if;
end if;
-- In GNATprove mode, inline only when there is a separate subprogram
-- declaration for now, as inlining of subprogram bodies acting as
@ -3627,7 +3646,7 @@ package body Sem_Ch6 is
and then Can_Be_Inlined_In_GNATprove_Mode (Spec_Id, Body_Id)
and then not Body_Has_Contract
then
Check_And_Build_Body_To_Inline (N, Spec_Id, Body_Id);
Build_Body_To_Inline (N, Spec_Id);
end if;
-- Ada 2005 (AI-262): In library subprogram bodies, after the analysis

View File

@ -5935,18 +5935,9 @@ package body Sem_Res is
-- check for this by traversing the type in Check_Initialization_Call.
if Is_Inlined (Nam)
and then Has_Pragma_Inline_Always (Nam)
and then Nkind (Unit_Declaration_Node (Nam)) = N_Subprogram_Declaration
and then Present (Body_To_Inline (Unit_Declaration_Node (Nam)))
and then not Debug_Flag_Dot_K
then
null;
elsif Is_Inlined (Nam)
and then Has_Pragma_Inline (Nam)
and then Nkind (Unit_Declaration_Node (Nam)) = N_Subprogram_Declaration
and then Present (Body_To_Inline (Unit_Declaration_Node (Nam)))
and then Debug_Flag_Dot_K
then
null;