Commit 92c7734d by Hristian Kirtchev Committed by Pierre-Marie de Rodat

[Ada] New algorithm for Elaboration order v4.0

This patch introduces several changes to the new elaboration order
mechanism:

   * The concept of "strong" and "weak" edges is introduced. Strong
     edges are the byproduct of language-defined relations between
     units, such as with clauses. Weak edges are the byproduct of
     specilative invocations at elaboration time, which may or may not
     take place depending on control flow.

   * The elaboration order algorithm has been heavily modified to make
     use of the strong and weak edges, and operate on units compiled
     with different elaboration models.

   * The elaboration order algorithm employs the following logic:

        - Maintain two sets of vertices, one for all elaborable
          vertices, and one for all waiting vertices.

        - Pick the best elaborable vertex, and elaborate its component.

        - If no such elaborable vertex is available, pick the best
          weakly elaborable vertex whose unit has been compiled with the
          dynamic model, and elaborate its component.

        - If no such weakly elaborable vertex is available, then either
          all vertices were already elaborated, or the graph contains a
          cycle.

     The elaboration of a component employs the same logic, with an
     added step where all successors of some predecessor currently being
     elaborated are notified that they have one fewer predecessor to
     wait on. This may cause certain successors to become elaborable, in
     which case they are moved from the set of waiting vertices to the
     set of elaborable vertices.

   * Three new GNATbind debug switches are introduced, -d_a, -d_b, and
     -d_e, to eliminate the effects of pragmas Elaborate_All,
     Elaborate_Body, and Elaborate respectively.

   * The section on terminology is updated to include new entries.

2019-07-08  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* bindo.adb: Update the section on terminology to include new
	concepts.  Update the section on switches to include new
	entries.
	* bindo.ads: Add type Precedence_Kind.
	* bindo-builders.adb: Add with and use clauses for Debug and
	Bindo.Validators.  Add use clauses for
	Bindo.Validators.Invocation_Graph_Validators and
	Bindo.Validators.Library_Graph_Validators.
	(Build_Invocation_Graph): Validate the graph immediately after
	it was built.
	(Build_Library_Graph): Update the parameter profile. The
	creation of the graph is now elaboration model-agnostic.
	Validate the graph immediately after it was built.
	(Create_With_Edge): Create regular with edges for Elaborate and
	Elaborate_All edges when the appropriate debug switches are in
	effect.
	* bindo-builders.ads (Build_Library_Graph): Update the parameter
	profile.
	* bindo-diagnostics.adb (Diagnose_Cycle): Track the presence of
	an Elaborate_All edge throughout the inspection of the cycle's
	edges.
	(Output_Dynamic_Model_Suggestions): Output the suggestion only
	when the cycle contains at least one weak edge where the
	successor was statically elaborated.
	(Output_Elaborate_Body_Transition, Output_Forced_Transition,
	Output_With_Transition): Update the assertions.
	* bindo-elaborators.adb: Remove use clauses for
	Bindo.Validators.Invocation_Graph_Validators and
	Bindo.Validators.Library_Graph_Validators.  Remove strings
	Add_To_All_Candidates_Msg and Add_To_Comp_Candidates_Msg.
	Remove type String_Ptr.
	(Add_Vertex, Add_Vertex_If_Elaborable, Create_All_Candidates_Set
	Create_Component_Candidates_Set): Remove.
	(Create_Component_Vertex_Sets, Create_Vertex_Sets): New routine.
	(Elaborate_Component): Update the parameter profile and the
	comment on usage.  Reimplement the elaboration of a component.
	The algorithm will now attempt to elaborate as many vertices
	possible. If this is not possible, and a weakly elaborable
	vertex is available use unit was compiled using the dynamic
	model, the algorithm will elaborate it.
	(Elaborate_Library_Graph): Reimplement the elaboration of the
	graph. The algorithm will now attempt to elaborate as many
	vertices along with their components as possible. If this is not
	possible, and a weakly elaborable vertex is available use unit
	was compiled using the dynamic model, the algorithm will
	elaborate it along with its component.
	(Elaborate_Units): Merge with the functionality of
	Elaborate_Units_Common.
	(Elaborate_Units_Common, Elaborate_Units_Dynamic,
	Elaborate_Units_Static): Remove.
	(Elaborate_Vertex): Update the parameter profile and the comment
	on usage.  Reimplemented.
	(Find_Best_Candidate): Remove.
	(Find_Best_Elaborable_Vertex, Find_Best_Vertex,
	Find_Best_Weakly_Elaborable_Vertex, Has_Elaborable_Body,
	Insert_Elaborable_Successor, Insert_Vertex): New routines.
	(Is_Better_Candidate): Remove.
	(Is_Better_Elaborable_Vertex,
	Is_Better_Weakly_Elaborable_Vertex,
	Is_Suitable_Elaborable_Vertex,
	Is_Suitable_Weakly_Elaborable_Vertex): New routines.
	(Trace_Candidate_Vertices): Remove.
	(Trace_Component): Output the number of strong and weak
	predecessors.
	(Trace_Unelaborated_Vertices): Remove.
	(Trace_Vertex): Output the number of strong and weak
	predecessors.
	(Trace_Vertices): New routine.
	(Update_Successor, Update_Successors): Update the parameter
	profile and the comment on usage.
	* bindo-graphs.adb: Remove type Precedence_Kind.
	(Add_Edge_With_Return): Update the increment of pending
	predecessors.
	(Add_Vertex): Provide default values for strong and weak
	predecessors.
	(Complementary_Vertex): Move the initial declaration to the
	spec. Update the parameter profile and the comment on usage.
	(Contains_Weak_Static_Successor): New routine.
	(Create): Update the parameter profile. The creation of the
	graph is now elaboration model-agnostic.
	(Decrement_Pending_Predecessors): Update the parameter profile
	and the comment on usage. Reimplemented.
	(Delete_Edge): Update the decrement of pending predecesors.
	(Has_Elaborate_Body): Do not treat a vertex as being subject to
	Elaborate_Body when a debug switch is in effect.
	(Increment_Pending_Predecessors): Update the parameter profile
	and the comment on usage. Reimplemented.
	(Is_Elaborable_Component): Reimplemented.
	(Is_Elaborable_Vertex): Move the initial declaration to the
	spec.  Reimplemented.
	(Is_Elaborate_Body_Pair): New routine.
	(Is_Dynamically_Elaborated): Update the parameter profile.
	Reimplemented.
	(Is_Weakly_Elaborable_Vertex): New routine.
	(Pending_Predecessors): Removed.
	(Pending_Predecessors_For_Elaboration,
	Pending_Strong_Predecessors, Pending_Weak_Predecessors,
	Update_Pending_Predecessors): New routines.
	(Update_Pending_Predecessors_Of_Components): Update the
	increment of pending predecessors.
	* bindo-graphs.ads: Update the components of type
	Component_Attributes.  Update the components of type
	Library_Graph_Attributes.  Update the components of type
	Library_Graph_Vertex_Attributes.  Update the initialization of
	No_Component_Attributes.  Update the initialization of
	No_Library_Graph_Vertex_Attributes.
	(Complementary_Vertex, Contains_Weak_Static_Successor): New
	routines.
	(Create): Update the parameter profile and the comment on usage.
	(Decrement_Pending_Predecessors, Is_Dynamically_Elaborated):
	Update the parameter profile and the comment on usage.
	(Is_Elaborate_Body_Pair, Is_Weakly_Elaborable_Vertex): New
	routines.
	(Pending_Predecessors): Removed.
	(Pending_Predecessors_For_Elaboration,
	Pending_Strong_Predecessors, Pending_Weak_Predecessors): New
	routines.
	* bindo-writers.adb (Write_Components): Moved from the spec.
	(Write_Component): Output the strong and weak predecessors.
	(Write_Library_Graph): Output the components as part of the
	graph.
	(Write_Library_Graph_Vertex): Output the strong and weak
	predecessors.
	* bindo-writers.ads (Write_Components): Moved to the body.
	* debug.adb: Add and document new GNATbind switches -d_a, -d_b,
	-d_e.
	* bindo-validators.adb: Minor reformattings.

From-SVN: r273209
parent 79ee9e32
2019-07-08 Hristian Kirtchev <kirtchev@adacore.com>
* bindo.adb: Update the section on terminology to include new
concepts. Update the section on switches to include new
entries.
* bindo.ads: Add type Precedence_Kind.
* bindo-builders.adb: Add with and use clauses for Debug and
Bindo.Validators. Add use clauses for
Bindo.Validators.Invocation_Graph_Validators and
Bindo.Validators.Library_Graph_Validators.
(Build_Invocation_Graph): Validate the graph immediately after
it was built.
(Build_Library_Graph): Update the parameter profile. The
creation of the graph is now elaboration model-agnostic.
Validate the graph immediately after it was built.
(Create_With_Edge): Create regular with edges for Elaborate and
Elaborate_All edges when the appropriate debug switches are in
effect.
* bindo-builders.ads (Build_Library_Graph): Update the parameter
profile.
* bindo-diagnostics.adb (Diagnose_Cycle): Track the presence of
an Elaborate_All edge throughout the inspection of the cycle's
edges.
(Output_Dynamic_Model_Suggestions): Output the suggestion only
when the cycle contains at least one weak edge where the
successor was statically elaborated.
(Output_Elaborate_Body_Transition, Output_Forced_Transition,
Output_With_Transition): Update the assertions.
* bindo-elaborators.adb: Remove use clauses for
Bindo.Validators.Invocation_Graph_Validators and
Bindo.Validators.Library_Graph_Validators. Remove strings
Add_To_All_Candidates_Msg and Add_To_Comp_Candidates_Msg.
Remove type String_Ptr.
(Add_Vertex, Add_Vertex_If_Elaborable, Create_All_Candidates_Set
Create_Component_Candidates_Set): Remove.
(Create_Component_Vertex_Sets, Create_Vertex_Sets): New routine.
(Elaborate_Component): Update the parameter profile and the
comment on usage. Reimplement the elaboration of a component.
The algorithm will now attempt to elaborate as many vertices
possible. If this is not possible, and a weakly elaborable
vertex is available use unit was compiled using the dynamic
model, the algorithm will elaborate it.
(Elaborate_Library_Graph): Reimplement the elaboration of the
graph. The algorithm will now attempt to elaborate as many
vertices along with their components as possible. If this is not
possible, and a weakly elaborable vertex is available use unit
was compiled using the dynamic model, the algorithm will
elaborate it along with its component.
(Elaborate_Units): Merge with the functionality of
Elaborate_Units_Common.
(Elaborate_Units_Common, Elaborate_Units_Dynamic,
Elaborate_Units_Static): Remove.
(Elaborate_Vertex): Update the parameter profile and the comment
on usage. Reimplemented.
(Find_Best_Candidate): Remove.
(Find_Best_Elaborable_Vertex, Find_Best_Vertex,
Find_Best_Weakly_Elaborable_Vertex, Has_Elaborable_Body,
Insert_Elaborable_Successor, Insert_Vertex): New routines.
(Is_Better_Candidate): Remove.
(Is_Better_Elaborable_Vertex,
Is_Better_Weakly_Elaborable_Vertex,
Is_Suitable_Elaborable_Vertex,
Is_Suitable_Weakly_Elaborable_Vertex): New routines.
(Trace_Candidate_Vertices): Remove.
(Trace_Component): Output the number of strong and weak
predecessors.
(Trace_Unelaborated_Vertices): Remove.
(Trace_Vertex): Output the number of strong and weak
predecessors.
(Trace_Vertices): New routine.
(Update_Successor, Update_Successors): Update the parameter
profile and the comment on usage.
* bindo-graphs.adb: Remove type Precedence_Kind.
(Add_Edge_With_Return): Update the increment of pending
predecessors.
(Add_Vertex): Provide default values for strong and weak
predecessors.
(Complementary_Vertex): Move the initial declaration to the
spec. Update the parameter profile and the comment on usage.
(Contains_Weak_Static_Successor): New routine.
(Create): Update the parameter profile. The creation of the
graph is now elaboration model-agnostic.
(Decrement_Pending_Predecessors): Update the parameter profile
and the comment on usage. Reimplemented.
(Delete_Edge): Update the decrement of pending predecesors.
(Has_Elaborate_Body): Do not treat a vertex as being subject to
Elaborate_Body when a debug switch is in effect.
(Increment_Pending_Predecessors): Update the parameter profile
and the comment on usage. Reimplemented.
(Is_Elaborable_Component): Reimplemented.
(Is_Elaborable_Vertex): Move the initial declaration to the
spec. Reimplemented.
(Is_Elaborate_Body_Pair): New routine.
(Is_Dynamically_Elaborated): Update the parameter profile.
Reimplemented.
(Is_Weakly_Elaborable_Vertex): New routine.
(Pending_Predecessors): Removed.
(Pending_Predecessors_For_Elaboration,
Pending_Strong_Predecessors, Pending_Weak_Predecessors,
Update_Pending_Predecessors): New routines.
(Update_Pending_Predecessors_Of_Components): Update the
increment of pending predecessors.
* bindo-graphs.ads: Update the components of type
Component_Attributes. Update the components of type
Library_Graph_Attributes. Update the components of type
Library_Graph_Vertex_Attributes. Update the initialization of
No_Component_Attributes. Update the initialization of
No_Library_Graph_Vertex_Attributes.
(Complementary_Vertex, Contains_Weak_Static_Successor): New
routines.
(Create): Update the parameter profile and the comment on usage.
(Decrement_Pending_Predecessors, Is_Dynamically_Elaborated):
Update the parameter profile and the comment on usage.
(Is_Elaborate_Body_Pair, Is_Weakly_Elaborable_Vertex): New
routines.
(Pending_Predecessors): Removed.
(Pending_Predecessors_For_Elaboration,
Pending_Strong_Predecessors, Pending_Weak_Predecessors): New
routines.
* bindo-writers.adb (Write_Components): Moved from the spec.
(Write_Component): Output the strong and weak predecessors.
(Write_Library_Graph): Output the components as part of the
graph.
(Write_Library_Graph_Vertex): Output the strong and weak
predecessors.
* bindo-writers.ads (Write_Components): Moved to the body.
* debug.adb: Add and document new GNATbind switches -d_a, -d_b,
-d_e.
* bindo-validators.adb: Minor reformattings.
2019-07-08 Bob Duff <duff@adacore.com> 2019-07-08 Bob Duff <duff@adacore.com>
* libgnat/g-sercom.ads, libgnat/g-sercom__linux.adb (Data_Rate): * libgnat/g-sercom.ads, libgnat/g-sercom__linux.adb (Data_Rate):
......
...@@ -25,12 +25,18 @@ ...@@ -25,12 +25,18 @@
with Binderr; use Binderr; with Binderr; use Binderr;
with Butil; use Butil; with Butil; use Butil;
with Debug; use Debug;
with Opt; use Opt; with Opt; use Opt;
with Output; use Output; with Output; use Output;
with Types; use Types; with Types; use Types;
with Bindo.Units; use Bindo.Units; with Bindo.Units; use Bindo.Units;
with Bindo.Validators;
use Bindo.Validators;
use Bindo.Validators.Invocation_Graph_Validators;
use Bindo.Validators.Library_Graph_Validators;
with GNAT; use GNAT; with GNAT; use GNAT;
with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables; with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
...@@ -104,6 +110,8 @@ package body Bindo.Builders is ...@@ -104,6 +110,8 @@ package body Bindo.Builders is
For_Each_Elaborable_Unit (Create_Vertices'Access); For_Each_Elaborable_Unit (Create_Vertices'Access);
For_Each_Elaborable_Unit (Create_Edges'Access); For_Each_Elaborable_Unit (Create_Edges'Access);
Validate_Invocation_Graph (Inv_Graph);
return Inv_Graph; return Inv_Graph;
end Build_Invocation_Graph; end Build_Invocation_Graph;
...@@ -365,24 +373,22 @@ package body Bindo.Builders is ...@@ -365,24 +373,22 @@ package body Bindo.Builders is
-- Build_Library_Graph -- -- Build_Library_Graph --
------------------------- -------------------------
function Build_Library_Graph function Build_Library_Graph return Library_Graph is
(Dynamically_Elaborated : Boolean) return Library_Graph
is
begin begin
-- Prepare the global data -- Prepare the global data
Lib_Graph := Lib_Graph :=
Create Create
(Initial_Vertices => Number_Of_Elaborable_Units, (Initial_Vertices => Number_Of_Elaborable_Units,
Initial_Edges => Number_Of_Elaborable_Units, Initial_Edges => Number_Of_Elaborable_Units);
Dynamically_Elaborated => Dynamically_Elaborated);
For_Each_Elaborable_Unit (Create_Vertex'Access); For_Each_Elaborable_Unit (Create_Vertex'Access);
For_Each_Elaborable_Unit (Create_Spec_And_Body_Edge'Access); For_Each_Elaborable_Unit (Create_Spec_And_Body_Edge'Access);
For_Each_Elaborable_Unit (Create_With_Edges'Access); For_Each_Elaborable_Unit (Create_With_Edges'Access);
Create_Forced_Edges; Create_Forced_Edges;
Validate_Library_Graph (Lib_Graph);
return Lib_Graph; return Lib_Graph;
end Build_Library_Graph; end Build_Library_Graph;
...@@ -549,9 +555,13 @@ package body Bindo.Builders is ...@@ -549,9 +555,13 @@ package body Bindo.Builders is
Withed_Vertex := Corresponding_Vertex (Lib_Graph, Withed_U_Id); Withed_Vertex := Corresponding_Vertex (Lib_Graph, Withed_U_Id);
-- The with comes with pragma Elaborate -- The with comes with pragma Elaborate. Treat the edge as a with
-- edge when switch -d_e (ignore the effects of pragma Elaborate)
-- is in effect.
if Withed_Rec.Elaborate then if Withed_Rec.Elaborate
and then not Debug_Flag_Underscore_E
then
Kind := Elaborate_Edge; Kind := Elaborate_Edge;
-- The withed unit is a spec with a completing body. Add an edge -- The withed unit is a spec with a completing body. Add an edge
...@@ -568,9 +578,13 @@ package body Bindo.Builders is ...@@ -568,9 +578,13 @@ package body Bindo.Builders is
Kind => Kind); Kind => Kind);
end if; end if;
-- The with comes with pragma Elaborate_All -- The with comes with pragma Elaborate_All. Treat the edge as a with
-- edge when switch -d_a (ignore the effects of pragma Elaborate_All)
-- is in effect.
elsif Withed_Rec.Elaborate_All then elsif Withed_Rec.Elaborate_All
and then not Debug_Flag_Underscore_A
then
Kind := Elaborate_All_Edge; Kind := Elaborate_All_Edge;
-- Otherwise this is a regular with -- Otherwise this is a regular with
......
...@@ -56,11 +56,9 @@ package Bindo.Builders is ...@@ -56,11 +56,9 @@ package Bindo.Builders is
---------------------------- ----------------------------
package Library_Graph_Builders is package Library_Graph_Builders is
function Build_Library_Graph function Build_Library_Graph return Library_Graph;
(Dynamically_Elaborated : Boolean) return Library_Graph;
-- Return a new library graph that reflects the dependencies between -- Return a new library graph that reflects the dependencies between
-- all units of the bind. Flag Dynamically_Elaborated must be set when -- all units of the bind.
-- the main library unit was compiled using the dynamic model.
end Library_Graph_Builders; end Library_Graph_Builders;
......
...@@ -285,9 +285,9 @@ package body Bindo.Diagnostics is ...@@ -285,9 +285,9 @@ package body Bindo.Diagnostics is
end loop; end loop;
end Diagnose_All_Cycles; end Diagnose_All_Cycles;
-------------------------- ----------------------------
-- Diagnose_Circularities -- -- Diagnose_Circularities --
-------------------------- ----------------------------
procedure Diagnose_Circularities procedure Diagnose_Circularities
(Inv_Graph : Invocation_Graph; (Inv_Graph : Invocation_Graph;
...@@ -374,6 +374,12 @@ package body Bindo.Diagnostics is ...@@ -374,6 +374,12 @@ package body Bindo.Diagnostics is
-- taking into account the predecessors and successors involved, as -- taking into account the predecessors and successors involved, as
-- well as the nature of the edge. -- well as the nature of the edge.
Elaborate_All_Active :=
Elaborate_All_Active
or else Is_Elaborate_All_Edge
(G => Lib_Graph,
Edge => Current_Edge);
Output_Transition Output_Transition
(Inv_Graph => Inv_Graph, (Inv_Graph => Inv_Graph,
Lib_Graph => Lib_Graph, Lib_Graph => Lib_Graph,
...@@ -533,12 +539,12 @@ package body Bindo.Diagnostics is ...@@ -533,12 +539,12 @@ package body Bindo.Diagnostics is
pragma Assert (Present (G)); pragma Assert (Present (G));
pragma Assert (Present (Cycle)); pragma Assert (Present (Cycle));
-- The cycle contains at least one invocation edge and the main library -- The cycle contains at least one invocation edge where the successor
-- unit was compiled with the static model. Using the dynamic model may -- was statically elaborated. Using the dynamic model may eliminate an
-- eliminate the invocation edge, and thus the cycle. -- invocation edge, and thus the cycle.
if Invocation_Edge_Count (G, Cycle) > 0 if Invocation_Edge_Count (G, Cycle) > 0
and then not Is_Dynamically_Elaborated (G) and then Contains_Weak_Static_Successor (G, Cycle)
then then
Error_Msg_Info Error_Msg_Info
(" use the dynamic elaboration model (compiler switch -gnatE)"); (" use the dynamic elaboration model (compiler switch -gnatE)");
...@@ -703,10 +709,11 @@ package body Bindo.Diagnostics is ...@@ -703,10 +709,11 @@ package body Bindo.Diagnostics is
-- Expected_Destination -- Expected_Destination
else else
pragma Assert (Is_Spec_With_Body (G, Actual_Destination));
pragma Assert (Is_Body_With_Spec (G, Expected_Destination));
pragma Assert pragma Assert
(Proper_Body (G, Actual_Destination) = Expected_Destination); (Is_Elaborate_Body_Pair
(G => G,
Spec_Vertex => Actual_Destination,
Body_Vertex => Expected_Destination));
Error_Msg_Unit_1 := Name (G, Source); Error_Msg_Unit_1 := Name (G, Source);
Error_Msg_Unit_2 := Name (G, Actual_Destination); Error_Msg_Unit_2 := Name (G, Actual_Destination);
...@@ -922,13 +929,11 @@ package body Bindo.Diagnostics is ...@@ -922,13 +929,11 @@ package body Bindo.Diagnostics is
-- Expected_Destination -- Expected_Destination
else else
pragma Assert (Is_Spec_With_Body (G, Actual_Destination));
pragma Assert (Is_Spec_With_Elaborate_Body (G, Actual_Destination));
pragma Assert (Is_Body_With_Spec (G, Expected_Destination));
pragma Assert
(Is_Body_Of_Spec_With_Elaborate_Body (G, Expected_Destination));
pragma Assert pragma Assert
(Proper_Body (G, Actual_Destination) = Expected_Destination); (Is_Elaborate_Body_Pair
(G => G,
Spec_Vertex => Actual_Destination,
Body_Vertex => Expected_Destination));
Error_Msg_Unit_1 := Name (G, Source); Error_Msg_Unit_1 := Name (G, Source);
Error_Msg_Unit_2 := Name (G, Actual_Destination); Error_Msg_Unit_2 := Name (G, Actual_Destination);
...@@ -1392,13 +1397,11 @@ package body Bindo.Diagnostics is ...@@ -1392,13 +1397,11 @@ package body Bindo.Diagnostics is
-- Expected_Destination -- Expected_Destination
else else
pragma Assert (Is_Spec_With_Body (G, Actual_Destination));
pragma Assert (Is_Spec_With_Elaborate_Body (G, Actual_Destination));
pragma Assert (Is_Body_With_Spec (G, Expected_Destination));
pragma Assert
(Is_Body_Of_Spec_With_Elaborate_Body (G, Expected_Destination));
pragma Assert pragma Assert
(Proper_Body (G, Actual_Destination) = Expected_Destination); (Is_Elaborate_Body_Pair
(G => G,
Spec_Vertex => Actual_Destination,
Body_Vertex => Expected_Destination));
Error_Msg_Unit_1 := Name (G, Source); Error_Msg_Unit_1 := Name (G, Source);
Error_Msg_Unit_2 := Name (G, Actual_Destination); Error_Msg_Unit_2 := Name (G, Actual_Destination);
......
...@@ -140,7 +140,7 @@ package body Bindo.Validators is ...@@ -140,7 +140,7 @@ package body Bindo.Validators is
Edges := LGE_Sets.Create (Length (G, Cycle)); Edges := LGE_Sets.Create (Length (G, Cycle));
-- Inspect the edges of the cucle, trying to catch duplicates -- Inspect the edges of the cycle, trying to catch duplicates
Iter := Iterate_Edges_Of_Cycle (G, Cycle); Iter := Iterate_Edges_Of_Cycle (G, Cycle);
while Has_Next (Iter) loop while Has_Next (Iter) loop
...@@ -155,7 +155,7 @@ package body Bindo.Validators is ...@@ -155,7 +155,7 @@ package body Bindo.Validators is
Write_Str (" library graph edge (LGE_Id_"); Write_Str (" library graph edge (LGE_Id_");
Write_Int (Int (Edge)); Write_Int (Int (Edge));
Write_Str (") is repeaded in cycle (LGC_Id_"); Write_Str (") is repeated in cycle (LGC_Id_");
Write_Int (Int (Cycle)); Write_Int (Int (Cycle));
Write_Str (")"); Write_Str (")");
Write_Eol; Write_Eol;
...@@ -421,7 +421,7 @@ package body Bindo.Validators is ...@@ -421,7 +421,7 @@ package body Bindo.Validators is
(G : Invocation_Graph; (G : Invocation_Graph;
Vertex : Invocation_Graph_Vertex_Id); Vertex : Invocation_Graph_Vertex_Id);
pragma Inline (Validate_Invocation_Graph_Vertex); pragma Inline (Validate_Invocation_Graph_Vertex);
-- Verify that the attributes of vertex Vertex of inbocation graph G are -- Verify that the attributes of vertex Vertex of invocation graph G are
-- properly set. -- properly set.
procedure Validate_Invocation_Graph_Vertices (G : Invocation_Graph); procedure Validate_Invocation_Graph_Vertices (G : Invocation_Graph);
...@@ -468,7 +468,7 @@ package body Bindo.Validators is ...@@ -468,7 +468,7 @@ package body Bindo.Validators is
if not Present (Edge) then if not Present (Edge) then
Write_Error (Msg, Has_Invalid_Data); Write_Error (Msg, Has_Invalid_Data);
Write_Str (" emply invocation graph edge"); Write_Str (" empty invocation graph edge");
Write_Eol; Write_Eol;
Write_Eol; Write_Eol;
return; return;
...@@ -530,7 +530,7 @@ package body Bindo.Validators is ...@@ -530,7 +530,7 @@ package body Bindo.Validators is
if not Present (Vertex) then if not Present (Vertex) then
Write_Error (Msg, Has_Invalid_Data); Write_Error (Msg, Has_Invalid_Data);
Write_Str (" emply invocation graph vertex"); Write_Str (" empty invocation graph vertex");
Write_Eol; Write_Eol;
Write_Eol; Write_Eol;
return; return;
...@@ -662,7 +662,7 @@ package body Bindo.Validators is ...@@ -662,7 +662,7 @@ package body Bindo.Validators is
if not Present (Edge) then if not Present (Edge) then
Write_Error (Msg, Has_Invalid_Data); Write_Error (Msg, Has_Invalid_Data);
Write_Str (" emply library graph edge"); Write_Str (" empty library graph edge");
Write_Eol; Write_Eol;
Write_Eol; Write_Eol;
return; return;
......
...@@ -1025,6 +1025,10 @@ package body Bindo.Writers is ...@@ -1025,6 +1025,10 @@ package body Bindo.Writers is
-- Write all vertices of component Comp of library graph G to standard -- Write all vertices of component Comp of library graph G to standard
-- output. -- output.
procedure Write_Components (G : Library_Graph);
pragma Inline (Write_Component);
-- Write all components of library graph G to standard output
procedure Write_Edges_To_Successors procedure Write_Edges_To_Successors
(G : Library_Graph; (G : Library_Graph;
Vertex : Library_Graph_Vertex_Id); Vertex : Library_Graph_Vertex_Id);
...@@ -1089,8 +1093,12 @@ package body Bindo.Writers is ...@@ -1089,8 +1093,12 @@ package body Bindo.Writers is
Write_Str (")"); Write_Str (")");
Write_Eol; Write_Eol;
Write_Str (" Pending_Predecessors = "); Write_Str (" Pending_Strong_Predecessors = ");
Write_Int (Int (Pending_Predecessors (G, Comp))); Write_Int (Int (Pending_Strong_Predecessors (G, Comp)));
Write_Eol;
Write_Str (" Pending_Weak_Predecessors = ");
Write_Int (Int (Pending_Weak_Predecessors (G, Comp)));
Write_Eol; Write_Eol;
Write_Component_Vertices (G, Comp); Write_Component_Vertices (G, Comp);
...@@ -1225,6 +1233,7 @@ package body Bindo.Writers is ...@@ -1225,6 +1233,7 @@ package body Bindo.Writers is
Write_Statistics (G); Write_Statistics (G);
Write_Library_Graph_Vertices (G); Write_Library_Graph_Vertices (G);
Write_Components (G);
Write_Str ("Library Graph end"); Write_Str ("Library Graph end");
Write_Eol; Write_Eol;
...@@ -1312,8 +1321,12 @@ package body Bindo.Writers is ...@@ -1312,8 +1321,12 @@ package body Bindo.Writers is
end if; end if;
Write_Eol; Write_Eol;
Write_Str (" Pending_Predecessors = "); Write_Str (" Pending_Strong_Predecessors = ");
Write_Int (Int (Pending_Predecessors (G, Vertex))); Write_Int (Int (Pending_Strong_Predecessors (G, Vertex)));
Write_Eol;
Write_Str (" Pending_Weak_Predecessors = ");
Write_Int (Int (Pending_Weak_Predecessors (G, Vertex)));
Write_Eol; Write_Eol;
Write_Str (" Component (Comp_Id_"); Write_Str (" Component (Comp_Id_");
...@@ -1612,7 +1625,7 @@ package body Bindo.Writers is ...@@ -1612,7 +1625,7 @@ package body Bindo.Writers is
is is
function Digits_Indentation return Indentation_Level; function Digits_Indentation return Indentation_Level;
pragma Inline (Digits_Indentation); pragma Inline (Digits_Indentation);
-- Determine the level of indentation the number requies in order to -- Determine the level of indentation the number requires in order to
-- be right-justified by Val_Indent. -- be right-justified by Val_Indent.
------------------------ ------------------------
......
...@@ -127,9 +127,6 @@ package Bindo.Writers is ...@@ -127,9 +127,6 @@ package Bindo.Writers is
--------------------------- ---------------------------
package Library_Graph_Writers is package Library_Graph_Writers is
procedure Write_Components (G : Library_Graph);
-- Write all components of library graph G to standard output
procedure Write_Library_Graph (G : Library_Graph); procedure Write_Library_Graph (G : Library_Graph);
-- Write library graph G to standard output -- Write library graph G to standard output
......
...@@ -74,7 +74,7 @@ package body Bindo is ...@@ -74,7 +74,7 @@ package body Bindo is
-- --
-- * Diagnose elaboration circularities between units -- * Diagnose elaboration circularities between units
-- --
-- An elaboration circularity arrises when either -- An elaboration circularity arises when either
-- --
-- - At least one unit cannot be ordered, or -- - At least one unit cannot be ordered, or
-- --
...@@ -95,6 +95,12 @@ package body Bindo is ...@@ -95,6 +95,12 @@ package body Bindo is
-- * Component - A strongly connected component of a graph. -- * Component - A strongly connected component of a graph.
-- --
-- * Elaborable component - A component that is not waiting on other
-- components to be elaborated.
--
-- * Elaborable vertex - A vertex that is not waiting on strong and weak
-- predecessors, and whose component is elaborable.
--
-- * Elaboration circularity - A cycle involving units from the bind. -- * Elaboration circularity - A cycle involving units from the bind.
-- --
-- * Elaboration root - A special invocation construct which denotes the -- * Elaboration root - A special invocation construct which denotes the
...@@ -136,8 +142,23 @@ package body Bindo is ...@@ -136,8 +142,23 @@ package body Bindo is
-- * Pending predecessor - A vertex that must be elaborated before another -- * Pending predecessor - A vertex that must be elaborated before another
-- vertex can be elaborated. -- vertex can be elaborated.
-- --
-- * Strong edge - A non-invocation library graph edge. Strong edges
-- represent the language-defined relations between units.
--
-- * Strong predecessor - A library graph vertex reachable via a strong
-- edge.
--
-- * Target - The destination construct of an invocation relation (the -- * Target - The destination construct of an invocation relation (the
-- generic, subprogram, or task type). -- generic, subprogram, or task type).
--
-- * Weak edge - An invocation library graph edge. Weak edges represent
-- the speculative flow of execution at elaboration time, which may or
-- may not take place.
--
-- * Weak predecessor - A library graph vertex reachable via a weak edge.
--
-- * Weakly elaborable vertex - A vertex that is waiting solely on weak
-- predecessors to be elaborated, and whose component is elaborable.
------------------ ------------------
-- Architecture -- -- Architecture --
...@@ -233,7 +254,7 @@ package body Bindo is ...@@ -233,7 +254,7 @@ package body Bindo is
-- bodies as single vertices. -- bodies as single vertices.
-- --
-- * Try to order as many vertices of the library graph as possible by -- * Try to order as many vertices of the library graph as possible by
-- peforming a topological sort based on the pending predecessors of -- performing a topological sort based on the pending predecessors of
-- vertices across all components and within a single component. -- vertices across all components and within a single component.
-- --
-- * Validate the consistency of the order, only when switch -d_V is in -- * Validate the consistency of the order, only when switch -d_V is in
...@@ -251,7 +272,7 @@ package body Bindo is ...@@ -251,7 +272,7 @@ package body Bindo is
-- The Diagnostics phase has the following objectives: -- The Diagnostics phase has the following objectives:
-- --
-- * Discover, save, and sort all cycles in the library graph. The cycles -- * Discover, save, and sort all cycles in the library graph. The cycles
-- are sorted based on the following heiristics: -- are sorted based on the following heuristics:
-- --
-- - A cycle with higher precedence is preferred. -- - A cycle with higher precedence is preferred.
-- --
...@@ -268,7 +289,7 @@ package body Bindo is ...@@ -268,7 +289,7 @@ package body Bindo is
-- * Diagnose the most important cycle, or all cycles when switch -d_C is -- * Diagnose the most important cycle, or all cycles when switch -d_C is
-- in effect. The diagnostic consists of: -- in effect. The diagnostic consists of:
-- --
-- - The reason for the existance of the cycle, along with the unit -- - The reason for the existence of the cycle, along with the unit
-- whose elaboration cannot be guaranteed. -- whose elaboration cannot be guaranteed.
-- --
-- - A detailed traceback of the cycle, showcasing the transition -- - A detailed traceback of the cycle, showcasing the transition
...@@ -276,7 +297,7 @@ package body Bindo is ...@@ -276,7 +297,7 @@ package body Bindo is
-- information. -- information.
-- --
-- - A set of suggestions on how to break the cycle considering the -- - A set of suggestions on how to break the cycle considering the
-- the edges coprising the circuit, the elaboration model used to -- the edges comprising the circuit, the elaboration model used to
-- compile the units, the availability of invocation information, -- compile the units, the availability of invocation information,
-- and the state of various relevant switches. -- and the state of various relevant switches.
...@@ -284,6 +305,23 @@ package body Bindo is ...@@ -284,6 +305,23 @@ package body Bindo is
-- Switches -- -- Switches --
-------------- --------------
-- -d_a Ignore the effects of pragma Elaborate_All
--
-- GNATbind creates a regular with edge instead of an Elaborate_All
-- edge in the library graph, thus eliminating the effects of the
-- pragma.
--
-- -d_b Ignore the effects of pragma Elaborate_Body
--
-- GNATbind treats a spec and body pair as decoupled.
--
-- -d_e Ignore the effects of pragma Elaborate
--
-- GNATbind creates a regular with edge instead of an Elaborate edge
-- in the library graph, thus eliminating the effects of the pragma.
-- In addition, GNATbind does not create an edge to the body of the
-- pragma argument.
--
-- -d_A Output ALI invocation tables -- -d_A Output ALI invocation tables
-- --
-- GNATbind outputs the contents of ALI table Invocation_Constructs -- GNATbind outputs the contents of ALI table Invocation_Constructs
......
...@@ -41,4 +41,14 @@ package Bindo is ...@@ -41,4 +41,14 @@ package Bindo is
-- exists, it is returned in Order, otherwise Unrecoverable_Error is -- exists, it is returned in Order, otherwise Unrecoverable_Error is
-- raised. -- raised.
private
-- The following type represents the various kinds of precedence between
-- two items.
type Precedence_Kind is
(Lower_Precedence,
Equal_Precedence,
Higher_Precedence);
end Bindo; end Bindo;
...@@ -349,11 +349,11 @@ package body Debug is ...@@ -349,11 +349,11 @@ package body Debug is
-- d.8 -- d.8
-- d.9 -- d.9
-- d_a -- d_a Ignore the effects of pragma Elaborate_All
-- d_b -- d_b Ignore the effects of pragma Elaborate_Body
-- d_c -- d_c
-- d_d -- d_d
-- d_e -- d_e Ignore the effects of pragma Elaborate
-- d_f -- d_f
-- d_g -- d_g
-- d_h -- d_h
...@@ -1141,6 +1141,17 @@ package body Debug is ...@@ -1141,6 +1141,17 @@ package body Debug is
-- dx Force the binder to read (and then ignore) the xref information -- dx Force the binder to read (and then ignore) the xref information
-- in ali files (used to check that read circuit is working OK). -- in ali files (used to check that read circuit is working OK).
-- d_a GNATBIND ignores the effects of pragma Elaborate_All in the case of
-- elaboration order and treats the associated dependency as a regular
-- with edge.
-- d_b GNATBIND ignores the effects of pragma Elaborate_Body in the case
-- of elaboration order and treats the spec and body as decoupled.
-- d_e GNATBIND ignores the effects of pragma Elaborate in the case of
-- elaboration order and no longer creates an implicit dependency on
-- the body of the argument.
-- d_A GNATBIND output the contents of all ALI invocation-related tables -- d_A GNATBIND output the contents of all ALI invocation-related tables
-- in textual format to standard output. -- in textual format to standard output.
......
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