public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] VECify record_layout_info.pending_statics
@ 2010-06-17 19:33 Nathan Froyd
  2010-06-18  9:31 ` Richard Guenther
  2010-06-18 18:04 ` H.J. Lu
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Froyd @ 2010-06-17 19:33 UTC (permalink / raw)
  To: gcc-patches

As $SUBJECT suggests.  More TREE_LIST removal, yada, yada.

Tested on x86_64-unknown-linux-gnu.  OK?

-Nathan

	* tree.h (record_layout_info): Change type of pending_statics field
	to a VEC.
	* stor-layout.c (start_record_layout): Store NULL into
	pending_statics.
	(debug_rli): Adjust for new type of pending_statics field.
	(place_field): Likewise.
	(finish_record_layout): Likewise.

--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -743,7 +743,7 @@ start_record_layout (tree t)
   rli->offset = size_zero_node;
   rli->bitpos = bitsize_zero_node;
   rli->prev_field = 0;
-  rli->pending_statics = 0;
+  rli->pending_statics = NULL;
   rli->packed_maybe_necessary = 0;
   rli->remaining_in_alignment = 0;
 
@@ -827,10 +827,13 @@ debug_rli (record_layout_info rli)
   if (rli->packed_maybe_necessary)
     fprintf (stderr, "packed may be necessary\n");
 
-  if (rli->pending_statics)
+  if (!VEC_empty (tree, rli->pending_statics))
     {
+      unsigned ix;
+      tree t;
       fprintf (stderr, "pending statics:\n");
-      debug_tree (rli->pending_statics);
+      for (ix = 0; VEC_iterate (tree, rli->pending_statics, ix, t); ix++)
+        debug_tree (t);
     }
 }
 
@@ -1041,8 +1044,7 @@ place_field (record_layout_info rli, tree field)
      it *after* the record is laid out.  */
   if (TREE_CODE (field) == VAR_DECL)
     {
-      rli->pending_statics = tree_cons (NULL_TREE, field,
-					rli->pending_statics);
+      VEC_safe_push (tree, gc, rli->pending_statics, field);
       return;
     }
 
@@ -1718,15 +1720,15 @@ finish_record_layout (record_layout_info rli, int free_p)
 
   /* Lay out any static members.  This is done now because their type
      may use the record's type.  */
-  while (rli->pending_statics)
-    {
-      layout_decl (TREE_VALUE (rli->pending_statics), 0);
-      rli->pending_statics = TREE_CHAIN (rli->pending_statics);
-    }
+  while (!VEC_empty (tree, rli->pending_statics))
+    layout_decl (VEC_pop (tree, rli->pending_statics), 0);
 
   /* Clean up.  */
   if (free_p)
-    free (rli);
+    {
+      VEC_free (tree, gc, rli->pending_statics);
+      free (rli);
+    }
 }
 \f
 
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4325,7 +4325,7 @@ typedef struct record_layout_info_s
   tree prev_field;
   /* The static variables (i.e., class variables, as opposed to
      instance variables) encountered in T.  */
-  tree pending_statics;
+  VEC(tree,gc) *pending_statics;
   /* Bits remaining in the current alignment group */
   int remaining_in_alignment;
   /* True if we've seen a packed field that didn't have normal

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] VECify record_layout_info.pending_statics
  2010-06-17 19:33 [PATCH] VECify record_layout_info.pending_statics Nathan Froyd
@ 2010-06-18  9:31 ` Richard Guenther
  2010-06-18 18:04 ` H.J. Lu
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2010-06-18  9:31 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: gcc-patches

On Thu, Jun 17, 2010 at 8:51 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> As $SUBJECT suggests.  More TREE_LIST removal, yada, yada.
>
> Tested on x86_64-unknown-linux-gnu.  OK?

Ok.

Thanks,
Richard.

> -Nathan
>
>        * tree.h (record_layout_info): Change type of pending_statics field
>        to a VEC.
>        * stor-layout.c (start_record_layout): Store NULL into
>        pending_statics.
>        (debug_rli): Adjust for new type of pending_statics field.
>        (place_field): Likewise.
>        (finish_record_layout): Likewise.
>
> --- a/gcc/stor-layout.c
> +++ b/gcc/stor-layout.c
> @@ -743,7 +743,7 @@ start_record_layout (tree t)
>   rli->offset = size_zero_node;
>   rli->bitpos = bitsize_zero_node;
>   rli->prev_field = 0;
> -  rli->pending_statics = 0;
> +  rli->pending_statics = NULL;
>   rli->packed_maybe_necessary = 0;
>   rli->remaining_in_alignment = 0;
>
> @@ -827,10 +827,13 @@ debug_rli (record_layout_info rli)
>   if (rli->packed_maybe_necessary)
>     fprintf (stderr, "packed may be necessary\n");
>
> -  if (rli->pending_statics)
> +  if (!VEC_empty (tree, rli->pending_statics))
>     {
> +      unsigned ix;
> +      tree t;
>       fprintf (stderr, "pending statics:\n");
> -      debug_tree (rli->pending_statics);
> +      for (ix = 0; VEC_iterate (tree, rli->pending_statics, ix, t); ix++)
> +        debug_tree (t);
>     }
>  }
>
> @@ -1041,8 +1044,7 @@ place_field (record_layout_info rli, tree field)
>      it *after* the record is laid out.  */
>   if (TREE_CODE (field) == VAR_DECL)
>     {
> -      rli->pending_statics = tree_cons (NULL_TREE, field,
> -                                       rli->pending_statics);
> +      VEC_safe_push (tree, gc, rli->pending_statics, field);
>       return;
>     }
>
> @@ -1718,15 +1720,15 @@ finish_record_layout (record_layout_info rli, int free_p)
>
>   /* Lay out any static members.  This is done now because their type
>      may use the record's type.  */
> -  while (rli->pending_statics)
> -    {
> -      layout_decl (TREE_VALUE (rli->pending_statics), 0);
> -      rli->pending_statics = TREE_CHAIN (rli->pending_statics);
> -    }
> +  while (!VEC_empty (tree, rli->pending_statics))
> +    layout_decl (VEC_pop (tree, rli->pending_statics), 0);
>
>   /* Clean up.  */
>   if (free_p)
> -    free (rli);
> +    {
> +      VEC_free (tree, gc, rli->pending_statics);
> +      free (rli);
> +    }
>  }
>
>
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -4325,7 +4325,7 @@ typedef struct record_layout_info_s
>   tree prev_field;
>   /* The static variables (i.e., class variables, as opposed to
>      instance variables) encountered in T.  */
> -  tree pending_statics;
> +  VEC(tree,gc) *pending_statics;
>   /* Bits remaining in the current alignment group */
>   int remaining_in_alignment;
>   /* True if we've seen a packed field that didn't have normal
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] VECify record_layout_info.pending_statics
  2010-06-17 19:33 [PATCH] VECify record_layout_info.pending_statics Nathan Froyd
  2010-06-18  9:31 ` Richard Guenther
@ 2010-06-18 18:04 ` H.J. Lu
  1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2010-06-18 18:04 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: gcc-patches

On Thu, Jun 17, 2010 at 11:51 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> As $SUBJECT suggests.  More TREE_LIST removal, yada, yada.
>
> Tested on x86_64-unknown-linux-gnu.  OK?
>
> -Nathan
>
>        * tree.h (record_layout_info): Change type of pending_statics field
>        to a VEC.
>        * stor-layout.c (start_record_layout): Store NULL into
>        pending_statics.
>        (debug_rli): Adjust for new type of pending_statics field.
>        (place_field): Likewise.
>        (finish_record_layout): Likewise.
>
> --- a/gcc/stor-layout.c
> +++ b/gcc/stor-layout.c
> @@ -743,7 +743,7 @@ start_record_layout (tree t)
>   rli->offset = size_zero_node;
>   rli->bitpos = bitsize_zero_node;
>   rli->prev_field = 0;
> -  rli->pending_statics = 0;
> +  rli->pending_statics = NULL;
>   rli->packed_maybe_necessary = 0;
>   rli->remaining_in_alignment = 0;
>
> @@ -827,10 +827,13 @@ debug_rli (record_layout_info rli)
>   if (rli->packed_maybe_necessary)
>     fprintf (stderr, "packed may be necessary\n");
>
> -  if (rli->pending_statics)
> +  if (!VEC_empty (tree, rli->pending_statics))
>     {
> +      unsigned ix;
> +      tree t;
>       fprintf (stderr, "pending statics:\n");
> -      debug_tree (rli->pending_statics);
> +      for (ix = 0; VEC_iterate (tree, rli->pending_statics, ix, t); ix++)
> +        debug_tree (t);
>     }
>  }
>

The checked-in version:

http://gcc.gnu.org/viewcvs/trunk/gcc/stor-layout.c?r1=161000&r2=160999&pathrev=161000

has

   if (rli->packed_maybe_necessary)
     fprintf (stderr, "packed may be necessary\n");

-  if (rli->pending_statics)
+  if (!VEC_empty (tree, rli->pending_statics))
     {
+      unsigned ix;
+      tree t;
       fprintf (stderr, "pending statics:\n");
-      debug_tree (rli->pending_statics);
+      debug_vec_tree (rli->pending_statics);
     }
 }

ix and t are unused. I got

 ../../src-trunk/gcc/store-motion.c -o store-motion.o
../../src-trunk/gcc/stor-layout.c: In function 'debug_rli':
../../src-trunk/gcc/stor-layout.c:833:12: error: unused variable 't'
[-Werror=unused-variable]
../../src-trunk/gcc/stor-layout.c:832:16: error: unused variable 'ix'
[-Werror=unused-variable]
cc1: all warnings being treated as errors

I checked in this patch as an obvious fix.

-- 
H.J.
--
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 161007)
+++ ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2010-06-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* stor-layout.c (debug_rli): Remove unused local variables.
+
 2010-06-18  Eric Botcazou  <ebotcazou@adacore.com>

 	PR rtl-optimization/40900
Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 161007)
+++ stor-layout.c	(working copy)
@@ -829,8 +829,6 @@ debug_rli (record_layout_info rli)

   if (!VEC_empty (tree, rli->pending_statics))
     {
-      unsigned ix;
-      tree t;
       fprintf (stderr, "pending statics:\n");
       debug_vec_tree (rli->pending_statics);
     }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-18 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-17 19:33 [PATCH] VECify record_layout_info.pending_statics Nathan Froyd
2010-06-18  9:31 ` Richard Guenther
2010-06-18 18:04 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).