diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2024-02-26 09:32:20 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-16 10:49:32 +0200 |
commit | c485a154ae0cfa1a63c79a1f3b82d6f2d4a107b5 (patch) | |
tree | 1899e549c078aec936497eb9c553965dae210a0d | |
parent | a802cb3c5f530e77dabcb6343d79cb7a24f96ed3 (diff) | |
download | gcc-c485a154ae0cfa1a63c79a1f3b82d6f2d4a107b5.zip gcc-c485a154ae0cfa1a63c79a1f3b82d6f2d4a107b5.tar.gz gcc-c485a154ae0cfa1a63c79a1f3b82d6f2d4a107b5.tar.bz2 |
ada: Ignore ghost nodes in call graph information for dispatching calls
When emitting call graph information, we already skipped calls to
ignored ghost entities, but this code was causing crashes (in production
builds) and assertion failures (in development builds), because the
ignored ghost entities are not fully decorated, e.g. when they come from
instances of generic units with default subprograms.
With this patch we skip call graph information for ignored ghost
entities when they are registered, both as explicit calls and as
tagged types that will come with internally generated dispatching
subprograms.
gcc/ada/
* exp_cg.adb (Generate_CG_Output): Remove code for ignored ghost
entities that applied to subprogram calls.
(Register_CG_Node): Skip ignored ghost entities, both calls
and tagged types, when they are registered.
-rw-r--r-- | gcc/ada/exp_cg.adb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/ada/exp_cg.adb b/gcc/ada/exp_cg.adb index addf1ca..91a6d40 100644 --- a/gcc/ada/exp_cg.adb +++ b/gcc/ada/exp_cg.adb @@ -125,14 +125,7 @@ package body Exp_CG is for J in Call_Graph_Nodes.First .. Call_Graph_Nodes.Last loop N := Call_Graph_Nodes.Table (J); - -- No action needed for subprogram calls removed by the expander - -- (for example, calls to ignored ghost entities). - - if Nkind (N) = N_Null_Statement then - pragma Assert (Nkind (Original_Node (N)) in N_Subprogram_Call); - null; - - elsif Nkind (N) in N_Subprogram_Call then + if Nkind (N) in N_Subprogram_Call then Write_Call_Info (N); else pragma Assert (Nkind (N) = N_Defining_Identifier); @@ -358,7 +351,13 @@ package body Exp_CG is procedure Register_CG_Node (N : Node_Id) is begin - if Nkind (N) in N_Subprogram_Call then + -- Skip ignored ghost calls that will be removed by the expander + + if Is_Ignored_Ghost_Node (N) then + null; + + elsif Nkind (N) in N_Subprogram_Call then + if Current_Scope = Main_Unit_Entity or else Entity_Is_In_Main_Unit (Current_Scope) then |