public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PR middle-end/55398] Convert vec<> into a POD
@ 2012-11-20 16:23 Diego Novillo
  2012-11-20 16:27 ` Diego Novillo
  0 siblings, 1 reply; 6+ messages in thread
From: Diego Novillo @ 2012-11-20 16:23 UTC (permalink / raw)
  To: gcc-patches

This fixes PR 55398 by making vec<> a true POD.  I thought we could get
away with having private fields, but we can't.  We fail to pass vec<>
instances through varargs.

The patch makes every field public and mangles the field names in the
hope that no future patch will try to make use of them directly.  It's
horrible, but I could not think of anything better.

I also added two small changes to va_heap::release and
va_stack::release.  If the vector to free is NULL, they do
nothing.

Tested with clang++ as the host compiler on x86_64.


2012-11-20  Diego Novillo  <dnovillo@google.com>

    PR middle-end/55398
    * vec.h (class vec_prefix): Make every field public.
    Rename field alloc_ to alloc_PRIVATE_.
    Rename field num_ to num_PRIVATE_.
    Update all users.
    (class vec<T, A, vl_embed>): Make every field public.
    Rename field pfx_ to pfx_PRIVATE_.
    Rename field data_ to data_PRIVATE_.
    Update all users.
    (class vec<T, A, vl_ptr>): Make every field public.
    Rename field vec_ to vec_PRIVATE_.
    Update all users.
    (va_heap::release): Do nothing if V is NULL.
    (va_stack::release): Likewise.

---
 gcc/ChangeLog |   15 ++++
 gcc/vec.c     |   13 ++--
 gcc/vec.h     |  203 ++++++++++++++++++++++++++++++---------------------------
 3 files changed, 130 insertions(+), 101 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7c07c32..21948b9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2012-11-20  Diego Novillo  <dnovillo@google.com>
+
+	PR middle-end/55398
+	* vec.h (class vec_prefix): Make every field public.
+	Rename field alloc_ to alloc_PRIVATE_.
+	Rename field num_ to num_PRIVATE_.
+	Update all users.
+	(class vec<T, A, vl_embed>): Make every field public.
+	Rename field pfx_ to pfx_PRIVATE_.
+	Rename field data_ to data_PRIVATE_.
+	Update all users.
+	(class vec<T, A, vl_ptr>): Make every field public.
+	Rename field vec_ to vec_PRIVATE_.
+	Update all users.
+
 2012-11-20  Uros Bizjak  <ubizjak@gmail.com>
 
 	* config/i386/i386.c (ix86_expand_call): Emit CLOBBERs in VOIDmode.
diff --git a/gcc/vec.c b/gcc/vec.c
index b213aba..3f8f550 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -121,8 +121,8 @@ vec_descriptor (const char *name, int line, const char *function)
 /* Account the overhead.  */
 
 void
-vec_prefix::register_overhead (size_t size, const char *name, int line,
-			       const char *function)
+vec_prefix::register_overhead_PRIVATE_ (size_t size, const char *name, int line,
+			                const char *function)
 {
   struct vec_descriptor *loc = vec_descriptor (name, line, function);
   struct ptr_hash_entry *p = XNEW (struct ptr_hash_entry);
@@ -148,7 +148,7 @@ vec_prefix::register_overhead (size_t size, const char *name, int line,
 /* Notice that the memory allocated for the vector has been freed.  */
 
 void
-vec_prefix::release_overhead (void)
+vec_prefix::release_overhead_PRIVATE_ (void)
 {
   PTR *slot = htab_find_slot_with_hash (ptr_hash, this,
 					htab_hash_pointer (this),
@@ -165,15 +165,16 @@ vec_prefix::release_overhead (void)
    exponentially.  PFX is the control data for the vector.  */
 
 unsigned
-vec_prefix::calculate_allocation (vec_prefix *pfx, unsigned reserve, bool exact)
+vec_prefix::calculate_allocation_PRIVATE_ (vec_prefix *pfx, unsigned reserve,
+					   bool exact)
 {
   unsigned alloc = 0;
   unsigned num = 0;
 
   if (pfx)
     {
-      alloc = pfx->alloc_;
-      num = pfx->num_;
+      alloc = pfx->alloc_PRIVATE_;
+      num = pfx->num_PRIVATE_;
     }
   else if (!reserve)
     /* If there's no vector, and we've not requested anything, then we
diff --git a/gcc/vec.h b/gcc/vec.h
index b9be85c..61ae9bf 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -216,11 +216,13 @@ extern void dump_vec_loc_statistics (void);
 
 class vec_prefix
 {
-protected:
+  /* FIXME - These fields should be private, but we need to cater to
+	     compilers that have stricter notions of PODness for types.  */
+public:
   /* Memory allocation support routines in vec.c.  */
-  void register_overhead (size_t, const char *, int, const char *);
-  void release_overhead (void);
-  static unsigned calculate_allocation (vec_prefix *, unsigned, bool);
+  void register_overhead_PRIVATE_ (size_t, const char *, int, const char *);
+  void release_overhead_PRIVATE_ (void);
+  static unsigned calculate_allocation_PRIVATE_ (vec_prefix *, unsigned, bool);
 
   /* Note that vec_prefix should be a base class for vec, but we use
      offsetof() on vector fields of tree structures (e.g.,
@@ -236,8 +238,8 @@ protected:
   friend struct va_heap;
   friend struct va_stack;
 
-  unsigned alloc_;
-  unsigned num_;
+  unsigned alloc_PRIVATE_;
+  unsigned num_PRIVATE_;
 };
 
 template<typename, typename, typename> class vec;
@@ -285,8 +287,8 @@ inline void
 va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
 		  MEM_STAT_DECL)
 {
-  unsigned alloc = vec_prefix::calculate_allocation (v ? &v->pfx_ : 0, reserve,
-						     exact);
+  unsigned alloc = vec_prefix::calculate_allocation_PRIVATE_ (
+	  v ? &v->pfx_PRIVATE_ : 0, reserve, exact);
   if (!alloc)
     {
       release (v);
@@ -294,7 +296,7 @@ va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
     }
 
   if (GATHER_STATISTICS && v)
-    v->pfx_.release_overhead ();
+    v->pfx_PRIVATE_.release_overhead_PRIVATE_ ();
 
   size_t size = vec<T, va_heap, vl_embed>::embedded_size (alloc);
   unsigned nelem = v ? v->length () : 0;
@@ -302,7 +304,7 @@ va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
   v->embedded_init (alloc, nelem);
 
   if (GATHER_STATISTICS)
-    v->pfx_.register_overhead (size FINAL_PASS_MEM_STAT);
+    v->pfx_PRIVATE_.register_overhead_PRIVATE_ (size FINAL_PASS_MEM_STAT);
 }
 
 
@@ -312,8 +314,11 @@ template<typename T>
 void
 va_heap::release (vec<T, va_heap, vl_embed> *&v)
 {
+  if (v == NULL)
+    return;
+
   if (GATHER_STATISTICS)
-    v->pfx_.release_overhead ();
+    v->pfx_PRIVATE_.release_overhead_PRIVATE_ ();
   ::free (v);
   v = NULL;
 }
@@ -349,8 +354,8 @@ void
 va_gc::reserve (vec<T, A, vl_embed> *&v, unsigned reserve, bool exact
 		MEM_STAT_DECL)
 {
-  unsigned alloc = vec_prefix::calculate_allocation (v ? &v->pfx_ : 0, reserve,
-						     exact);
+  unsigned alloc = vec_prefix::calculate_allocation_PRIVATE_ (
+	  v ? &v->pfx_PRIVATE_ : 0, reserve, exact);
   if (!alloc)
     {
       ::ggc_free (v);
@@ -418,9 +423,9 @@ void
 va_stack::alloc (vec<T, va_stack, vl_ptr> &v, unsigned nelems,
 		 vec<T, va_stack, vl_embed> *space)
 {
-  v.vec_ = space;
-  register_stack_vec (static_cast<void *> (v.vec_));
-  v.vec_->embedded_init (nelems, 0);
+  v.vec_PRIVATE_ = space;
+  register_stack_vec (static_cast<void *> (v.vec_PRIVATE_));
+  v.vec_PRIVATE_->embedded_init (nelems, 0);
 }
 
 
@@ -447,15 +452,17 @@ va_stack::reserve (vec<T, va_stack, vl_embed> *&v, unsigned nelems, bool exact
     }
 
   /* Move VEC_ to the heap.  */
-  nelems += v->pfx_.num_;
+  nelems += v->pfx_PRIVATE_.num_PRIVATE_;
   vec<T, va_stack, vl_embed> *oldvec = v;
   v = NULL;
   va_heap::reserve (reinterpret_cast<vec<T, va_heap, vl_embed> *&>(v), nelems,
 		    exact);
   if (v && oldvec)
     {
-      v->pfx_.num_ = oldvec->length ();
-      memcpy (v->data_, oldvec->data_, oldvec->length () * sizeof (T));
+      v->pfx_PRIVATE_.num_PRIVATE_ = oldvec->length ();
+      memcpy (v->data_PRIVATE_,
+	      oldvec->data_PRIVATE_,
+	      oldvec->length () * sizeof (T));
     }
 }
 
@@ -467,6 +474,9 @@ template<typename T>
 void
 va_stack::release (vec<T, va_stack, vl_embed> *&v)
 {
+  if (v == NULL)
+    return;
+
   int ix = stack_vec_register_index (static_cast<void *> (v));
   if (ix >= 0)
     {
@@ -531,11 +541,11 @@ template<typename T, typename A>
 class GTY((user)) vec<T, A, vl_embed>
 {
 public:
-  unsigned allocated (void) const { return pfx_.alloc_; }
-  unsigned length (void) const { return pfx_.num_; }
-  bool is_empty (void) const { return pfx_.num_ == 0; }
-  T *address (void) { return data_; }
-  const T *address (void) const { return data_; }
+  unsigned allocated (void) const { return pfx_PRIVATE_.alloc_PRIVATE_; }
+  unsigned length (void) const { return pfx_PRIVATE_.num_PRIVATE_; }
+  bool is_empty (void) const { return pfx_PRIVATE_.num_PRIVATE_ == 0; }
+  T *address (void) { return data_PRIVATE_; }
+  const T *address (void) const { return data_PRIVATE_; }
   const T &operator[] (unsigned) const;
   T &operator[] (unsigned);
   T &last (void);
@@ -568,9 +578,10 @@ public:
   friend struct va_heap;
   friend struct va_stack;
 
-private:
-  vec_prefix pfx_;
-  T data_[1];
+  /* FIXME - These fields should be private, but we need to cater to
+	     compilers that have stricter notions of PODness for types.  */
+  vec_prefix pfx_PRIVATE_;
+  T data_PRIVATE_[1];
 };
 
 
@@ -782,16 +793,16 @@ template<typename T, typename A>
 inline const T &
 vec<T, A, vl_embed>::operator[] (unsigned ix) const
 {
-  gcc_checking_assert (ix < pfx_.num_);
-  return data_[ix];
+  gcc_checking_assert (ix < pfx_PRIVATE_.num_PRIVATE_);
+  return data_PRIVATE_[ix];
 }
 
 template<typename T, typename A>
 inline T &
 vec<T, A, vl_embed>::operator[] (unsigned ix)
 {
-  gcc_checking_assert (ix < pfx_.num_);
-  return data_[ix];
+  gcc_checking_assert (ix < pfx_PRIVATE_.num_PRIVATE_);
+  return data_PRIVATE_[ix];
 }
 
 
@@ -801,8 +812,8 @@ template<typename T, typename A>
 inline T &
 vec<T, A, vl_embed>::last (void)
 {
-  gcc_checking_assert (pfx_.num_ > 0);
-  return (*this)[pfx_.num_ - 1];
+  gcc_checking_assert (pfx_PRIVATE_.num_PRIVATE_ > 0);
+  return (*this)[pfx_PRIVATE_.num_PRIVATE_ - 1];
 }
 
 
@@ -816,7 +827,7 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_embed>::space (unsigned nelems) const
 {
-  return pfx_.alloc_ - pfx_.num_ >= nelems;
+  return pfx_PRIVATE_.alloc_PRIVATE_ - pfx_PRIVATE_.num_PRIVATE_ >= nelems;
 }
 
 
@@ -831,9 +842,9 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_embed>::iterate (unsigned ix, T *ptr) const
 {
-  if (ix < pfx_.num_)
+  if (ix < pfx_PRIVATE_.num_PRIVATE_)
     {
-      *ptr = data_[ix];
+      *ptr = data_PRIVATE_[ix];
       return true;
     }
   else
@@ -857,9 +868,9 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_embed>::iterate (unsigned ix, T **ptr) const
 {
-  if (ix < pfx_.num_)
+  if (ix < pfx_PRIVATE_.num_PRIVATE_)
     {
-      *ptr = CONST_CAST (T *, &data_[ix]);
+      *ptr = CONST_CAST (T *, &data_PRIVATE_[ix]);
       return true;
     }
   else
@@ -882,7 +893,7 @@ vec<T, A, vl_embed>::copy (ALONE_MEM_STAT_DECL) const
     {
       vec_alloc (new_vec, len PASS_MEM_STAT);
       new_vec->embedded_init (len, len);
-      memcpy (new_vec->address(), data_, sizeof (T) * len);
+      memcpy (new_vec->address(), data_PRIVATE_, sizeof (T) * len);
     }
   return new_vec;
 }
@@ -900,7 +911,7 @@ vec<T, A, vl_embed>::splice (vec<T, A, vl_embed> &src)
     {
       gcc_checking_assert (space (len));
       memcpy (address() + length(), src.address(), len * sizeof (T));
-      pfx_.num_ += len;
+      pfx_PRIVATE_.num_PRIVATE_ += len;
     }
 }
 
@@ -922,7 +933,7 @@ inline T *
 vec<T, A, vl_embed>::quick_push (const T &obj)
 {
   gcc_checking_assert (space (1));
-  T *slot = &data_[pfx_.num_++];
+  T *slot = &data_PRIVATE_[pfx_PRIVATE_.num_PRIVATE_++];
   *slot = obj;
   return slot;
 }
@@ -935,7 +946,7 @@ inline T &
 vec<T, A, vl_embed>::pop (void)
 {
   gcc_checking_assert (length () > 0);
-  return data_[--pfx_.num_];
+  return data_PRIVATE_[--pfx_PRIVATE_.num_PRIVATE_];
 }
 
 
@@ -947,7 +958,7 @@ inline void
 vec<T, A, vl_embed>::truncate (unsigned size)
 {
   gcc_checking_assert (length () >= size);
-  pfx_.num_ = size;
+  pfx_PRIVATE_.num_PRIVATE_ = size;
 }
 
 
@@ -960,8 +971,8 @@ vec<T, A, vl_embed>::quick_insert (unsigned ix, const T &obj)
 {
   gcc_checking_assert (length () < allocated ());
   gcc_checking_assert (ix <= length ());
-  T *slot = &data_[ix];
-  memmove (slot + 1, slot, (pfx_.num_++ - ix) * sizeof (T));
+  T *slot = &data_PRIVATE_[ix];
+  memmove (slot + 1, slot, (pfx_PRIVATE_.num_PRIVATE_++ - ix) * sizeof (T));
   *slot = obj;
 }
 
@@ -975,8 +986,8 @@ inline void
 vec<T, A, vl_embed>::ordered_remove (unsigned ix)
 {
   gcc_checking_assert (ix < length());
-  T *slot = &data_[ix];
-  memmove (slot, slot + 1, (--pfx_.num_ - ix) * sizeof (T));
+  T *slot = &data_PRIVATE_[ix];
+  memmove (slot, slot + 1, (--pfx_PRIVATE_.num_PRIVATE_ - ix) * sizeof (T));
 }
 
 
@@ -988,7 +999,7 @@ inline void
 vec<T, A, vl_embed>::unordered_remove (unsigned ix)
 {
   gcc_checking_assert (ix < length());
-  data_[ix] = data_[--pfx_.num_];
+  data_PRIVATE_[ix] = data_PRIVATE_[--pfx_PRIVATE_.num_PRIVATE_];
 }
 
 
@@ -1000,9 +1011,9 @@ inline void
 vec<T, A, vl_embed>::block_remove (unsigned ix, unsigned len)
 {
   gcc_checking_assert (ix + len <= length());
-  T *slot = &data_[ix];
-  pfx_.num_ -= len;
-  memmove (slot, slot + len, (pfx_.num_ - ix) * sizeof (T));
+  T *slot = &data_PRIVATE_[ix];
+  pfx_PRIVATE_.num_PRIVATE_ -= len;
+  memmove (slot, slot + len, (pfx_PRIVATE_.num_PRIVATE_ - ix) * sizeof (T));
 }
 
 
@@ -1066,7 +1077,7 @@ inline size_t
 vec<T, A, vl_embed>::embedded_size (unsigned alloc)
 {
   typedef vec<T, A, vl_embed> vec_embedded;
-  return offsetof (vec_embedded, data_) + alloc * sizeof (T);
+  return offsetof (vec_embedded, data_PRIVATE_) + alloc * sizeof (T);
 }
 
 
@@ -1077,8 +1088,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_embed>::embedded_init (unsigned alloc, unsigned num)
 {
-  pfx_.alloc_ = alloc;
-  pfx_.num_ = num;
+  pfx_PRIVATE_.alloc_PRIVATE_ = alloc;
+  pfx_PRIVATE_.num_PRIVATE_ = num;
 }
 
 
@@ -1089,8 +1100,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_embed>::quick_grow (unsigned len)
 {
-  gcc_checking_assert (length () <= len && len <= pfx_.alloc_);
-  pfx_.num_ = len;
+  gcc_checking_assert (length () <= len && len <= pfx_PRIVATE_.alloc_PRIVATE_);
+  pfx_PRIVATE_.num_PRIVATE_ = len;
 }
 
 
@@ -1195,22 +1206,22 @@ public:
 
   /* Vector operations.  */
   bool exists (void) const
-  { return vec_ != NULL; }
+  { return vec_PRIVATE_ != NULL; }
 
   bool is_empty (void) const
-  { return vec_ ? vec_->is_empty() : true; }
+  { return vec_PRIVATE_ ? vec_PRIVATE_->is_empty() : true; }
 
   unsigned length (void) const
-  { return vec_ ? vec_->length() : 0; }
+  { return vec_PRIVATE_ ? vec_PRIVATE_->length() : 0; }
 
   T *address (void)
-  { return vec_ ? vec_->data_ : NULL; }
+  { return vec_PRIVATE_ ? vec_PRIVATE_->data_PRIVATE_ : NULL; }
 
   const T *address (void) const
-  { return vec_ ? vec_->data_ : NULL; }
+  { return vec_PRIVATE_ ? vec_PRIVATE_->data_PRIVATE_ : NULL; }
 
   const T &operator[] (unsigned ix) const
-  { return (*vec_)[ix]; }
+  { return (*vec_PRIVATE_)[ix]; }
 
   bool operator!=(const vec &other) const
   { return !(*this == other); }
@@ -1219,13 +1230,13 @@ public:
   { return address() == other.address(); }
 
   T &operator[] (unsigned ix)
-  { return (*vec_)[ix]; }
+  { return (*vec_PRIVATE_)[ix]; }
 
   T &last (void)
-  { return vec_->last(); }
+  { return vec_PRIVATE_->last(); }
 
   bool space (int nelems) const
-  { return vec_ ? vec_->space (nelems) : nelems == 0; }
+  { return vec_PRIVATE_ ? vec_PRIVATE_->space (nelems) : nelems == 0; }
 
   bool iterate (unsigned ix, T *p) const;
   bool iterate (unsigned ix, T **p) const;
@@ -1254,8 +1265,9 @@ public:
   friend void va_stack::alloc(vec<T1, va_stack, vl_ptr>&, unsigned,
 			      vec<T1, va_stack, vl_embed> *);
 
-private:
-  vec<T, A, vl_embed> *vec_;
+  /* FIXME - This field should be private, but we need to cater to
+	     compilers that have stricter notions of PODness for types.  */
+  vec<T, A, vl_embed> *vec_PRIVATE_;
 };
 
 
@@ -1358,8 +1370,8 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_ptr>::iterate (unsigned ix, T *ptr) const
 {
-  if (vec_)
-    return vec_->iterate (ix, ptr);
+  if (vec_PRIVATE_)
+    return vec_PRIVATE_->iterate (ix, ptr);
   else
     {
       *ptr = 0;
@@ -1381,8 +1393,8 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_ptr>::iterate (unsigned ix, T **ptr) const
 {
-  if (vec_)
-    return vec_->iterate (ix, ptr);
+  if (vec_PRIVATE_)
+    return vec_PRIVATE_->iterate (ix, ptr);
   else
     {
       *ptr = 0;
@@ -1422,7 +1434,7 @@ vec<T, A, vl_ptr>::copy (ALONE_MEM_STAT_DECL) const
 {
   vec<T, A, vl_ptr> new_vec = vec<T, A, vl_ptr>();
   if (length ())
-    new_vec.vec_ = vec_->copy ();
+    new_vec.vec_PRIVATE_ = vec_PRIVATE_->copy ();
   return new_vec;
 }
 
@@ -1442,7 +1454,7 @@ vec<T, A, vl_ptr>::reserve (unsigned nelems, bool exact MEM_STAT_DECL)
 {
   bool extend = nelems ? !space (nelems) : false;
   if (extend)
-    A::reserve (vec_, nelems, exact PASS_MEM_STAT);
+    A::reserve (vec_PRIVATE_, nelems, exact PASS_MEM_STAT);
   return extend;
 }
 
@@ -1469,7 +1481,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::create (unsigned nelems MEM_STAT_DECL)
 {
-  vec_ = NULL;
+  vec_PRIVATE_ = NULL;
   if (nelems > 0)
     reserve_exact (nelems PASS_MEM_STAT);
 }
@@ -1481,8 +1493,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::release (void)
 {
-  if (vec_)
-    A::release (vec_);
+  if (vec_PRIVATE_)
+    A::release (vec_PRIVATE_);
 }
 
 
@@ -1495,8 +1507,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::splice (vec<T, A, vl_ptr> &src)
 {
-  if (src.vec_)
-    vec_->splice (*(src.vec_));
+  if (src.vec_PRIVATE_)
+    vec_PRIVATE_->splice (*(src.vec_PRIVATE_));
 }
 
 
@@ -1525,7 +1537,7 @@ template<typename T, typename A>
 inline T *
 vec<T, A, vl_ptr>::quick_push (const T &obj)
 {
-  return vec_->quick_push (obj);
+  return vec_PRIVATE_->quick_push (obj);
 }
 
 
@@ -1548,7 +1560,7 @@ template<typename T, typename A>
 inline T &
 vec<T, A, vl_ptr>::pop (void)
 {
-  return vec_->pop ();
+  return vec_PRIVATE_->pop ();
 }
 
 
@@ -1559,8 +1571,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::truncate (unsigned size)
 {
-  if (vec_)
-    vec_->truncate (size);
+  if (vec_PRIVATE_)
+    vec_PRIVATE_->truncate (size);
   else
     gcc_checking_assert (size == 0);
 }
@@ -1577,7 +1589,7 @@ vec<T, A, vl_ptr>::safe_grow (unsigned len MEM_STAT_DECL)
   unsigned oldlen = length ();
   gcc_checking_assert (oldlen <= len);
   reserve_exact (len - oldlen PASS_MEM_STAT);
-  vec_->quick_grow (len);
+  vec_PRIVATE_->quick_grow (len);
 }
 
 
@@ -1602,8 +1614,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::quick_grow (unsigned len)
 {
-  gcc_checking_assert (vec_);
-  vec_->quick_grow (len);
+  gcc_checking_assert (vec_PRIVATE_);
+  vec_PRIVATE_->quick_grow (len);
 }
 
 
@@ -1615,8 +1627,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::quick_grow_cleared (unsigned len)
 {
-  gcc_checking_assert (vec_);
-  vec_->quick_grow_cleared (len);
+  gcc_checking_assert (vec_PRIVATE_);
+  vec_PRIVATE_->quick_grow_cleared (len);
 }
 
 
@@ -1627,7 +1639,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::quick_insert (unsigned ix, const T &obj)
 {
-  vec_->quick_insert (ix, obj);
+  vec_PRIVATE_->quick_insert (ix, obj);
 }
 
 
@@ -1651,7 +1663,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::ordered_remove (unsigned ix)
 {
-  vec_->ordered_remove (ix);
+  vec_PRIVATE_->ordered_remove (ix);
 }
 
 
@@ -1662,7 +1674,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::unordered_remove (unsigned ix)
 {
-  vec_->unordered_remove (ix);
+  vec_PRIVATE_->unordered_remove (ix);
 }
 
 
@@ -1673,7 +1685,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::block_remove (unsigned ix, unsigned len)
 {
-  vec_->block_remove (ix, len);
+  vec_PRIVATE_->block_remove (ix, len);
 }
 
 
@@ -1684,8 +1696,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::qsort (int (*cmp) (const void *, const void *))
 {
-  if (vec_)
-    vec_->qsort (cmp);
+  if (vec_PRIVATE_)
+    vec_PRIVATE_->qsort (cmp);
 }
 
 
@@ -1696,9 +1708,10 @@ vec<T, A, vl_ptr>::qsort (int (*cmp) (const void *, const void *))
 
 template<typename T, typename A>
 inline unsigned
-vec<T, A, vl_ptr>::lower_bound (T obj, bool (*lessthan)(const T &, const T &)) const
+vec<T, A, vl_ptr>::lower_bound (T obj, bool (*lessthan)(const T &, const T &))
+    const
 {
-  return vec_ ? vec_->lower_bound (obj, lessthan) : 0;
+  return vec_PRIVATE_ ? vec_PRIVATE_->lower_bound (obj, lessthan) : 0;
 }
 
 #endif // GCC_VEC_H
-- 
1.7.7.3

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

* Re: [PR middle-end/55398] Convert vec<> into a POD
  2012-11-20 16:23 [PR middle-end/55398] Convert vec<> into a POD Diego Novillo
@ 2012-11-20 16:27 ` Diego Novillo
  2012-11-20 17:49   ` Andreas Tobler
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Diego Novillo @ 2012-11-20 16:27 UTC (permalink / raw)
  To: gcc-patches

On Tue, Nov 20, 2012 at 11:23 AM, Diego Novillo <dnovillo@google.com> wrote:

> 2012-11-20  Diego Novillo  <dnovillo@google.com>
>
>     PR middle-end/55398
>     * vec.h (class vec_prefix): Make every field public.
>     Rename field alloc_ to alloc_PRIVATE_.
>     Rename field num_ to num_PRIVATE_.
>     Update all users.
>     (class vec<T, A, vl_embed>): Make every field public.
>     Rename field pfx_ to pfx_PRIVATE_.
>     Rename field data_ to data_PRIVATE_.
>     Update all users.
>     (class vec<T, A, vl_ptr>): Make every field public.
>     Rename field vec_ to vec_PRIVATE_.
>     Update all users.
>     (va_heap::release): Do nothing if V is NULL.
>     (va_stack::release): Likewise.

Committed as rev 193667.


Diego.

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

* Re: [PR middle-end/55398] Convert vec<> into a POD
  2012-11-20 16:27 ` Diego Novillo
@ 2012-11-20 17:49   ` Andreas Tobler
  2012-11-20 19:36   ` Jakub Jelinek
  2012-11-20 20:11   ` Ulrich Weigand
  2 siblings, 0 replies; 6+ messages in thread
From: Andreas Tobler @ 2012-11-20 17:49 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches

On 20.11.12 17:27, Diego Novillo wrote:
> On Tue, Nov 20, 2012 at 11:23 AM, Diego Novillo <dnovillo@google.com> wrote:
> 
>> 2012-11-20  Diego Novillo  <dnovillo@google.com>
>>
>>     PR middle-end/55398
>>     * vec.h (class vec_prefix): Make every field public.
>>     Rename field alloc_ to alloc_PRIVATE_.
>>     Rename field num_ to num_PRIVATE_.
>>     Update all users.
>>     (class vec<T, A, vl_embed>): Make every field public.
>>     Rename field pfx_ to pfx_PRIVATE_.
>>     Rename field data_ to data_PRIVATE_.
>>     Update all users.
>>     (class vec<T, A, vl_ptr>): Make every field public.
>>     Rename field vec_ to vec_PRIVATE_.
>>     Update all users.
>>     (va_heap::release): Do nothing if V is NULL.
>>     (va_stack::release): Likewise.
> 
> Committed as rev 193667.

Completed bootstrap on x86_64-unknown-freebsd10.0 with a 4.2.1 gcc.
Which was failing before with a bus error in genautomata:

(gdb) bt
#0  0x00000008010410f9 in ?? () from /lib/libc.so.7
#1  0x0000000801046ac9 in free () from /lib/libc.so.7
#2  0x000000000041db18 in va_heap::release<state*> (
    v=@0x7fffffffd860: 0x641560 <minimize_time>)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/vec.h:317
#3  0x000000000041ddb1 in vec<state*, va_heap, vl_ptr>::release (
    this=0x7fffffffd860)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/vec.h:1485
#4  0x0000000000407b29 in copy_equiv_class (to=0x7fffffffd860, from=...)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:6030
#5  0x0000000000408406 in evaluate_equiv_classes (automaton=0x8032c1470,
    equiv_classes=0x7fffffffd860)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:6118
#6  0x00000000004114b2 in minimize_DFA (automaton=0x8032c1470)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:6260
#7  0x00000000004185d0 in build_automaton (automaton=0x8032c1470)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:6350
#8  0x0000000000418e07 in create_automata ()
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:6779
#9  0x0000000000418eb3 in generate ()
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:9203
#10 0x000000000041b8d9 in expand_automata ()
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:9465
---Type <return> to continue, or q <return> to quit---bt fullq
#11 0x000000000041c3fc in main (argc=3, argv=0x7fffffffda08)
    at /home/andreast/devel/gcc/gcc-head/gcc/gcc/genautomata.c:9656


Thank you very much!

Andreas

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

* Re: [PR middle-end/55398] Convert vec<> into a POD
  2012-11-20 16:27 ` Diego Novillo
  2012-11-20 17:49   ` Andreas Tobler
@ 2012-11-20 19:36   ` Jakub Jelinek
  2012-11-20 19:49     ` Diego Novillo
  2012-11-20 20:11   ` Ulrich Weigand
  2 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2012-11-20 19:36 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches

On Tue, Nov 20, 2012 at 11:27:06AM -0500, Diego Novillo wrote:
> On Tue, Nov 20, 2012 at 11:23 AM, Diego Novillo <dnovillo@google.com> wrote:
> 
> > 2012-11-20  Diego Novillo  <dnovillo@google.com>
> >
> >     PR middle-end/55398
> >     * vec.h (class vec_prefix): Make every field public.
> >     Rename field alloc_ to alloc_PRIVATE_.
> >     Rename field num_ to num_PRIVATE_.
> >     Update all users.
> >     (class vec<T, A, vl_embed>): Make every field public.
> >     Rename field pfx_ to pfx_PRIVATE_.
> >     Rename field data_ to data_PRIVATE_.
> >     Update all users.
> >     (class vec<T, A, vl_ptr>): Make every field public.
> >     Rename field vec_ to vec_PRIVATE_.
> >     Update all users.
> >     (va_heap::release): Do nothing if V is NULL.
> >     (va_stack::release): Likewise.
> 
> Committed as rev 193667.

As discussed on IRC, the uglification unfortunately also affects day to day
use of gcc under gdb.  I don't see the point in uglifying vec_prefix fields,
from vec<X> vec_prefix shouldn't be available except of direct use of the
uglified/poisoned fields, and the following patch also renames the vec<> fields,
so that they all have vec in their names and poisons them at the end of
vec.h.

Bootstrapped/regtested on i686-linux and so far bootstrapped on
x86_64-linux, ok for trunk?

2012-11-20  Jakub Jelinek  <jakub@redhat.com>

	* vec.h (class vec_prefix): Change into struct.
	Rename field alloc_PRIVATE_ back to alloc_.
	Rename field num_PRIVATE_ to num_.
	Update all users.
	(class vec<T, A, vl_embed>): Rename field pfx_PRIVATE_ to vecpfx_.
	Rename field data_PRIVATE_ to vecdata_.
	Update all users.
	(class vec<T, A, vl_ptr>): Make every field public.
	Rename field vec_PRIVATE_ back to vec_.
	Update all users.

--- gcc/vec.h.jj	2012-11-20 18:29:44.000000000 +0100
+++ gcc/vec.h	2012-11-20 18:40:40.977290143 +0100
@@ -214,15 +214,15 @@ extern void dump_vec_loc_statistics (voi
 /* Control data for vectors.  This contains the number of allocated
    and used slots inside a vector.  */
 
-class vec_prefix
+struct vec_prefix
 {
   /* FIXME - These fields should be private, but we need to cater to
 	     compilers that have stricter notions of PODness for types.  */
-public:
+
   /* Memory allocation support routines in vec.c.  */
-  void register_overhead_PRIVATE_ (size_t, const char *, int, const char *);
-  void release_overhead_PRIVATE_ (void);
-  static unsigned calculate_allocation_PRIVATE_ (vec_prefix *, unsigned, bool);
+  void register_overhead (size_t, const char *, int, const char *);
+  void release_overhead (void);
+  static unsigned calculate_allocation (vec_prefix *, unsigned, bool);
 
   /* Note that vec_prefix should be a base class for vec, but we use
      offsetof() on vector fields of tree structures (e.g.,
@@ -238,8 +238,8 @@ public:
   friend struct va_heap;
   friend struct va_stack;
 
-  unsigned alloc_PRIVATE_;
-  unsigned num_PRIVATE_;
+  unsigned alloc_;
+  unsigned num_;
 };
 
 template<typename, typename, typename> class vec;
@@ -287,8 +287,8 @@ inline void
 va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
 		  MEM_STAT_DECL)
 {
-  unsigned alloc = vec_prefix::calculate_allocation_PRIVATE_ (
-	  v ? &v->pfx_PRIVATE_ : 0, reserve, exact);
+  unsigned alloc
+    = vec_prefix::calculate_allocation (v ? &v->vecpfx_ : 0, reserve, exact);
   if (!alloc)
     {
       release (v);
@@ -296,7 +296,7 @@ va_heap::reserve (vec<T, va_heap, vl_emb
     }
 
   if (GATHER_STATISTICS && v)
-    v->pfx_PRIVATE_.release_overhead_PRIVATE_ ();
+    v->vecpfx_.release_overhead ();
 
   size_t size = vec<T, va_heap, vl_embed>::embedded_size (alloc);
   unsigned nelem = v ? v->length () : 0;
@@ -304,7 +304,7 @@ va_heap::reserve (vec<T, va_heap, vl_emb
   v->embedded_init (alloc, nelem);
 
   if (GATHER_STATISTICS)
-    v->pfx_PRIVATE_.register_overhead_PRIVATE_ (size FINAL_PASS_MEM_STAT);
+    v->vecpfx_.register_overhead (size FINAL_PASS_MEM_STAT);
 }
 
 
@@ -318,7 +318,7 @@ va_heap::release (vec<T, va_heap, vl_emb
     return;
 
   if (GATHER_STATISTICS)
-    v->pfx_PRIVATE_.release_overhead_PRIVATE_ ();
+    v->vecpfx_.release_overhead ();
   ::free (v);
   v = NULL;
 }
@@ -354,8 +354,8 @@ void
 va_gc::reserve (vec<T, A, vl_embed> *&v, unsigned reserve, bool exact
 		MEM_STAT_DECL)
 {
-  unsigned alloc = vec_prefix::calculate_allocation_PRIVATE_ (
-	  v ? &v->pfx_PRIVATE_ : 0, reserve, exact);
+  unsigned alloc
+    = vec_prefix::calculate_allocation (v ? &v->vecpfx_ : 0, reserve, exact);
   if (!alloc)
     {
       ::ggc_free (v);
@@ -423,9 +423,9 @@ void
 va_stack::alloc (vec<T, va_stack, vl_ptr> &v, unsigned nelems,
 		 vec<T, va_stack, vl_embed> *space)
 {
-  v.vec_PRIVATE_ = space;
-  register_stack_vec (static_cast<void *> (v.vec_PRIVATE_));
-  v.vec_PRIVATE_->embedded_init (nelems, 0);
+  v.vec_ = space;
+  register_stack_vec (static_cast<void *> (v.vec_));
+  v.vec_->embedded_init (nelems, 0);
 }
 
 
@@ -452,16 +452,16 @@ va_stack::reserve (vec<T, va_stack, vl_e
     }
 
   /* Move VEC_ to the heap.  */
-  nelems += v->pfx_PRIVATE_.num_PRIVATE_;
+  nelems += v->vecpfx_.num_;
   vec<T, va_stack, vl_embed> *oldvec = v;
   v = NULL;
   va_heap::reserve (reinterpret_cast<vec<T, va_heap, vl_embed> *&>(v), nelems,
 		    exact);
   if (v && oldvec)
     {
-      v->pfx_PRIVATE_.num_PRIVATE_ = oldvec->length ();
-      memcpy (v->data_PRIVATE_,
-	      oldvec->data_PRIVATE_,
+      v->vecpfx_.num_ = oldvec->length ();
+      memcpy (v->vecdata_,
+	      oldvec->vecdata_,
 	      oldvec->length () * sizeof (T));
     }
 }
@@ -541,11 +541,11 @@ template<typename T, typename A>
 class GTY((user)) vec<T, A, vl_embed>
 {
 public:
-  unsigned allocated (void) const { return pfx_PRIVATE_.alloc_PRIVATE_; }
-  unsigned length (void) const { return pfx_PRIVATE_.num_PRIVATE_; }
-  bool is_empty (void) const { return pfx_PRIVATE_.num_PRIVATE_ == 0; }
-  T *address (void) { return data_PRIVATE_; }
-  const T *address (void) const { return data_PRIVATE_; }
+  unsigned allocated (void) const { return vecpfx_.alloc_; }
+  unsigned length (void) const { return vecpfx_.num_; }
+  bool is_empty (void) const { return vecpfx_.num_ == 0; }
+  T *address (void) { return vecdata_; }
+  const T *address (void) const { return vecdata_; }
   const T &operator[] (unsigned) const;
   T &operator[] (unsigned);
   T &last (void);
@@ -580,8 +580,8 @@ public:
 
   /* FIXME - These fields should be private, but we need to cater to
 	     compilers that have stricter notions of PODness for types.  */
-  vec_prefix pfx_PRIVATE_;
-  T data_PRIVATE_[1];
+  vec_prefix vecpfx_;
+  T vecdata_[1];
 };
 
 
@@ -793,16 +793,16 @@ template<typename T, typename A>
 inline const T &
 vec<T, A, vl_embed>::operator[] (unsigned ix) const
 {
-  gcc_checking_assert (ix < pfx_PRIVATE_.num_PRIVATE_);
-  return data_PRIVATE_[ix];
+  gcc_checking_assert (ix < vecpfx_.num_);
+  return vecdata_[ix];
 }
 
 template<typename T, typename A>
 inline T &
 vec<T, A, vl_embed>::operator[] (unsigned ix)
 {
-  gcc_checking_assert (ix < pfx_PRIVATE_.num_PRIVATE_);
-  return data_PRIVATE_[ix];
+  gcc_checking_assert (ix < vecpfx_.num_);
+  return vecdata_[ix];
 }
 
 
@@ -812,8 +812,8 @@ template<typename T, typename A>
 inline T &
 vec<T, A, vl_embed>::last (void)
 {
-  gcc_checking_assert (pfx_PRIVATE_.num_PRIVATE_ > 0);
-  return (*this)[pfx_PRIVATE_.num_PRIVATE_ - 1];
+  gcc_checking_assert (vecpfx_.num_ > 0);
+  return (*this)[vecpfx_.num_ - 1];
 }
 
 
@@ -827,7 +827,7 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_embed>::space (unsigned nelems) const
 {
-  return pfx_PRIVATE_.alloc_PRIVATE_ - pfx_PRIVATE_.num_PRIVATE_ >= nelems;
+  return vecpfx_.alloc_ - vecpfx_.num_ >= nelems;
 }
 
 
@@ -842,9 +842,9 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_embed>::iterate (unsigned ix, T *ptr) const
 {
-  if (ix < pfx_PRIVATE_.num_PRIVATE_)
+  if (ix < vecpfx_.num_)
     {
-      *ptr = data_PRIVATE_[ix];
+      *ptr = vecdata_[ix];
       return true;
     }
   else
@@ -868,9 +868,9 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_embed>::iterate (unsigned ix, T **ptr) const
 {
-  if (ix < pfx_PRIVATE_.num_PRIVATE_)
+  if (ix < vecpfx_.num_)
     {
-      *ptr = CONST_CAST (T *, &data_PRIVATE_[ix]);
+      *ptr = CONST_CAST (T *, &vecdata_[ix]);
       return true;
     }
   else
@@ -893,7 +893,7 @@ vec<T, A, vl_embed>::copy (ALONE_MEM_STA
     {
       vec_alloc (new_vec, len PASS_MEM_STAT);
       new_vec->embedded_init (len, len);
-      memcpy (new_vec->address(), data_PRIVATE_, sizeof (T) * len);
+      memcpy (new_vec->address(), vecdata_, sizeof (T) * len);
     }
   return new_vec;
 }
@@ -911,7 +911,7 @@ vec<T, A, vl_embed>::splice (vec<T, A, v
     {
       gcc_checking_assert (space (len));
       memcpy (address() + length(), src.address(), len * sizeof (T));
-      pfx_PRIVATE_.num_PRIVATE_ += len;
+      vecpfx_.num_ += len;
     }
 }
 
@@ -933,7 +933,7 @@ inline T *
 vec<T, A, vl_embed>::quick_push (const T &obj)
 {
   gcc_checking_assert (space (1));
-  T *slot = &data_PRIVATE_[pfx_PRIVATE_.num_PRIVATE_++];
+  T *slot = &vecdata_[vecpfx_.num_++];
   *slot = obj;
   return slot;
 }
@@ -946,7 +946,7 @@ inline T &
 vec<T, A, vl_embed>::pop (void)
 {
   gcc_checking_assert (length () > 0);
-  return data_PRIVATE_[--pfx_PRIVATE_.num_PRIVATE_];
+  return vecdata_[--vecpfx_.num_];
 }
 
 
@@ -958,7 +958,7 @@ inline void
 vec<T, A, vl_embed>::truncate (unsigned size)
 {
   gcc_checking_assert (length () >= size);
-  pfx_PRIVATE_.num_PRIVATE_ = size;
+  vecpfx_.num_ = size;
 }
 
 
@@ -971,8 +971,8 @@ vec<T, A, vl_embed>::quick_insert (unsig
 {
   gcc_checking_assert (length () < allocated ());
   gcc_checking_assert (ix <= length ());
-  T *slot = &data_PRIVATE_[ix];
-  memmove (slot + 1, slot, (pfx_PRIVATE_.num_PRIVATE_++ - ix) * sizeof (T));
+  T *slot = &vecdata_[ix];
+  memmove (slot + 1, slot, (vecpfx_.num_++ - ix) * sizeof (T));
   *slot = obj;
 }
 
@@ -986,8 +986,8 @@ inline void
 vec<T, A, vl_embed>::ordered_remove (unsigned ix)
 {
   gcc_checking_assert (ix < length());
-  T *slot = &data_PRIVATE_[ix];
-  memmove (slot, slot + 1, (--pfx_PRIVATE_.num_PRIVATE_ - ix) * sizeof (T));
+  T *slot = &vecdata_[ix];
+  memmove (slot, slot + 1, (--vecpfx_.num_ - ix) * sizeof (T));
 }
 
 
@@ -999,7 +999,7 @@ inline void
 vec<T, A, vl_embed>::unordered_remove (unsigned ix)
 {
   gcc_checking_assert (ix < length());
-  data_PRIVATE_[ix] = data_PRIVATE_[--pfx_PRIVATE_.num_PRIVATE_];
+  vecdata_[ix] = vecdata_[--vecpfx_.num_];
 }
 
 
@@ -1011,9 +1011,9 @@ inline void
 vec<T, A, vl_embed>::block_remove (unsigned ix, unsigned len)
 {
   gcc_checking_assert (ix + len <= length());
-  T *slot = &data_PRIVATE_[ix];
-  pfx_PRIVATE_.num_PRIVATE_ -= len;
-  memmove (slot, slot + len, (pfx_PRIVATE_.num_PRIVATE_ - ix) * sizeof (T));
+  T *slot = &vecdata_[ix];
+  vecpfx_.num_ -= len;
+  memmove (slot, slot + len, (vecpfx_.num_ - ix) * sizeof (T));
 }
 
 
@@ -1077,7 +1077,7 @@ inline size_t
 vec<T, A, vl_embed>::embedded_size (unsigned alloc)
 {
   typedef vec<T, A, vl_embed> vec_embedded;
-  return offsetof (vec_embedded, data_PRIVATE_) + alloc * sizeof (T);
+  return offsetof (vec_embedded, vecdata_) + alloc * sizeof (T);
 }
 
 
@@ -1088,8 +1088,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_embed>::embedded_init (unsigned alloc, unsigned num)
 {
-  pfx_PRIVATE_.alloc_PRIVATE_ = alloc;
-  pfx_PRIVATE_.num_PRIVATE_ = num;
+  vecpfx_.alloc_ = alloc;
+  vecpfx_.num_ = num;
 }
 
 
@@ -1100,8 +1100,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_embed>::quick_grow (unsigned len)
 {
-  gcc_checking_assert (length () <= len && len <= pfx_PRIVATE_.alloc_PRIVATE_);
-  pfx_PRIVATE_.num_PRIVATE_ = len;
+  gcc_checking_assert (length () <= len && len <= vecpfx_.alloc_);
+  vecpfx_.num_ = len;
 }
 
 
@@ -1206,22 +1206,22 @@ public:
 
   /* Vector operations.  */
   bool exists (void) const
-  { return vec_PRIVATE_ != NULL; }
+  { return vec_ != NULL; }
 
   bool is_empty (void) const
-  { return vec_PRIVATE_ ? vec_PRIVATE_->is_empty() : true; }
+  { return vec_ ? vec_->is_empty() : true; }
 
   unsigned length (void) const
-  { return vec_PRIVATE_ ? vec_PRIVATE_->length() : 0; }
+  { return vec_ ? vec_->length() : 0; }
 
   T *address (void)
-  { return vec_PRIVATE_ ? vec_PRIVATE_->data_PRIVATE_ : NULL; }
+  { return vec_ ? vec_->vecdata_ : NULL; }
 
   const T *address (void) const
-  { return vec_PRIVATE_ ? vec_PRIVATE_->data_PRIVATE_ : NULL; }
+  { return vec_ ? vec_->vecdata_ : NULL; }
 
   const T &operator[] (unsigned ix) const
-  { return (*vec_PRIVATE_)[ix]; }
+  { return (*vec_)[ix]; }
 
   bool operator!=(const vec &other) const
   { return !(*this == other); }
@@ -1230,13 +1230,13 @@ public:
   { return address() == other.address(); }
 
   T &operator[] (unsigned ix)
-  { return (*vec_PRIVATE_)[ix]; }
+  { return (*vec_)[ix]; }
 
   T &last (void)
-  { return vec_PRIVATE_->last(); }
+  { return vec_->last(); }
 
   bool space (int nelems) const
-  { return vec_PRIVATE_ ? vec_PRIVATE_->space (nelems) : nelems == 0; }
+  { return vec_ ? vec_->space (nelems) : nelems == 0; }
 
   bool iterate (unsigned ix, T *p) const;
   bool iterate (unsigned ix, T **p) const;
@@ -1267,7 +1267,7 @@ public:
 
   /* FIXME - This field should be private, but we need to cater to
 	     compilers that have stricter notions of PODness for types.  */
-  vec<T, A, vl_embed> *vec_PRIVATE_;
+  vec<T, A, vl_embed> *vec_;
 };
 
 
@@ -1370,8 +1370,8 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_ptr>::iterate (unsigned ix, T *ptr) const
 {
-  if (vec_PRIVATE_)
-    return vec_PRIVATE_->iterate (ix, ptr);
+  if (vec_)
+    return vec_->iterate (ix, ptr);
   else
     {
       *ptr = 0;
@@ -1393,8 +1393,8 @@ template<typename T, typename A>
 inline bool
 vec<T, A, vl_ptr>::iterate (unsigned ix, T **ptr) const
 {
-  if (vec_PRIVATE_)
-    return vec_PRIVATE_->iterate (ix, ptr);
+  if (vec_)
+    return vec_->iterate (ix, ptr);
   else
     {
       *ptr = 0;
@@ -1434,7 +1434,7 @@ vec<T, A, vl_ptr>::copy (ALONE_MEM_STAT_
 {
   vec<T, A, vl_ptr> new_vec = vec<T, A, vl_ptr>();
   if (length ())
-    new_vec.vec_PRIVATE_ = vec_PRIVATE_->copy ();
+    new_vec.vec_ = vec_->copy ();
   return new_vec;
 }
 
@@ -1454,7 +1454,7 @@ vec<T, A, vl_ptr>::reserve (unsigned nel
 {
   bool extend = nelems ? !space (nelems) : false;
   if (extend)
-    A::reserve (vec_PRIVATE_, nelems, exact PASS_MEM_STAT);
+    A::reserve (vec_, nelems, exact PASS_MEM_STAT);
   return extend;
 }
 
@@ -1481,7 +1481,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::create (unsigned nelems MEM_STAT_DECL)
 {
-  vec_PRIVATE_ = NULL;
+  vec_ = NULL;
   if (nelems > 0)
     reserve_exact (nelems PASS_MEM_STAT);
 }
@@ -1493,8 +1493,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::release (void)
 {
-  if (vec_PRIVATE_)
-    A::release (vec_PRIVATE_);
+  if (vec_)
+    A::release (vec_);
 }
 
 
@@ -1507,8 +1507,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::splice (vec<T, A, vl_ptr> &src)
 {
-  if (src.vec_PRIVATE_)
-    vec_PRIVATE_->splice (*(src.vec_PRIVATE_));
+  if (src.vec_)
+    vec_->splice (*(src.vec_));
 }
 
 
@@ -1537,7 +1537,7 @@ template<typename T, typename A>
 inline T *
 vec<T, A, vl_ptr>::quick_push (const T &obj)
 {
-  return vec_PRIVATE_->quick_push (obj);
+  return vec_->quick_push (obj);
 }
 
 
@@ -1560,7 +1560,7 @@ template<typename T, typename A>
 inline T &
 vec<T, A, vl_ptr>::pop (void)
 {
-  return vec_PRIVATE_->pop ();
+  return vec_->pop ();
 }
 
 
@@ -1571,8 +1571,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::truncate (unsigned size)
 {
-  if (vec_PRIVATE_)
-    vec_PRIVATE_->truncate (size);
+  if (vec_)
+    vec_->truncate (size);
   else
     gcc_checking_assert (size == 0);
 }
@@ -1589,7 +1589,7 @@ vec<T, A, vl_ptr>::safe_grow (unsigned l
   unsigned oldlen = length ();
   gcc_checking_assert (oldlen <= len);
   reserve_exact (len - oldlen PASS_MEM_STAT);
-  vec_PRIVATE_->quick_grow (len);
+  vec_->quick_grow (len);
 }
 
 
@@ -1614,8 +1614,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::quick_grow (unsigned len)
 {
-  gcc_checking_assert (vec_PRIVATE_);
-  vec_PRIVATE_->quick_grow (len);
+  gcc_checking_assert (vec_);
+  vec_->quick_grow (len);
 }
 
 
@@ -1627,8 +1627,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::quick_grow_cleared (unsigned len)
 {
-  gcc_checking_assert (vec_PRIVATE_);
-  vec_PRIVATE_->quick_grow_cleared (len);
+  gcc_checking_assert (vec_);
+  vec_->quick_grow_cleared (len);
 }
 
 
@@ -1639,7 +1639,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::quick_insert (unsigned ix, const T &obj)
 {
-  vec_PRIVATE_->quick_insert (ix, obj);
+  vec_->quick_insert (ix, obj);
 }
 
 
@@ -1663,7 +1663,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::ordered_remove (unsigned ix)
 {
-  vec_PRIVATE_->ordered_remove (ix);
+  vec_->ordered_remove (ix);
 }
 
 
@@ -1674,7 +1674,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::unordered_remove (unsigned ix)
 {
-  vec_PRIVATE_->unordered_remove (ix);
+  vec_->unordered_remove (ix);
 }
 
 
@@ -1685,7 +1685,7 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::block_remove (unsigned ix, unsigned len)
 {
-  vec_PRIVATE_->block_remove (ix, len);
+  vec_->block_remove (ix, len);
 }
 
 
@@ -1696,8 +1696,8 @@ template<typename T, typename A>
 inline void
 vec<T, A, vl_ptr>::qsort (int (*cmp) (const void *, const void *))
 {
-  if (vec_PRIVATE_)
-    vec_PRIVATE_->qsort (cmp);
+  if (vec_)
+    vec_->qsort (cmp);
 }
 
 
@@ -1711,7 +1711,11 @@ inline unsigned
 vec<T, A, vl_ptr>::lower_bound (T obj, bool (*lessthan)(const T &, const T &))
     const
 {
-  return vec_PRIVATE_ ? vec_PRIVATE_->lower_bound (obj, lessthan) : 0;
+  return vec_ ? vec_->lower_bound (obj, lessthan) : 0;
 }
 
+#if (GCC_VERSION >= 3000)
+# pragma GCC poison vec_ vecpfx_ vecdata_
+#endif
+
 #endif // GCC_VEC_H
--- gcc/vec.c.jj	2012-11-20 18:29:44.000000000 +0100
+++ gcc/vec.c	2012-11-20 18:38:31.387034012 +0100
@@ -121,8 +121,8 @@ vec_descriptor (const char *name, int li
 /* Account the overhead.  */
 
 void
-vec_prefix::register_overhead_PRIVATE_ (size_t size, const char *name, int line,
-			                const char *function)
+vec_prefix::register_overhead (size_t size, const char *name, int line,
+			       const char *function)
 {
   struct vec_descriptor *loc = vec_descriptor (name, line, function);
   struct ptr_hash_entry *p = XNEW (struct ptr_hash_entry);
@@ -148,7 +148,7 @@ vec_prefix::register_overhead_PRIVATE_ (
 /* Notice that the memory allocated for the vector has been freed.  */
 
 void
-vec_prefix::release_overhead_PRIVATE_ (void)
+vec_prefix::release_overhead (void)
 {
   PTR *slot = htab_find_slot_with_hash (ptr_hash, this,
 					htab_hash_pointer (this),
@@ -165,16 +165,16 @@ vec_prefix::release_overhead_PRIVATE_ (v
    exponentially.  PFX is the control data for the vector.  */
 
 unsigned
-vec_prefix::calculate_allocation_PRIVATE_ (vec_prefix *pfx, unsigned reserve,
-					   bool exact)
+vec_prefix::calculate_allocation (vec_prefix *pfx, unsigned reserve,
+				  bool exact)
 {
   unsigned alloc = 0;
   unsigned num = 0;
 
   if (pfx)
     {
-      alloc = pfx->alloc_PRIVATE_;
-      num = pfx->num_PRIVATE_;
+      alloc = pfx->alloc_;
+      num = pfx->num_;
     }
   else if (!reserve)
     /* If there's no vector, and we've not requested anything, then we


	Jakub

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

* Re: [PR middle-end/55398] Convert vec<> into a POD
  2012-11-20 19:36   ` Jakub Jelinek
@ 2012-11-20 19:49     ` Diego Novillo
  0 siblings, 0 replies; 6+ messages in thread
From: Diego Novillo @ 2012-11-20 19:49 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, Nov 20, 2012 at 2:35 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> 2012-11-20  Jakub Jelinek  <jakub@redhat.com>
>
>         * vec.h (class vec_prefix): Change into struct.
>         Rename field alloc_PRIVATE_ back to alloc_.
>         Rename field num_PRIVATE_ to num_.
>         Update all users.
>         (class vec<T, A, vl_embed>): Rename field pfx_PRIVATE_ to vecpfx_.
>         Rename field data_PRIVATE_ to vecdata_.
>         Update all users.
>         (class vec<T, A, vl_ptr>): Make every field public.
>         Rename field vec_PRIVATE_ back to vec_.
>         Update all users.

Much cleaner.  Thanks.  The patch is OK.


Diego.

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

* Re: [PR middle-end/55398] Convert vec<> into a POD
  2012-11-20 16:27 ` Diego Novillo
  2012-11-20 17:49   ` Andreas Tobler
  2012-11-20 19:36   ` Jakub Jelinek
@ 2012-11-20 20:11   ` Ulrich Weigand
  2 siblings, 0 replies; 6+ messages in thread
From: Ulrich Weigand @ 2012-11-20 20:11 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches

Diego Novillo wrote:
> On Tue, Nov 20, 2012 at 11:23 AM, Diego Novillo <dnovillo@google.com> wrote:
> 
> > 2012-11-20  Diego Novillo  <dnovillo@google.com>
> >
> >     PR middle-end/55398
> >     * vec.h (class vec_prefix): Make every field public.
> >     Rename field alloc_ to alloc_PRIVATE_.
> >     Rename field num_ to num_PRIVATE_.
> >     Update all users.
> >     (class vec<T, A, vl_embed>): Make every field public.
> >     Rename field pfx_ to pfx_PRIVATE_.
> >     Rename field data_ to data_PRIVATE_.
> >     Update all users.
> >     (class vec<T, A, vl_ptr>): Make every field public.
> >     Rename field vec_ to vec_PRIVATE_.
> >     Update all users.
> >     (va_heap::release): Do nothing if V is NULL.
> >     (va_stack::release): Likewise.
> 
> Committed as rev 193667.

This fixed the spu-elf build failure.  Thanks!

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

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

end of thread, other threads:[~2012-11-20 20:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-20 16:23 [PR middle-end/55398] Convert vec<> into a POD Diego Novillo
2012-11-20 16:27 ` Diego Novillo
2012-11-20 17:49   ` Andreas Tobler
2012-11-20 19:36   ` Jakub Jelinek
2012-11-20 19:49     ` Diego Novillo
2012-11-20 20:11   ` Ulrich Weigand

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