[lto] c-decl.c, stor-layout.c: Use VEC for pending_sizes.

Kazu Hirata kazu@codesourcery.com
Wed May 31 22:07:00 GMT 2006


Hi,

Attached is a patch to use VEC for pending_sizes.

One of the things we'd like to do on the LTO branch is to eliminate
TREE_LIST.  Without this patch, pending_sizes uses TREE_LIST.

This patch converts pending_sizes to use the VEC API.  Note that the
order of elements have not been changed.  A bunch of tree_cons
followed by nreverse is the same as VEC_safe_push followed by
forward VEC_iterate.

Tested on x86_64-pc-linux-gnu.  OK to apply to the LTO branch?

Kazu Hirata

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

	* stor-layout.c (pending_sizes): Change the type to
	VEC(tree,gc) *.
	(get_pending_sizes, put_pending_size, put_pending_sizes):
	Update the uses of pending_sizes.
	* c-decl.c (store_parm_decls): Likewise.
	* tree.h: Update the prototype for get_pending_sizes and
	put_pending_sizes.

Index: c-decl.c
===================================================================
--- c-decl.c	(revision 114196)
+++ c-decl.c	(working copy)
@@ -6524,9 +6524,12 @@ store_parm_decls (void)
      thus won't naturally see the SAVE_EXPR containing the increment.  All
      other pending sizes would be handled by gimplify_parameters.  */
   {
+    VEC(tree,gc) *pending_sizes = get_pending_sizes ();
     tree t;
-    for (t = nreverse (get_pending_sizes ()); t ; t = TREE_CHAIN (t))
-      add_stmt (TREE_VALUE (t));
+    int i;
+
+    for (i = 0; VEC_iterate (tree, pending_sizes, i, t); i++)
+      add_stmt (t);
   }
 
   /* Even though we're inside a function body, we still don't want to
Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 114196)
+++ stor-layout.c	(working copy)
@@ -65,7 +65,7 @@ extern void debug_rli (record_layout_inf
 
 /* SAVE_EXPRs for sizes of types and decls, waiting to be expanded.  */
 
-static GTY(()) tree pending_sizes;
+static GTY(()) VEC(tree,gc) *pending_sizes;
 
 /* Show that REFERENCE_TYPES are internal and should be Pmode.  Called only
    by front end.  */
@@ -78,10 +78,10 @@ internal_reference_types (void)
 
 /* Get a list of all the objects put on the pending sizes list.  */
 
-tree
+VEC(tree,gc) *
 get_pending_sizes (void)
 {
-  tree chain = pending_sizes;
+  VEC(tree,gc) *chain = pending_sizes;
 
   pending_sizes = 0;
   return chain;
@@ -97,14 +97,14 @@ put_pending_size (tree expr)
   expr = skip_simple_arithmetic (expr);
 
   if (TREE_CODE (expr) == SAVE_EXPR)
-    pending_sizes = tree_cons (NULL_TREE, expr, pending_sizes);
+    VEC_safe_push (tree, gc, pending_sizes, expr);
 }
 
 /* Put a chain of objects into the pending sizes list, which must be
    empty.  */
 
 void
-put_pending_sizes (tree chain)
+put_pending_sizes (VEC(tree,gc) *chain)
 {
   gcc_assert (!pending_sizes);
   pending_sizes = chain;
Index: tree.h
===================================================================
--- tree.h	(revision 114196)
+++ tree.h	(working copy)
@@ -3870,9 +3870,9 @@ extern tree size_diffop (tree, tree);
 
 extern tree round_up (tree, int);
 extern tree round_down (tree, int);
-extern tree get_pending_sizes (void);
+extern VEC(tree,gc) *get_pending_sizes (void);
 extern void put_pending_size (tree);
-extern void put_pending_sizes (tree);
+extern void put_pending_sizes (VEC(tree,gc) *);
 
 /* Type for sizes of data-type.  */
 



More information about the Gcc-patches mailing list