diff mbox

[1/2] Memory statistics enhancement.

Message ID 556ECBAF.8080404@suse.cz
State New
Headers show

Commit Message

Martin Liška June 3, 2015, 9:41 a.m. UTC
On 06/01/2015 06:16 PM, mliska wrote:
> Hi.
> 
> Following 2 patches improve memory statistics infrastructure. First one
> ports pool allocator to the new infrastructure. And the second one makes
> column alignment properly.
> 
> Both can bootstrap on x86_64-linux-pc and survive regression tests.
> 
> Ready for trunk?
> Thank you,
> Martin
> 
> Port pool-allocator memory stats to a new infrastructure.
> 
> gcc/ChangeLog:
> 
> 2015-06-02  Martin Liska  <mliska@suse.cz>
> 
> 	* alloc-pool.c (allocate_pool_descriptor): Remove.
> 	(struct pool_output_info): Likewise.
> 	(print_alloc_pool_statistics): Likewise.
> 	(dump_alloc_pool_statistics): Likewise.
> 	* alloc-pool.h (struct pool_usage): New struct.
> 	(pool_allocator::initialize): Change usage of memory statistics
> 	to a new interface.
> 	(pool_allocator::release): Likewise.
> 	(pool_allocator::allocate): Likewise.
> 	(pool_allocator::remove): Likewise.
> 	* mem-stats-traits.h (enum mem_alloc_origin): Add new enum value
> 	for a pool allocator.
> 	* mem-stats.h (struct mem_location): Add new ctor.
> 	(struct mem_usage): Add counter for number of
> 	instances.
> 	(mem_alloc_description::register_descriptor): New overload of
> 	the function.
> ---
>  gcc/alloc-pool.c       |  60 +----------------------------
>  gcc/alloc-pool.h       | 102 +++++++++++++++++++++++++++++++++++++++----------
>  gcc/mem-stats-traits.h |   3 +-
>  gcc/mem-stats.h        |  69 ++++++++++++++++++++++-----------
>  4 files changed, 132 insertions(+), 102 deletions(-)
> 
> diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
> index e9fdc86..601c2b7 100644
> --- a/gcc/alloc-pool.c
> +++ b/gcc/alloc-pool.c
> @@ -26,70 +26,14 @@ along with GCC; see the file COPYING3.  If not see
>  #include "hash-map.h"
>  
>  ALLOC_POOL_ID_TYPE last_id;
> -
> -/* Hashtable mapping alloc_pool names to descriptors.  */
> -hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash;
> -
> -struct alloc_pool_descriptor *
> -allocate_pool_descriptor (const char *name)
> -{
> -  if (!alloc_pool_hash)
> -    alloc_pool_hash = new hash_map<const char *, alloc_pool_descriptor> (10,
> -									 false,
> -									 false);
> -
> -  return &alloc_pool_hash->get_or_insert (name);
> -}
> -
> -/* Output per-alloc_pool statistics.  */
> -
> -/* Used to accumulate statistics about alloc_pool sizes.  */
> -struct pool_output_info
> -{
> -  unsigned long total_created;
> -  unsigned long total_allocated;
> -};
> -
> -/* Called via hash_map.traverse.  Output alloc_pool descriptor pointed out by
> -   SLOT and update statistics.  */
> -bool
> -print_alloc_pool_statistics (const char *const &name,
> -			     const alloc_pool_descriptor &d,
> -			     struct pool_output_info *i)
> -{
> -  if (d.allocated)
> -    {
> -      fprintf (stderr,
> -	       "%-22s %6d %10lu %10lu(%10lu) %10lu(%10lu) %10lu(%10lu)\n",
> -	       name, d.elt_size, d.created, d.allocated,
> -	       d.allocated / d.elt_size, d.peak, d.peak / d.elt_size,
> -	       d.current, d.current / d.elt_size);
> -      i->total_allocated += d.allocated;
> -      i->total_created += d.created;
> -    }
> -  return 1;
> -}
> +mem_alloc_description<pool_usage> pool_allocator_usage;
>  
>  /* Output per-alloc_pool memory usage statistics.  */
>  void
>  dump_alloc_pool_statistics (void)
>  {
> -  struct pool_output_info info;
> -
>    if (! GATHER_STATISTICS)
>      return;
>  
> -  if (!alloc_pool_hash)
> -    return;
> -
> -  fprintf (stderr, "\nAlloc-pool Kind         Elt size  Pools  Allocated (elts)            Peak (elts)            Leak (elts)\n");
> -  fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
> -  info.total_created = 0;
> -  info.total_allocated = 0;
> -  alloc_pool_hash->traverse <struct pool_output_info *,
> -			     print_alloc_pool_statistics> (&info);
> -  fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
> -  fprintf (stderr, "%-22s           %7lu %10lu\n",
> -	   "Total", info.total_created, info.total_allocated);
> -  fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
> +  pool_allocator_usage.dump (ALLOC_POOL);
>  }
> diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
> index 96a1342..a1727ce 100644
> --- a/gcc/alloc-pool.h
> +++ b/gcc/alloc-pool.h
> @@ -26,6 +26,71 @@ extern void dump_alloc_pool_statistics (void);
>  
>  typedef unsigned long ALLOC_POOL_ID_TYPE;
>  
> +/* Pool allocator memory usage.  */
> +struct pool_usage: public mem_usage
> +{
> +  /* Default contructor.  */
> +  pool_usage (): m_element_size (0), m_pool_name ("") {}
> +  /* Constructor.  */
> +  pool_usage (size_t allocated, size_t times, size_t peak,
> +	      size_t instances, size_t element_size,
> +	      const char *pool_name)
> +    : mem_usage (allocated, times, peak, instances),
> +      m_element_size (element_size),
> +      m_pool_name (pool_name) {}
> +
> +  /* Sum the usage with SECOND usage.  */
> +  pool_usage operator+ (const pool_usage &second)
> +  {
> +    return pool_usage (m_allocated + second.m_allocated,
> +			     m_times + second.m_times,
> +			     m_peak + second.m_peak,
> +			     m_instances + second.m_instances,
> +			     m_element_size, m_pool_name);
> +  }
> +
> +  /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
> +  inline void dump (mem_location *loc, mem_usage &total) const
> +  {
> +    char s[4096];
> +    sprintf (s, "%s:%i (%s)", loc->get_trimmed_filename (),
> +	     loc->m_line, loc->m_function);
> +
> +    s[48] = '\0';
> +
> +    fprintf (stderr, "%-32s%-48s %6li%10li:%5.1f%%%10li%10li:%5.1f%%%12li\n",
> +	     m_pool_name, s, (long)m_instances,
> +	     (long)m_allocated, get_percent (m_allocated, total.m_allocated),
> +	     (long)m_peak, (long)m_times,
> +	     get_percent (m_times, total.m_times),
> +	     (long)m_element_size);
> +  }
> +
> +  /* Dump header with NAME.  */
> +  static inline void dump_header (const char *name)
> +  {
> +    fprintf (stderr, "%-32s%-48s %6s%11s%16s%17s%12s\n", "Pool name", name,
> +	     "Pools", "Leak", "Peak", "Times", "Elt size");
> +    print_dash_line ();
> +  }
> +
> +  /* Dump footer.  */
> +  inline void dump_footer ()
> +  {
> +    print_dash_line ();
> +    fprintf (stderr, "%s%75li%10li\n", "Total", (long)m_instances,
> +	     (long)m_allocated);
> +    print_dash_line ();
> +  }
> +
> +  /* Element size.  */
> +  size_t m_element_size;
> +  /* Pool name.  */
> +  const char *m_pool_name;
> +};
> +
> +extern mem_alloc_description<pool_usage> pool_allocator_usage;
> +
>  /* Type based memory pool allocator.  */
>  template <typename T>
>  class pool_allocator
> @@ -35,7 +100,7 @@ public:
>       has NUM elements.  The allocator support EXTRA_SIZE and can
>       potentially IGNORE_TYPE_SIZE.  */
>    pool_allocator (const char *name, size_t num, size_t extra_size = 0,
> -		  bool ignore_type_size = false);
> +		  bool ignore_type_size = false CXX_MEM_STAT_INFO);
>    ~pool_allocator ();
>    void release ();
>    void release_if_empty ();
> @@ -122,6 +187,8 @@ private:
>    size_t m_extra_size;
>    /* Flag if a pool allocator is initialized.  */
>    bool m_initialized;
> +  /* Memory allocation location.  */
> +  mem_location m_location;
>  };
>  
>  /* Last used ID.  */
> @@ -151,19 +218,16 @@ struct alloc_pool_descriptor
>  /* Hashtable mapping alloc_pool names to descriptors.  */
>  extern hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash;
>  
> -/* For given name, return descriptor, create new if needed.  */
> -alloc_pool_descriptor *
> -allocate_pool_descriptor (const char *name);
> -
>  template <typename T>
>  inline
>  pool_allocator<T>::pool_allocator (const char *name, size_t num,
> -				   size_t extra_size, bool ignore_type_size):
> +				   size_t extra_size, bool ignore_type_size
> +				   MEM_STAT_DECL):
>    m_name (name), m_elts_per_block (num), m_returned_free_list (NULL),
>    m_virgin_free_list (NULL), m_virgin_elts_remaining (0), m_elts_allocated (0),
>    m_elts_free (0), m_blocks_allocated (0), m_block_list (NULL),
>    m_ignore_type_size (ignore_type_size), m_extra_size (extra_size),
> -  m_initialized (false) {}
> +  m_initialized (false), m_location (ALLOC_POOL, false PASS_MEM_STAT) {}
>  
>  /* Initialize a pool allocator.  */
>  
> @@ -196,9 +260,11 @@ pool_allocator<T>::initialize ()
>  
>    if (GATHER_STATISTICS)
>      {
> -      alloc_pool_descriptor *desc = allocate_pool_descriptor (m_name);
> -      desc->elt_size = size;
> -      desc->created++;
> +      pool_usage *u = pool_allocator_usage.register_descriptor
> +	(this, new mem_location (m_location));
> +
> +      u->m_element_size = m_elt_size;
> +      u->m_pool_name = m_name;
>      }
>  
>    /* List header size should be a multiple of 8.  */
> @@ -235,10 +301,10 @@ pool_allocator<T>::release ()
>        free (block);
>      }
>  
> -  if (GATHER_STATISTICS && false)
> +  if (GATHER_STATISTICS)
>      {
> -      alloc_pool_descriptor *desc = allocate_pool_descriptor (m_name);
> -      desc->current -= (m_elts_allocated - m_elts_free) * m_elt_size;
> +      pool_allocator_usage.release_instance_overhead (this,
> +	(m_elts_allocated - m_elts_free) * m_elt_size);
>      }
>  
>    m_returned_free_list = NULL;
> @@ -279,12 +345,7 @@ pool_allocator<T>::allocate ()
>  
>    if (GATHER_STATISTICS)
>      {
> -      alloc_pool_descriptor *desc = allocate_pool_descriptor (m_name);
> -
> -      desc->allocated += m_elt_size;
> -      desc->current += m_elt_size;
> -      if (desc->peak < desc->current)
> -	desc->peak = desc->current;
> +      pool_allocator_usage.register_instance_overhead (m_elt_size, this);
>      }
>  
>  #ifdef ENABLE_VALGRIND_ANNOTATIONS
> @@ -383,8 +444,7 @@ pool_allocator<T>::remove (T *object)
>  
>    if (GATHER_STATISTICS)
>      {
> -      alloc_pool_descriptor *desc = allocate_pool_descriptor (m_name);
> -      desc->current -= m_elt_size;
> +      pool_allocator_usage.release_instance_overhead (this, m_elt_size);
>      }
>  }
>  
> diff --git a/gcc/mem-stats-traits.h b/gcc/mem-stats-traits.h
> index de1614e..f7843f2 100644
> --- a/gcc/mem-stats-traits.h
> +++ b/gcc/mem-stats-traits.h
> @@ -10,11 +10,12 @@ enum mem_alloc_origin
>    VEC,
>    BITMAP,
>    GGC,
> +  ALLOC_POOL,
>    MEM_ALLOC_ORIGIN_LENGTH
>  };
>  
>  /* Verbose names of the memory allocation origin.  */
>  static const char * mem_alloc_origin_names[] = { "Hash tables", "Hash maps",
> -  "Hash sets", "Heap vectors", "Bitmaps", "GGC memory" };
> +  "Hash sets", "Heap vectors", "Bitmaps", "GGC memory", "Allocation pool" };
>  
>  #endif // GCC_MEM_STATS_TRAITS_H
> diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
> index ac47231..fea68fa 100644
> --- a/gcc/mem-stats.h
> +++ b/gcc/mem-stats.h
> @@ -18,11 +18,16 @@ struct mem_location
>    inline mem_location () {}
>  
>    /* Constructor.  */
> -  inline mem_location (const char *filename, const char *function, int line,
> -		mem_alloc_origin origin, bool ggc):
> +  inline mem_location (mem_alloc_origin origin, bool ggc,
> +		const char *filename = NULL, int line = 0, const char *function = NULL):
>      m_filename (filename), m_function (function), m_line (line), m_origin
>      (origin), m_ggc (ggc) {}
>  
> +  /* Copy constructor.  */
> +  inline mem_location (mem_location &other): m_filename (other.m_filename),
> +    m_function (other.m_function), m_line (other.m_line),
> +    m_origin (other.m_origin), m_ggc (other.m_ggc) {}
> +
>    /* Compute hash value based on file name, function name and line in
>       source code. As there is just a single pointer registered for every
>       constant that points to e.g. the same file name, we can use hash
> @@ -79,11 +84,12 @@ struct mem_location
>  struct mem_usage
>  {
>    /* Default constructor.  */
> -  mem_usage (): m_allocated (0), m_times (0), m_peak (0) {}
> +  mem_usage (): m_allocated (0), m_times (0), m_peak (0), m_instances (1) {}
>  
>    /* Constructor.  */
> -  mem_usage (size_t allocated, size_t times, size_t peak):
> -    m_allocated (allocated), m_times (times), m_peak (peak) {}
> +  mem_usage (size_t allocated, size_t times, size_t peak, size_t instances = 0):
> +    m_allocated (allocated), m_times (times), m_peak (peak),
> +    m_instances (instances) {}
>  
>    /* Register overhead of SIZE bytes.  */
>    inline void register_overhead (size_t size)
> @@ -108,7 +114,8 @@ struct mem_usage
>    {
>      return mem_usage (m_allocated + second.m_allocated,
>  		      m_times + second.m_times,
> -		      m_peak + second.m_peak);
> +		      m_peak + second.m_peak,
> +		      m_instances + second.m_instances);
>    }
>  
>    /* Comparison operator.  */
> @@ -163,7 +170,7 @@ struct mem_usage
>    /* Print line made of dashes.  */
>    static inline void print_dash_line ()
>    {
> -    fprintf (stderr, "%s\n", std::string (128, '-').c_str ());
> +    fprintf (stderr, "%s\n", std::string (140, '-').c_str ());
>    }
>  
>    /* Dump header with NAME.  */
> @@ -180,6 +187,8 @@ struct mem_usage
>    size_t m_times;
>    /* Peak allocation in bytes.  */
>    size_t m_peak;
> +  /* Number of container instances.  */
> +  size_t m_instances;
>  };
>  
>  /* Memory usage pair that connectes memory usage and number
> @@ -241,9 +250,13 @@ public:
>    /* Return descriptor for instance PTR.  */
>    T *get_descriptor_for_instance (const void *ptr);
>  
> -  /* Register memory allocation descriptor for container PTR. ORIGIN identifies
> +  /* Register memory allocation descriptor for container PTR which is
> +     described by a memory LOCATION.  */
> +  T *register_descriptor (const void *ptr, mem_location *location);
> +
> +  /* Register memory allocation descriptor for container PTR.  ORIGIN identifies
>       type of container and GGC identifes if the allocation is handled in GGC
> -     memory. Each location is identified by file NAME, LINE in source code and
> +     memory.  Each location is identified by file NAME, LINE in source code and
>       FUNCTION name.  */
>    T *register_descriptor (const void *ptr, mem_alloc_origin origin,
>  			  bool ggc, const char *name, int line,
> @@ -321,33 +334,27 @@ mem_alloc_description<T>::get_descriptor_for_instance (const void *ptr)
>    return m_reverse_map->get (ptr) ? (*m_reverse_map->get (ptr)).usage : NULL;
>  }
>  
> -/* Register memory allocation descriptor for container PTR. ORIGIN identifies
> -   type of container and GGC identifes if the allocation is handled in GGC
> -   memory. Each location is identified by file NAME, LINE in source code and
> -   FUNCTION name.  */
>  
> +  /* Register memory allocation descriptor for container PTR which is
> +     described by a memory LOCATION.  */
>  template <class T>
>  inline T*
>  mem_alloc_description<T>::register_descriptor (const void *ptr,
> -					       mem_alloc_origin origin,
> -					       bool ggc,
> -					       const char *filename,
> -					       int line,
> -					       const char *function)
> +					       mem_location *location)
>  {
> -  mem_location *l = new mem_location (filename, function, line, origin, ggc);
>    T *usage = NULL;
>  
> -  T **slot = m_map->get (l);
> +  T **slot = m_map->get (location);
>    if (slot)
>      {
> -      delete l;
> +      delete location;
>        usage = *slot;
> +      usage->m_instances++;
>      }
>    else
>      {
>        usage = new T ();
> -      m_map->put (l, usage);
> +      m_map->put (location, usage);
>      }
>  
>    if (!m_reverse_map->get (ptr))
> @@ -356,6 +363,24 @@ mem_alloc_description<T>::register_descriptor (const void *ptr,
>    return usage;
>  }
>  
> +/* Register memory allocation descriptor for container PTR.  ORIGIN identifies
> +   type of container and GGC identifes if the allocation is handled in GGC
> +   memory.  Each location is identified by file NAME, LINE in source code and
> +   FUNCTION name.  */
> +
> +template <class T>
> +inline T*
> +mem_alloc_description<T>::register_descriptor (const void *ptr,
> +					       mem_alloc_origin origin,
> +					       bool ggc,
> +					       const char *filename,
> +					       int line,
> +					       const char *function)
> +{
> +  mem_location *l = new mem_location (origin, ggc, filename, line, function);
> +  return register_descriptor (ptr, l);
> +}
> +
>  /* Register instance overhead identified by PTR pointer. Allocation takes
>     SIZE bytes.  */
>  
> 

Hello.

This fix changes all function definitions (related to memory statistics infrastructure)
with respect to GNU coding style.

Ready for trunk?
Thanks,
Martin

Comments

Jeff Law June 3, 2015, 1:19 p.m. UTC | #1
On 06/03/2015 03:41 AM, Martin Liška wrote:
>
>  From a52eecf7c78f2eee0ccac662459e89ddbedd0244 Mon Sep 17 00:00:00 2001
> From: mliska<mliska@suse.cz>
> Date: Wed, 3 Jun 2015 11:37:01 +0200
> Subject: [PATCH] Fix GNU coding style in memory statistics.
>
> gcc/ChangeLog:
>
> 2015-06-03  Martin Liska<mliska@suse.cz>
>
> 	* alloc-pool.h (struct pool_usage): Correct GNU coding style.
> 	* bitmap.h (struct bitmap_usage): Likewise.
> 	* ggc-common.c (struct ggc_usage): Likewise.
> 	* mem-stats.h (struct mem_location): Likewise.
> 	(struct mem_usage): Likewise.
> 	* vec.c (struct vec_usage): Likewise.
OK.
jeff
diff mbox

Patch

From a52eecf7c78f2eee0ccac662459e89ddbedd0244 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Wed, 3 Jun 2015 11:37:01 +0200
Subject: [PATCH] Fix GNU coding style in memory statistics.

gcc/ChangeLog:

2015-06-03  Martin Liska  <mliska@suse.cz>

	* alloc-pool.h (struct pool_usage): Correct GNU coding style.
	* bitmap.h (struct bitmap_usage): Likewise.
	* ggc-common.c (struct ggc_usage): Likewise.
	* mem-stats.h (struct mem_location): Likewise.
	(struct mem_usage): Likewise.
	* vec.c (struct vec_usage): Likewise.
---
 gcc/alloc-pool.h | 21 +++++++++-----
 gcc/bitmap.h     |  9 ++++--
 gcc/ggc-common.c | 36 +++++++++++++++--------
 gcc/mem-stats.h  | 87 +++++++++++++++++++++++++++++++++++++-------------------
 gcc/vec.c        | 18 ++++++++----
 5 files changed, 113 insertions(+), 58 deletions(-)

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index b10cfa4..ed0cb6d 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -40,7 +40,8 @@  struct pool_usage: public mem_usage
       m_pool_name (pool_name) {}
 
   /* Sum the usage with SECOND usage.  */
-  pool_usage operator+ (const pool_usage &second)
+  pool_usage
+  operator+ (const pool_usage &second)
   {
     return pool_usage (m_allocated + second.m_allocated,
 			     m_times + second.m_times,
@@ -50,7 +51,8 @@  struct pool_usage: public mem_usage
   }
 
   /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
-  inline void dump (mem_location *loc, mem_usage &total) const
+  inline void
+  dump (mem_location *loc, mem_usage &total) const
   {
     char *location_string = loc->to_string ();
 
@@ -65,7 +67,8 @@  struct pool_usage: public mem_usage
   }
 
   /* Dump header with NAME.  */
-  static inline void dump_header (const char *name)
+  static inline void
+  dump_header (const char *name)
   {
     fprintf (stderr, "%-32s%-48s %6s%11s%16s%17s%12s\n", "Pool name", name,
 	     "Pools", "Leak", "Peak", "Times", "Elt size");
@@ -73,7 +76,8 @@  struct pool_usage: public mem_usage
   }
 
   /* Dump footer.  */
-  inline void dump_footer ()
+  inline void
+  dump_footer ()
   {
     print_dash_line ();
     fprintf (stderr, "%s%82li%10li\n", "Total", (long)m_instances,
@@ -133,21 +137,24 @@  private:
 	int64_t align_i;
       } u;
 
-    static inline allocation_object<U> *get_instance (void *data_ptr)
+    static inline allocation_object<U> *
+    get_instance (void *data_ptr)
     {
       return (allocation_object<U> *)(((char *)(data_ptr))
 				      - offsetof (allocation_object<U>,
 						  u.data));
     }
 
-    static inline U *get_data (void *instance_ptr)
+    static inline U *
+    get_data (void *instance_ptr)
     {
       return (U*)(((allocation_object<U> *) instance_ptr)->u.data);
     }
   };
 
   /* Align X to 8.  */
-  size_t align_eight (size_t x)
+  size_t
+  align_eight (size_t x)
   {
     return (((x+7) >> 3) << 3);
   }
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index 4309f6d..1d37bca 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -144,7 +144,8 @@  struct bitmap_usage: public mem_usage
     m_nsearches (nsearches), m_search_iter (search_iter) {}
 
   /* Sum the usage with SECOND usage.  */
-  bitmap_usage operator+ (const bitmap_usage &second)
+  bitmap_usage
+  operator+ (const bitmap_usage &second)
   {
     return bitmap_usage (m_allocated + second.m_allocated,
 			     m_times + second.m_times,
@@ -154,7 +155,8 @@  struct bitmap_usage: public mem_usage
   }
 
   /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
-  inline void dump (mem_location *loc, mem_usage &total) const
+  inline void
+  dump (mem_location *loc, mem_usage &total) const
   {
     char *location_string = loc->to_string ();
 
@@ -170,7 +172,8 @@  struct bitmap_usage: public mem_usage
   }
 
   /* Dump header with NAME.  */
-  static inline void dump_header (const char *name)
+  static inline void
+  dump_header (const char *name)
   {
     fprintf (stderr, "%-48s %11s%16s%17s%12s%12s%10s\n", name, "Leak", "Peak",
 	     "Times", "N searches", "Search iter", "Type");
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 43ccc0b..cd81770 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -843,7 +843,8 @@  struct ggc_usage: public mem_usage
     m_freed (freed), m_collected (collected), m_overhead (overhead) {}
 
   /* Comparison operator.  */
-  inline bool operator< (const ggc_usage &second) const
+  inline bool
+  operator< (const ggc_usage &second) const
   {
     return (get_balance () == second.get_balance () ?
 	    (m_peak == second.m_peak ? m_times < second.m_times
@@ -852,7 +853,8 @@  struct ggc_usage: public mem_usage
   }
 
   /* Register overhead of ALLOCATED and OVERHEAD bytes.  */
-  inline void register_overhead (size_t allocated, size_t overhead)
+  inline void
+  register_overhead (size_t allocated, size_t overhead)
   {
     m_allocated += allocated;
     m_overhead += overhead;
@@ -860,13 +862,15 @@  struct ggc_usage: public mem_usage
   }
 
   /* Release overhead of SIZE bytes.  */
-  inline void release_overhead (size_t size)
+  inline void
+  release_overhead (size_t size)
   {
     m_freed += size;
   }
 
   /* Sum the usage with SECOND usage.  */
-  ggc_usage operator+ (const ggc_usage &second)
+  ggc_usage
+  operator+ (const ggc_usage &second)
   {
     return ggc_usage (m_allocated + second.m_allocated,
 		      m_times + second.m_times,
@@ -877,7 +881,8 @@  struct ggc_usage: public mem_usage
   }
 
   /* Dump usage with PREFIX, where TOTAL is sum of all rows.  */
-  inline void dump (const char *prefix, ggc_usage &total) const
+  inline void
+  dump (const char *prefix, ggc_usage &total) const
   {
     long balance = get_balance ();
     fprintf (stderr,
@@ -892,7 +897,8 @@  struct ggc_usage: public mem_usage
   }
 
   /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
-  inline void dump (mem_location *loc, ggc_usage &total) const
+  inline void
+  dump (mem_location *loc, ggc_usage &total) const
   {
     char *location_string = loc->to_string ();
 
@@ -902,7 +908,8 @@  struct ggc_usage: public mem_usage
   }
 
   /* Dump footer.  */
-  inline void dump_footer ()
+  inline void
+  dump_footer ()
   {
     print_dash_line ();
     dump ("Total", *this);
@@ -910,7 +917,8 @@  struct ggc_usage: public mem_usage
   }
 
   /* Get balance which is GGC allocation leak.  */
-  inline long get_balance () const
+  inline long
+  get_balance () const
   {
     return m_allocated + m_overhead - m_collected - m_freed;
   }
@@ -918,7 +926,8 @@  struct ggc_usage: public mem_usage
   typedef std::pair<mem_location *, ggc_usage *> mem_pair_t;
 
   /* Compare wrapper used by qsort method.  */
-  static int compare (const void *first, const void *second)
+  static int
+  compare (const void *first, const void *second)
   {
     const mem_pair_t f = *(const mem_pair_t *)first;
     const mem_pair_t s = *(const mem_pair_t *)second;
@@ -927,8 +936,10 @@  struct ggc_usage: public mem_usage
   }
 
   /* Compare rows in final GGC summary dump.  */
-  static int compare_final (const void *first, const void *second)
-  {  typedef std::pair<mem_location *, ggc_usage *> mem_pair_t;
+  static int
+  compare_final (const void *first, const void *second)
+  {
+    typedef std::pair<mem_location *, ggc_usage *> mem_pair_t;
 
     const ggc_usage *f = ((const mem_pair_t *)first)->second;
     const ggc_usage *s = ((const mem_pair_t *)second)->second;
@@ -940,7 +951,8 @@  struct ggc_usage: public mem_usage
   }
 
   /* Dump header with NAME.  */
-  static inline void dump_header (const char *name)
+  static inline void
+  dump_header (const char *name)
   {
     fprintf (stderr, "%-48s %11s%17s%17s%16s%17s\n", name, "Garbage", "Freed",
 	     "Leak", "Overhead", "Times");
diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
index 641f7c1..7524ff7 100644
--- a/gcc/mem-stats.h
+++ b/gcc/mem-stats.h
@@ -18,17 +18,20 @@  class hash_map;
 struct mem_location
 {
   /* Default constructor.  */
-  inline mem_location () {}
+  inline
+  mem_location () {}
 
   /* Constructor.  */
-  inline mem_location (mem_alloc_origin origin, bool ggc,
+  inline
+  mem_location (mem_alloc_origin origin, bool ggc,
 		const char *filename = NULL, int line = 0,
 		const char *function = NULL):
     m_filename (filename), m_function (function), m_line (line), m_origin
     (origin), m_ggc (ggc) {}
 
   /* Copy constructor.  */
-  inline mem_location (mem_location &other): m_filename (other.m_filename),
+  inline
+  mem_location (mem_location &other): m_filename (other.m_filename),
     m_function (other.m_function), m_line (other.m_line),
     m_origin (other.m_origin), m_ggc (other.m_ggc) {}
 
@@ -36,7 +39,8 @@  struct mem_location
      source code. As there is just a single pointer registered for every
      constant that points to e.g. the same file name, we can use hash
      of the pointer.  */
-  hashval_t hash ()
+  hashval_t
+  hash ()
   {
     inchash::hash hash;
 
@@ -48,14 +52,16 @@  struct mem_location
   }
 
   /* Return true if the memory location is equal to OTHER.  */
-  int equal (mem_location &other)
+  int
+  equal (mem_location &other)
   {
     return m_filename == other.m_filename && m_function == other.m_function
       && m_line == other.m_line;
   }
 
   /* Return trimmed filename for the location.  */
-  inline const char *get_trimmed_filename ()
+  inline const char *
+  get_trimmed_filename ()
   {
     const char *s1 = m_filename;
     const char *s2;
@@ -66,7 +72,8 @@  struct mem_location
     return s1;
   }
 
-  inline char *to_string ()
+  inline char *
+  to_string ()
   {
     unsigned l = strlen (get_trimmed_filename ()) + strlen (m_function)
       + LOCATION_LINE_EXTRA_SPACE;
@@ -81,7 +88,8 @@  struct mem_location
   }
 
   /* Return display name associated to ORIGIN type.  */
-  static const char *get_origin_name (mem_alloc_origin origin)
+  static const char *
+  get_origin_name (mem_alloc_origin origin)
   {
     return mem_alloc_origin_names[(unsigned) origin];
   }
@@ -110,7 +118,8 @@  struct mem_usage
     m_instances (instances) {}
 
   /* Register overhead of SIZE bytes.  */
-  inline void register_overhead (size_t size)
+  inline void
+  register_overhead (size_t size)
   {
     m_allocated += size;
     m_times++;
@@ -120,7 +129,8 @@  struct mem_usage
   }
 
   /* Release overhead of SIZE bytes.  */
-  inline void release_overhead (size_t size)
+  inline void
+  release_overhead (size_t size)
   {
     gcc_assert (size <= m_allocated);
 
@@ -128,7 +138,8 @@  struct mem_usage
   }
 
   /* Sum the usage with SECOND usage.  */
-  mem_usage operator+ (const mem_usage &second)
+  mem_usage
+  operator+ (const mem_usage &second)
   {
     return mem_usage (m_allocated + second.m_allocated,
 		      m_times + second.m_times,
@@ -137,7 +148,8 @@  struct mem_usage
   }
 
   /* Comparison operator.  */
-  inline bool operator< (const mem_usage &second) const
+  inline bool
+  operator< (const mem_usage &second) const
   {
     return (m_allocated == second.m_allocated ?
 	    (m_peak == second.m_peak ? m_times < second.m_times
@@ -145,7 +157,8 @@  struct mem_usage
   }
 
   /* Compare wrapper used by qsort method.  */
-  static int compare (const void *first, const void *second)
+  static int
+  compare (const void *first, const void *second)
   {
     typedef std::pair<mem_location *, mem_usage *> mem_pair_t;
 
@@ -156,7 +169,8 @@  struct mem_usage
   }
 
   /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
-  inline void dump (mem_location *loc, mem_usage &total) const
+  inline void
+  dump (mem_location *loc, mem_usage &total) const
   {
     char *location_string = loc->to_string ();
 
@@ -170,7 +184,8 @@  struct mem_usage
   }
 
   /* Dump footer.  */
-  inline void dump_footer () const
+  inline void
+  dump_footer () const
   {
     print_dash_line ();
     fprintf (stderr, "%s%54li%27li\n", "Total", (long)m_allocated,
@@ -179,19 +194,22 @@  struct mem_usage
   }
 
   /* Return fraction of NOMINATOR and DENOMINATOR in percent.  */
-  static inline float get_percent (size_t nominator, size_t denominator)
+  static inline float
+  get_percent (size_t nominator, size_t denominator)
   {
     return denominator == 0 ? 0.0f : nominator * 100.0 / denominator;
   }
 
   /* Print line made of dashes.  */
-  static inline void print_dash_line (size_t count = 140)
+  static inline void
+  print_dash_line (size_t count = 140)
   {
     fprintf (stderr, "%s\n", std::string (count, '-').c_str ());
   }
 
   /* Dump header with NAME.  */
-  static inline void dump_header (const char *name)
+  static inline void
+  dump_header (const char *name)
   {
     fprintf (stderr, "%-48s %11s%16s%10s%17s\n", name, "Leak", "Peak",
 	     "Times", "Type");
@@ -262,50 +280,59 @@  public:
   ~mem_alloc_description ();
 
   /* Returns true if instance PTR is registered by the memory description.  */
-  bool contains_descriptor_for_instance (const void *ptr);
+  bool
+  contains_descriptor_for_instance (const void *ptr);
 
   /* Return descriptor for instance PTR.  */
-  T *get_descriptor_for_instance (const void *ptr);
+  T *
+  get_descriptor_for_instance (const void *ptr);
 
   /* Register memory allocation descriptor for container PTR which is
      described by a memory LOCATION.  */
-  T *register_descriptor (const void *ptr, mem_location *location);
+  T *
+  register_descriptor (const void *ptr, mem_location *location);
 
   /* Register memory allocation descriptor for container PTR.  ORIGIN identifies
      type of container and GGC identifes if the allocation is handled in GGC
      memory.  Each location is identified by file NAME, LINE in source code and
      FUNCTION name.  */
-  T *register_descriptor (const void *ptr, mem_alloc_origin origin,
+  T *
+  register_descriptor (const void *ptr, mem_alloc_origin origin,
 			  bool ggc, const char *name, int line,
 			  const char *function);
 
   /* Register instance overhead identified by PTR pointer. Allocation takes
      SIZE bytes.  */
-  T *register_instance_overhead (size_t size, const void *ptr);
+  T *
+  register_instance_overhead (size_t size, const void *ptr);
 
   /* For containers (and GGC) where we want to track every instance object,
      we register allocation of SIZE bytes, identified by PTR pointer, belonging
      to USAGE descriptor.  */
-  void register_object_overhead (T *usage, size_t size, const void *ptr);
+  void
+  register_object_overhead (T *usage, size_t size, const void *ptr);
 
   /* Release PTR pointer of SIZE bytes. If REMOVE_FROM_MAP is set to true,
      remove the instance from reverse map.  */
-  void release_instance_overhead (void *ptr, size_t size,
+  void
+  release_instance_overhead (void *ptr, size_t size,
 				  bool remove_from_map = false);
 
   /* Release intance object identified by PTR pointer.  */
-  void release_object_overhead (void *ptr);
+  void
+  release_object_overhead (void *ptr);
 
   /* Get sum value for ORIGIN type of allocation for the descriptor.  */
-  T get_sum (mem_alloc_origin origin);
+  T
+  get_sum (mem_alloc_origin origin);
 
   /* Get all tracked instances registered by the description. Items
      are filtered by ORIGIN type, LENGTH is return value where we register
      the number of elements in the list. If we want to process custom order,
      CMP comparator can be provided.  */
-  mem_list_t *get_list (mem_alloc_origin origin, unsigned *length,
-			int (*cmp) (const void *first, const void *second)
-			  = NULL);
+  mem_list_t *
+  get_list (mem_alloc_origin origin, unsigned *length,
+	    int (*cmp) (const void *first, const void *second) = NULL);
 
   /* Dump all tracked instances of type ORIGIN. If we want to process custom
      order, CMP comparator can be provided.  */
diff --git a/gcc/vec.c b/gcc/vec.c
index d4a7a02..f1a4d65 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -60,7 +60,8 @@  struct vec_usage: public mem_usage
     m_items (items), m_items_peak (items_peak) {}
 
   /* Comparison operator.  */
-  inline bool operator< (const vec_usage &second) const
+  inline bool
+  operator< (const vec_usage &second) const
   {
     return (m_allocated == second.m_allocated ?
 	    (m_peak == second.m_peak ? m_times < second.m_times
@@ -68,7 +69,8 @@  struct vec_usage: public mem_usage
   }
 
   /* Sum the usage with SECOND usage.  */
-  vec_usage operator+ (const vec_usage &second)
+  vec_usage
+  operator+ (const vec_usage &second)
   {
     return vec_usage (m_allocated + second.m_allocated,
 		      m_times + second.m_times,
@@ -78,7 +80,8 @@  struct vec_usage: public mem_usage
   }
 
   /* Dump usage coupled to LOC location, where TOTAL is sum of all rows.  */
-  inline void dump (mem_location *loc, mem_usage &total) const
+  inline void
+  dump (mem_location *loc, mem_usage &total) const
   {
     char s[4096];
     sprintf (s, "%s:%i (%s)", loc->get_trimmed_filename (),
@@ -93,7 +96,8 @@  struct vec_usage: public mem_usage
   }
 
   /* Dump footer.  */
-  inline void dump_footer ()
+  inline void
+  dump_footer ()
   {
     print_dash_line ();
     fprintf (stderr, "%s%55li%25li%17li\n", "Total", (long)m_allocated,
@@ -102,7 +106,8 @@  struct vec_usage: public mem_usage
   }
 
   /* Dump header with NAME.  */
-  static inline void dump_header (const char *name)
+  static inline void
+  dump_header (const char *name)
   {
     fprintf (stderr, "%-48s %11s%15s%10s%17s%11s\n", name, "Leak", "Peak",
 	     "Times", "Leak items", "Peak items");
@@ -110,7 +115,8 @@  struct vec_usage: public mem_usage
   }
 
   /* Compare wrapper used by qsort method.  */
-  static int compare (const void *first, const void *second)
+  static int
+  compare (const void *first, const void *second)
   {
     typedef std::pair<mem_location *, vec_usage *> mem_pair_t;
 
-- 
2.1.4