[RFC/RFH] remove uses of build_constructor_from_list from?Ada FE

Message ID 201006201107.01608.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou June 20, 2010, 9:07 a.m.
> I personally think TREE_VEC should just be a wrapper around VEC,
> precisely for cases like this.

That would indeed help.  But I think that we can get away without that in this 
case because the cico list is quite special: it's the list of elements of a 
CONSTRUCTOR.  So we can probably turn TYPE_CI_CO_LIST into a CONSTRUCTOR (and 
rename it into TYPE_CICO_RETVAL in the process for the sake of clarity).

In the meantime, I've installed the attached patch so that you can install 
yours without further ado (after testing though); it's already very valuable 
because it eliminates the back-and-forth conversion between list and array 
done in gnat_build_constructor.

Tested on i586-suse-linux, applied on the mainline.

2010-06-20  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Subprogram_Body_to_gnu): Use while instead of
	for loop.  Call build_constructor_from_list directly in the CICO case.


Index: gcc-interface/trans.c
--- gcc-interface/trans.c	(revision 161023)
+++ gcc-interface/trans.c	(working copy)
@@ -2462,9 +2462,8 @@  Subprogram_Body_to_gnu (Node_Id gnat_nod
 	/* Skip any entries that have been already filled in; they must
 	   correspond to In Out parameters.  */
-	for (; gnu_cico_list && TREE_VALUE (gnu_cico_list);
-	     gnu_cico_list = TREE_CHAIN (gnu_cico_list))
-	  ;
+	while (gnu_cico_list && TREE_VALUE (gnu_cico_list))
+	  gnu_cico_list = TREE_CHAIN (gnu_cico_list);
 	/* Do any needed references for padded types.  */
 	TREE_VALUE (gnu_cico_list)
@@ -2546,8 +2545,8 @@  Subprogram_Body_to_gnu (Node_Id gnat_nod
       if (list_length (gnu_cico_list) == 1)
 	gnu_retval = TREE_VALUE (gnu_cico_list);
-	gnu_retval = gnat_build_constructor (TREE_TYPE (gnu_subprog_type),
-					     gnu_cico_list);
+	gnu_retval = build_constructor_from_list (TREE_TYPE (gnu_subprog_type),
+						  gnu_cico_list);
       add_stmt_with_node (build_return_expr (gnu_result_decl, gnu_retval),
 			  End_Label (Handled_Statement_Sequence (gnat_node)));