Re: [PATCH 15/35] Change use to type-based pool allocator in dse.c.

2015-05-29 Thread Martin Liška

On 05/27/2015 03:56 PM, mliska wrote:

gcc/ChangeLog:

2015-04-30  Martin Liska  mli...@suse.cz

* dse.c (get_group_info):Use new type-based pool allocator.
(dse_step0) Likewise.
(free_store_info) Likewise.
(delete_dead_store_insn) Likewise.
(free_read_records) Likewise.
(record_store) Likewise.
(replace_read) Likewise.
(check_mem_read_rtx) Likewise.
(scan_insn) Likewise.
(dse_step1) Likewise.
(dse_step7) Likewise.
---
  gcc/dse.c | 201 --
  1 file changed, 129 insertions(+), 72 deletions(-)

diff --git a/gcc/dse.c b/gcc/dse.c
index b3b38d5..5ade9dd 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -249,7 +249,7 @@ static struct obstack dse_obstack;
  /* Scratch bitmap for cselib's cselib_expand_value_rtx.  */
  static bitmap scratch = NULL;

-struct insn_info;
+struct insn_info_type;

  /* This structure holds information about a candidate store.  */
  struct store_info
@@ -316,7 +316,7 @@ struct store_info
/* Set if this store stores the same constant value as REDUNDANT_REASON
   insn stored.  These aren't eliminated early, because doing that
   might prevent the earlier larger store to be eliminated.  */
-  struct insn_info *redundant_reason;
+  struct insn_info_type *redundant_reason;
  };

  /* Return a bitmask with the first N low bits set.  */
@@ -329,12 +329,15 @@ lowpart_bitmask (int n)
  }

  typedef struct store_info *store_info_t;
-static alloc_pool cse_store_info_pool;
-static alloc_pool rtx_store_info_pool;
+static pool_allocatorstore_info cse_store_info_pool (cse_store_info_pool,
+  100);
+
+static pool_allocatorstore_info rtx_store_info_pool (rtx_store_info_pool,
+  100);

  /* This structure holds information about a load.  These are only
 built for rtx bases.  */
-struct read_info
+struct read_info_type
  {
/* The id of the mem group of the base address.  */
int group_id;
@@ -351,15 +354,30 @@ struct read_info
rtx mem;

/* The next read_info for this insn.  */
-  struct read_info *next;
+  struct read_info_type *next;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((read_info_type *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocatorread_info_type pool;
  };
-typedef struct read_info *read_info_t;
-static alloc_pool read_info_pool;
+typedef struct read_info_type *read_info_t;

+pool_allocatorread_info_type read_info_type::pool (read_info_pool, 100);

  /* One of these records is created for each insn.  */

-struct insn_info
+struct insn_info_type
  {
/* Set true if the insn contains a store but the insn itself cannot
   be deleted.  This is set if the insn is a parallel and there is
@@ -433,27 +451,41 @@ struct insn_info
regset fixed_regs_live;

/* The prev insn in the basic block.  */
-  struct insn_info * prev_insn;
+  struct insn_info_type * prev_insn;

/* The linked list of insns that are in consideration for removal in
   the forwards pass through the basic block.  This pointer may be
   trash as it is not cleared when a wild read occurs.  The only
   time it is guaranteed to be correct is when the traversal starts
   at active_local_stores.  */
-  struct insn_info * next_local_store;
+  struct insn_info_type * next_local_store;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((insn_info_type *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocatorinsn_info_type pool;
  };
+typedef struct insn_info_type *insn_info_t;

-typedef struct insn_info *insn_info_t;
-static alloc_pool insn_info_pool;
+pool_allocatorinsn_info_type insn_info_type::pool (insn_info_pool, 100);

  /* The linked list of stores that are under consideration in this
 basic block.  */
  static insn_info_t active_local_stores;
  static int active_local_stores_len;

-struct dse_bb_info
+struct dse_bb_info_type
  {
-
/* Pointer to the insn info for the last insn in the block.  These
   are linked so this is how all of the insns are reached.  During
   scanning this is the current insn being scanned.  */
@@ -507,10 +539,25 @@ struct dse_bb_info
   to assure that shift and/or add sequences that are inserted do not
   accidentally clobber live hard regs.  */
bitmap regs_live;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator 

[PATCH 15/35] Change use to type-based pool allocator in dse.c.

2015-05-27 Thread mliska
gcc/ChangeLog:

2015-04-30  Martin Liska  mli...@suse.cz

* dse.c (get_group_info):Use new type-based pool allocator.
(dse_step0) Likewise.
(free_store_info) Likewise.
(delete_dead_store_insn) Likewise.
(free_read_records) Likewise.
(record_store) Likewise.
(replace_read) Likewise.
(check_mem_read_rtx) Likewise.
(scan_insn) Likewise.
(dse_step1) Likewise.
(dse_step7) Likewise.
---
 gcc/dse.c | 201 --
 1 file changed, 129 insertions(+), 72 deletions(-)

diff --git a/gcc/dse.c b/gcc/dse.c
index b3b38d5..5ade9dd 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -249,7 +249,7 @@ static struct obstack dse_obstack;
 /* Scratch bitmap for cselib's cselib_expand_value_rtx.  */
 static bitmap scratch = NULL;
 
-struct insn_info;
+struct insn_info_type;
 
 /* This structure holds information about a candidate store.  */
 struct store_info
@@ -316,7 +316,7 @@ struct store_info
   /* Set if this store stores the same constant value as REDUNDANT_REASON
  insn stored.  These aren't eliminated early, because doing that
  might prevent the earlier larger store to be eliminated.  */
-  struct insn_info *redundant_reason;
+  struct insn_info_type *redundant_reason;
 };
 
 /* Return a bitmask with the first N low bits set.  */
@@ -329,12 +329,15 @@ lowpart_bitmask (int n)
 }
 
 typedef struct store_info *store_info_t;
-static alloc_pool cse_store_info_pool;
-static alloc_pool rtx_store_info_pool;
+static pool_allocatorstore_info cse_store_info_pool (cse_store_info_pool,
+  100);
+
+static pool_allocatorstore_info rtx_store_info_pool (rtx_store_info_pool,
+  100);
 
 /* This structure holds information about a load.  These are only
built for rtx bases.  */
-struct read_info
+struct read_info_type
 {
   /* The id of the mem group of the base address.  */
   int group_id;
@@ -351,15 +354,30 @@ struct read_info
   rtx mem;
 
   /* The next read_info for this insn.  */
-  struct read_info *next;
+  struct read_info_type *next;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((read_info_type *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocatorread_info_type pool;
 };
-typedef struct read_info *read_info_t;
-static alloc_pool read_info_pool;
+typedef struct read_info_type *read_info_t;
 
+pool_allocatorread_info_type read_info_type::pool (read_info_pool, 100);
 
 /* One of these records is created for each insn.  */
 
-struct insn_info
+struct insn_info_type
 {
   /* Set true if the insn contains a store but the insn itself cannot
  be deleted.  This is set if the insn is a parallel and there is
@@ -433,27 +451,41 @@ struct insn_info
   regset fixed_regs_live;
 
   /* The prev insn in the basic block.  */
-  struct insn_info * prev_insn;
+  struct insn_info_type * prev_insn;
 
   /* The linked list of insns that are in consideration for removal in
  the forwards pass through the basic block.  This pointer may be
  trash as it is not cleared when a wild read occurs.  The only
  time it is guaranteed to be correct is when the traversal starts
  at active_local_stores.  */
-  struct insn_info * next_local_store;
+  struct insn_info_type * next_local_store;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((insn_info_type *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocatorinsn_info_type pool;
 };
+typedef struct insn_info_type *insn_info_t;
 
-typedef struct insn_info *insn_info_t;
-static alloc_pool insn_info_pool;
+pool_allocatorinsn_info_type insn_info_type::pool (insn_info_pool, 100);
 
 /* The linked list of stores that are under consideration in this
basic block.  */
 static insn_info_t active_local_stores;
 static int active_local_stores_len;
 
-struct dse_bb_info
+struct dse_bb_info_type
 {
-
   /* Pointer to the insn info for the last insn in the block.  These
  are linked so this is how all of the insns are reached.  During
  scanning this is the current insn being scanned.  */
@@ -507,10 +539,25 @@ struct dse_bb_info
  to assure that shift and/or add sequences that are inserted do not
  accidentally clobber live hard regs.  */
   bitmap regs_live;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((dse_bb_info_type *) ptr);
+  }
+