This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto] coverage.c: Call build_constructor instead of build_constructor_from_list. (Part 2)


Hi,

Attached is a patch to call build_constructor instead of
build_constructor_from_list.

build_constructor_from_list takes a linked list constructed with
tree_cons and internally converts that to an instance of VEC.

This patches skips the construction of the linked list and calls
build_constructor, which takes VEC directly.

Note that this patch does not change the order of elements.  A bunch
of tree_cons followed by nreverse is the same as a bunch of
VEC_safe_push.

Note also that this patch is slightly complicated by the fact that
build_fn_info_value builds two instances of vectors.

Tested on x86_64-pc-linux-gnu.  OK to apply to the LTO branch (and 4.3
once in stage 1)?

Kazu Hirata

2006-06-01  Kazu Hirata  <kazu@codesourcery.com>

	* coverage.c (build_fn_info_type): Call build_constructor
	instead of build_constructor_from_list.

Index: coverage.c
===================================================================
--- coverage.c	(revision 114242)
+++ coverage.c	(working copy)
@@ -628,40 +628,39 @@ build_fn_info_type (unsigned int counter
 static tree
 build_fn_info_value (const struct function_list *function, tree type)
 {
-  tree value = NULL_TREE;
   tree fields = TYPE_FIELDS (type);
   unsigned ix;
-  tree array_value = NULL_TREE;
+  VEC(constructor_elt,gc) *v1 = NULL;
+  VEC(constructor_elt,gc) *v2 = NULL;
+  constructor_elt *elt;
 
   /* ident */
-  value = tree_cons (fields, build_int_cstu (get_gcov_unsigned_t (),
-					     function->ident), value);
+  elt = VEC_safe_push (constructor_elt, gc, v1, NULL);
+  elt->index = fields;
+  elt->value = build_int_cstu (get_gcov_unsigned_t (), function->ident);
   fields = TREE_CHAIN (fields);
 
   /* checksum */
-  value = tree_cons (fields, build_int_cstu (get_gcov_unsigned_t (),
-					     function->checksum), value);
+  elt = VEC_safe_push (constructor_elt, gc, v1, NULL);
+  elt->index = fields;
+  elt->value = build_int_cstu (get_gcov_unsigned_t (), function->checksum);
   fields = TREE_CHAIN (fields);
 
   /* counters */
   for (ix = 0; ix != GCOV_COUNTERS; ix++)
     if (prg_ctr_mask & (1 << ix))
       {
-	tree counters = build_int_cstu (get_gcov_unsigned_t (),
-					function->n_ctrs[ix]);
-
-	array_value = tree_cons (NULL_TREE, counters, array_value);
+	elt = VEC_safe_push (constructor_elt, gc, v2, NULL);
+	elt->index = NULL;
+	elt->value = build_int_cstu (get_gcov_unsigned_t (),
+				     function->n_ctrs[ix]);
       }
 
-  /* FIXME: use build_constructor directly.  */
-  array_value = build_constructor_from_list (TREE_TYPE (fields),
-					     nreverse (array_value));
-  value = tree_cons (fields, array_value, value);
+  elt = VEC_safe_push (constructor_elt, gc, v1, NULL);
+  elt->index = fields;
+  elt->value = build_constructor (TREE_TYPE (fields), v2);
 
-  /* FIXME: use build_constructor directly.  */
-  value = build_constructor_from_list (type, nreverse (value));
-
-  return value;
+  return build_constructor (type, v1);
 }
 
 /* Creates the gcov_ctr_info RECORD_TYPE.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]