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 1)


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.

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

Kazu Hirata

2006-05-31  Kazu Hirata  <kazu@codesourcery.com>

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

Index: coverage.c
===================================================================
--- coverage.c	(revision 114242)
+++ coverage.c	(working copy)
@@ -706,15 +706,15 @@ build_ctr_info_type (void)
 static tree
 build_ctr_info_value (unsigned int counter, tree type)
 {
-  tree value = NULL_TREE;
   tree fields = TYPE_FIELDS (type);
   tree fn;
+  VEC(constructor_elt,gc) *v = NULL;
+  constructor_elt *elt;
 
   /* counters */
-  value = tree_cons (fields,
-		     build_int_cstu (get_gcov_unsigned_t (),
-				     prg_n_ctrs[counter]),
-		     value);
+  elt = VEC_safe_push (constructor_elt, gc, v, NULL);
+  elt->index = fields;
+  elt->value = build_int_cstu (get_gcov_unsigned_t (), prg_n_ctrs[counter]);
   fields = TREE_CHAIN (fields);
 
   if (prg_n_ctrs[counter])
@@ -732,13 +732,17 @@ build_ctr_info_value (unsigned int count
       DECL_SIZE_UNIT (tree_ctr_tables[counter]) = TYPE_SIZE_UNIT (array_type);
       assemble_variable (tree_ctr_tables[counter], 0, 0, 0);
 
-      value = tree_cons (fields,
-			 build1 (ADDR_EXPR, TREE_TYPE (fields), 
-					    tree_ctr_tables[counter]),
-			 value);
+      elt = VEC_safe_push (constructor_elt, gc, v, NULL);
+      elt->index = fields;
+      elt->value = build1 (ADDR_EXPR, TREE_TYPE (fields),
+			   tree_ctr_tables[counter]);
     }
   else
-    value = tree_cons (fields, null_pointer_node, value);
+    {
+      elt = VEC_safe_push (constructor_elt, gc, v, NULL);
+      elt->index = fields;
+      elt->value = null_pointer_node;
+    }
   fields = TREE_CHAIN (fields);
 
   fn = build_decl (FUNCTION_DECL,
@@ -748,14 +752,11 @@ build_ctr_info_value (unsigned int count
   TREE_PUBLIC (fn) = 1;
   DECL_ARTIFICIAL (fn) = 1;
   TREE_NOTHROW (fn) = 1;
-  value = tree_cons (fields,
-		     build1 (ADDR_EXPR, TREE_TYPE (fields), fn),
-		     value);
+  elt = VEC_safe_push (constructor_elt, gc, v, NULL);
+  elt->index = fields;
+  elt->value = build1 (ADDR_EXPR, TREE_TYPE (fields), fn);
 
-  /* FIXME: use build_constructor directly.  */
-  value = build_constructor_from_list (type, nreverse (value));
-
-  return value;
+  return build_constructor (type, v);
 }
 
 /* Creates the gcov_info RECORD_TYPE and initializer for it. Returns a


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