https://gcc.gnu.org/g:ccf668274ac66f9692eb0b6775e522ed240890f7

commit r16-2016-gccf668274ac66f9692eb0b6775e522ed240890f7
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Thu Jun 19 19:15:35 2025 +0200

    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:
---
 gcc/ada/gcc-interface/trans.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 520611e7d79a..a7254fe036f4 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;

Reply via email to