aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/fe.h
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-04-10 00:47:48 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-19 14:05:28 +0000
commitc697f593f47490b1d3b061ae76ba728bfa2ff372 (patch)
treec9b4883d40c89883b0609a6d8289b1118e64339f /gcc/ada/fe.h
parente08f1aad6fbc1cab4604f01f6fcf66349bb6c713 (diff)
downloadgcc-c697f593f47490b1d3b061ae76ba728bfa2ff372.zip
gcc-c697f593f47490b1d3b061ae76ba728bfa2ff372.tar.gz
gcc-c697f593f47490b1d3b061ae76ba728bfa2ff372.tar.bz2
[Ada] Get rid of secondary stack for controlled components
This eliminates the use of the secondary stack to return composite types with controlled components from functions, by exposing the return slot of these functions through the support interface of memory pools, much like for the secondary stack itself. This is piggybacked on the support of a specific intrinsic function by the code generator, and can be disabled if this support is not available, as well with the -gnatd_r debug switch. The change also streamlines a bit the implementation by consistently using the Needs_Finalization predicate, or its derivatives, in various places. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-retsta. * debug.adb (d_r): Document usage. * exp_ch4.adb (Expand_N_Allocato): Deal with the return stack pool. * exp_ch6.adb (Expand_Simple_Function_Return): Replace calls to Requires_Transient_Scope with Returns_On_Secondary_Stack. Deal with types that need finalization returned on the primary stack, use CW_Or_Needs_Finalization for those returned on the secondary. * exp_util.adb (Build_Allocate_Deallocate_Proc): Return early for the return stack pool. (Remove_Side_Effects): Call CW_Or_Needs_Finalization. * fe.h (Requires_Transient_Scope): Delete. (Returns_On_Secondary_Stack): Declare. * gnat1drv.adb (Adjust_Global_Switches): Set Back_End_Return_Slot to False when generating C code or if -gnatd_r is specified. * opt.ads (Back_End_Return_Slot): New boolean variable. * rtsfind.ads (RTU_Id): Add System_Return_Stack. (RE_Id): Add RE_RS_Allocate and RE_RS_Pool. (RE_Unit_Table): Add entries for RE_RS_Allocate and RE_RS_Pool. * sem_util.ads (CW_Or_Has_Controlled_Part): Delete. (CW_Or_Needs_Finalization): Declare. (Requires_Transient_Scope): Adjust description. (Returns_On_Secondary_Stack): Declare. * sem_util.adb (Compute_Returns_By_Ref): Set Returns_By_Ref on types which need finalization if they are returned on the secondary stack. (CW_Or_Has_Controlled_Part): Rename to... (CW_Or_Needs_Finalization): ...this. (Requires_Transient_Scope): Move bulk of implementation to... (Returns_On_Secondary_Stack): ...here. Return true for types which need finalization only if the back-end return slot is not supported. * libgnat/s-retsta.ads: New file. * gcc-interface/ada-builtin-types.def (BT_FN_PTR_SSIZE): Define. * gcc-interface/ada-builtins.def (return_slot): Likewise. * gcc-interface/ada-tree.h (BUILT_IN_RETURN_SLOT): Likewise. * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Replace call to Requires_Transient_Scope with Returns_On_Secondary_Stack. * gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>: In the return by invisible reference, skip the copy if the source is the same as the destination. * gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Deal with the return stack pool.
Diffstat (limited to 'gcc/ada/fe.h')
-rw-r--r--gcc/ada/fe.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h
index 33b48e6..4be9d94 100644
--- a/gcc/ada/fe.h
+++ b/gcc/ada/fe.h
@@ -298,14 +298,14 @@ extern Boolean Compile_Time_Known_Value (Node_Id);
#define Is_Expression_Function sem_util__is_expression_function
#define Is_Variable_Size_Record sem_util__is_variable_size_record
#define Next_Actual sem_util__next_actual
-#define Requires_Transient_Scope sem_util__requires_transient_scope
-
-extern Entity_Id Defining_Entity (Node_Id);
-extern Node_Id First_Actual (Node_Id);
-extern Boolean Is_Expression_Function (Entity_Id);
-extern Boolean Is_Variable_Size_Record (Entity_Id);
-extern Node_Id Next_Actual (Node_Id);
-extern Boolean Requires_Transient_Scope (Entity_Id);
+#define Returns_On_Secondary_Stack sem_util__returns_on_secondary_stack
+
+extern Entity_Id Defining_Entity (Node_Id);
+extern Node_Id First_Actual (Node_Id);
+extern Boolean Is_Expression_Function (Entity_Id);
+extern Boolean Is_Variable_Size_Record (Entity_Id);
+extern Node_Id Next_Actual (Node_Id);
+extern Boolean Returns_On_Secondary_Stack (Entity_Id);
/* sinfo: */