aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorRichard Kenner <kenner@adacore.com>2024-07-12 09:45:26 -0400
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-08-02 09:08:07 +0200
commit3e64ad035302af0cd8e329bb508aa9ef1eb27597 (patch)
tree391a594ea2507a2344cc9c031ce6b59bceb7d3e8 /gcc/ada
parent384283f91d218b7dbd0d665996512634383389ce (diff)
downloadgcc-3e64ad035302af0cd8e329bb508aa9ef1eb27597.zip
gcc-3e64ad035302af0cd8e329bb508aa9ef1eb27597.tar.gz
gcc-3e64ad035302af0cd8e329bb508aa9ef1eb27597.tar.bz2
ada: Clean up handling of inlining of finalizer procedures
Change Is_Finalizer from synthesized attribute into flag. Remove duplicate Is_Finalizer_Proc. Add new Try_Inline_Always for backend usage. gcc/ada/ * einfo-utils.ads (Is_Finalizer): Delete. * einfo-utils.adb (Is_Finalizer): Delete. * einfo.ads: Adjust comment. * gen_il-fields.ads, gen_il-gen-gen_entities.adb: Add Is_Finalizer flag. * exp_ch3.adb (Build_Init_Procedure): Set it. * exp_ch7.adb (Create_Finalizer): Likewise. * exp_util.adb (Try_Inline_Always): New function. * exp_util.ads (Try_Inline_Always): New function. * sem_elab.adb (Is_Finalizer_Proc): Replace with Is_Finalizer.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/einfo-utils.adb9
-rw-r--r--gcc/ada/einfo-utils.ads1
-rw-r--r--gcc/ada/einfo.ads2
-rw-r--r--gcc/ada/exp_ch3.adb1
-rw-r--r--gcc/ada/exp_ch7.adb1
-rw-r--r--gcc/ada/exp_util.adb10
-rw-r--r--gcc/ada/exp_util.ads5
-rw-r--r--gcc/ada/gen_il-fields.ads1
-rw-r--r--gcc/ada/gen_il-gen-gen_entities.adb1
-rw-r--r--gcc/ada/sem_elab.adb26
10 files changed, 25 insertions, 32 deletions
diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb
index c0c79f92..3dc25b3 100644
--- a/gcc/ada/einfo-utils.adb
+++ b/gcc/ada/einfo-utils.adb
@@ -1567,15 +1567,6 @@ package body Einfo.Utils is
Has_Option (Id, Name_Synchronous));
end Is_External_State;
- ------------------
- -- Is_Finalizer --
- ------------------
-
- function Is_Finalizer (Id : E) return B is
- begin
- return Ekind (Id) = E_Procedure and then Chars (Id) = Name_uFinalizer;
- end Is_Finalizer;
-
----------------------
-- Is_Full_Access --
----------------------
diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads
index 8207576..c0480c7 100644
--- a/gcc/ada/einfo-utils.ads
+++ b/gcc/ada/einfo-utils.ads
@@ -190,7 +190,6 @@ package Einfo.Utils is
function Is_Dynamic_Scope (Id : E) return B;
function Is_Elaboration_Target (Id : E) return B;
function Is_External_State (Id : E) return B;
- function Is_Finalizer (Id : E) return B with Inline;
function Is_Full_Access (Id : E) return B with Inline;
function Is_Null_State (Id : E) return B;
function Is_Package_Or_Generic_Package (Id : E) return B with Inline;
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 9d0f2ee..4486ab3 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -2647,7 +2647,7 @@ package Einfo is
-- the transient finalization mechanisms. The flag prevents the double
-- finalization of the object.
--- Is_Finalizer (synthesized)
+-- Is_Finalizer
-- Applies to all entities, true for procedures containing finalization
-- code to process local or library level objects.
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 6fee2b4..bf04ea9 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -3532,6 +3532,7 @@ package body Exp_Ch3 is
DF_Id :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Name_uFinalizer));
+ Set_Is_Finalizer (DF_Id);
Append_To (Decls, Make_Local_Deep_Finalize (Rec_Type, DF_Id));
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index b545a58..72f0b53 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -1979,6 +1979,7 @@ package body Exp_Ch7 is
Fin_Id :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Name_uFinalizer));
+ Set_Is_Finalizer (Fin_Id);
-- The visibility semantics of At_End handlers force a strange
-- separation of spec and body for stack-related finalizers:
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index c5d3af7..bd8bbb3 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -14525,6 +14525,16 @@ package body Exp_Util is
return Target;
end Thunk_Target;
+ -----------------------
+ -- Try_Inline_Always --
+ -----------------------
+
+ function Try_Inline_Always (Subp : Entity_Id) return Boolean is
+ ((Is_Expression_Function (Subp) or else Is_Finalizer (Subp))
+ and then not Debug_Flag_Dot_8);
+ -- We want to inline expression functions and finalizers as much as
+ -- practical unless -gnatd.8.
+
-------------------
-- Type_Map_Hash --
-------------------
diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads
index 7fbbe5f..14d9e34 100644
--- a/gcc/ada/exp_util.ads
+++ b/gcc/ada/exp_util.ads
@@ -1260,6 +1260,11 @@ package Exp_Util is
-- WARNING: There is a matching C declaration of this subprogram in fe.h
+ function Try_Inline_Always (Subp : Entity_Id) return Boolean;
+ -- Determines if the backend should try hard to inline Subp. This is
+ -- similar to Subp having a pragma Inline_Always, but doesn't cause an
+ -- error if Subp can't actually be inlined.
+
function Type_May_Have_Bit_Aligned_Components
(Typ : Entity_Id) return Boolean;
-- Determines if Typ is a composite type that has within it (looking down
diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads
index 9b85401..22fd1e3 100644
--- a/gcc/ada/gen_il-fields.ads
+++ b/gcc/ada/gen_il-fields.ads
@@ -708,6 +708,7 @@ package Gen_IL.Fields is
Is_Exception_Handler,
Is_Exported,
Is_Finalized_Transient,
+ Is_Finalizer,
Is_First_Subtype,
Is_Fixed_Lower_Bound_Array_Subtype,
Is_Fixed_Lower_Bound_Index_Subtype,
diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb
index 86701cf..29b22c6 100644
--- a/gcc/ada/gen_il-gen-gen_entities.adb
+++ b/gcc/ada/gen_il-gen-gen_entities.adb
@@ -146,6 +146,7 @@ begin -- Gen_IL.Gen.Gen_Entities
Sm (Is_Entry_Formal, Flag),
Sm (Is_Entry_Wrapper, Flag),
Sm (Is_Exported, Flag),
+ Sm (Is_Finalizer, Flag),
Sm (Is_First_Subtype, Flag),
Sm (Is_Formal_Subprogram, Flag),
Sm (Is_Frozen, Flag),
diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb
index a030d6b..0b5f87b 100644
--- a/gcc/ada/sem_elab.adb
+++ b/gcc/ada/sem_elab.adb
@@ -1778,11 +1778,6 @@ package body Sem_Elab is
-- Determine whether arbitrary entity Id denotes internally generated
-- routine Default_Initial_Condition.
- function Is_Finalizer_Proc (Id : Entity_Id) return Boolean;
- pragma Inline (Is_Finalizer_Proc);
- -- Determine whether arbitrary entity Id denotes internally generated
- -- routine _Finalizer.
-
function Is_Initial_Condition_Proc (Id : Entity_Id) return Boolean;
pragma Inline (Is_Initial_Condition_Proc);
-- Determine whether arbitrary entity Id denotes internally generated
@@ -2438,7 +2433,7 @@ package body Sem_Elab is
-- Calls to _Finalizer procedures must not appear in the output
-- because this creates confusing noise.
- elsif Is_Finalizer_Proc (Subp_Id) then
+ elsif Is_Finalizer (Subp_Id) then
null;
-- Initial_Condition
@@ -5338,7 +5333,7 @@ package body Sem_Elab is
return
(Is_Controlled_Procedure (Subp_Id, Name_Finalize)
- or else Is_Finalizer_Proc (Subp_Id)
+ or else Is_Finalizer (Subp_Id)
or else Is_TSS (Subp_Id, TSS_Deep_Finalize))
and then In_Initialization_Context (Call);
end Is_Partial_Finalization_Proc;
@@ -6607,7 +6602,7 @@ package body Sem_Elab is
-- Calls to _Finalizer procedures must not appear in the output
-- because this creates confusing noise.
- elsif Is_Finalizer_Proc (Subp_Id) then
+ elsif Is_Finalizer (Subp_Id) then
null;
-- Initial_Condition
@@ -13098,7 +13093,7 @@ package body Sem_Elab is
-- Controlled finalization actions
elsif Is_Controlled_Procedure (Targ_Id, Name_Finalize)
- or else Is_Finalizer_Proc (Targ_Id)
+ or else Is_Finalizer (Targ_Id)
then
Extra := First_Formal_Type (Targ_Id);
Kind := Controlled_Finalization;
@@ -14467,7 +14462,7 @@ package body Sem_Elab is
begin
return
Is_Accept_Alternative_Proc (Id)
- or else Is_Finalizer_Proc (Id)
+ or else Is_Finalizer (Id)
or else Is_Partial_Invariant_Proc (Id)
or else Is_TSS (Id, TSS_Deep_Adjust)
or else Is_TSS (Id, TSS_Deep_Finalize)
@@ -14488,17 +14483,6 @@ package body Sem_Elab is
return Ekind (Id) = E_Procedure and then Is_DIC_Procedure (Id);
end Is_Default_Initial_Condition_Proc;
- -----------------------
- -- Is_Finalizer_Proc --
- -----------------------
-
- function Is_Finalizer_Proc (Id : Entity_Id) return Boolean is
- begin
- -- To qualify, the entity must denote a _Finalizer procedure
-
- return Ekind (Id) = E_Procedure and then Chars (Id) = Name_uFinalizer;
- end Is_Finalizer_Proc;
-
-------------------------------
-- Is_Initial_Condition_Proc --
-------------------------------