]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove strange elaboration code generated for Cluster type in System.Pack_NN
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 19 Jun 2025 17:15:35 +0000 (19:15 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 4 Jul 2025 07:41:48 +0000 (09:41 +0200)
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.

gcc/ada/gcc-interface/trans.cc

index 520611e7d79aa2cdbc969debf6ac0151c83a23a5..a7254fe036f410f77948b8bbef0adbab3696c146 100644 (file)
@@ -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;