From: Eric Botcazou Date: Thu, 19 Jun 2025 17:15:35 +0000 (+0200) Subject: ada: Remove strange elaboration code generated for Cluster type in System.Pack_NN X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccf668274ac66f9692eb0b6775e522ed240890f7;p=thirdparty%2Fgcc.git ada: Remove strange elaboration code generated for Cluster type in System.Pack_NN Initialization procedures are turned into functions under the hood and, even when they are null (empty), the compiler may generate a convoluted sequence of instructions that return uninitialized data and, therefore, is useless. gcc/ada/ChangeLog: * gcc-interface/trans.cc (Subprogram_Body_to_gnu): Do not generate a block-copy out for a null initialization procedure when the _Init parameter is not passed in. --- diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 520611e7d79..a7254fe036f 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -4172,9 +4172,13 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) } } - /* Otherwise, if this is a procedure or a function which does not return - by invisible reference, we can do a direct block-copy out. */ - else + /* Otherwise, if this is a procedure or a function that does not return + by invisible reference, we can do a direct block-copy out, but we do + not need to do it for a null initialization procedure when the _Init + parameter is not passed in since we would copy uninitialized bits. */ + else if (!(Is_Null_Init_Proc (gnat_subprog) + && list_length (gnu_cico_list) == 1 + && TREE_CODE (TREE_VALUE (gnu_cico_list)) == VAR_DECL)) { tree gnu_retval;