aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-01-04 08:41:52 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-01-16 15:44:54 +0100
commit1f038e845bbdeae9dddf1810fb3e6c9ad1b79f13 (patch)
tree49e2de4aba4f20330ea90eabdf7a3dd13661d466 /gcc/ada/gcc-interface/utils.cc
parente59cd0db822e325868128281a81ee356a6914f52 (diff)
downloadgcc-1f038e845bbdeae9dddf1810fb3e6c9ad1b79f13.zip
gcc-1f038e845bbdeae9dddf1810fb3e6c9ad1b79f13.tar.gz
gcc-1f038e845bbdeae9dddf1810fb3e6c9ad1b79f13.tar.bz2
ada: Further optimize interface objects initialized with function calls
This further optimizes the usual case of (class-wide) interface objects that are initialized with calls to functions whose result type is the type of the objects (this is not necessary as any result type implementing the interface would do) by avoiding a back-and-forth displacement of the objects' address. This exposed a latent issue whereby the displacement was missing in the case of a simple return statement whose expression is a call to a function whose result type is a specific tagged type that needs finalization. And, in order to avoid pessimizing the expanded code, this in turn required avoiding to create temporaries for allocators by calling Remove_Side_Effects up front, in the common cases when they are not necessary. gcc/ada/ * exp_ch3.adb (Expand_N_Object_Declaration): Do not generate a back- and-forth displacement of the object's address when using a renaming for an interface object with an expression of the same type. * exp_ch4.adb (Expand_Allocator_Expression): Do not remove the side effects of the expression up front for the simple allocators. Do not call the Adjust primitive if the expression is a function call. * exp_ch6.adb (Expand_Ctrl_Function_Call): Do not expand the call unnecessarily for a special return object. (Expand_Simple_Function_Return): Restore the displacement of the return object's address in the case where the expression is the call to a function whose result type is a type that needs finalization. * exp_util.adb (Expand_Subtype_From_Expr): Do not remove the side effects of the expression before calling Make_Subtype_From_Expr. (Make_CW_Equivalent_Type): If the expression has the tag of its type and this type has a uniform size, use 'Object_Size of this type in lieu of 'Size of the expression to compute the expression's size.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.cc')
0 files changed, 0 insertions, 0 deletions