This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [bitmap memory]: Allocation part 2


Jeffrey A Law wrote:
That patch is, err, long.  Is there any way you can break it into
distinct functional hunks to make review easier?

and this one cleans up the BITMAP_OBSTACK_ALLOC name and removes a few unnecessary NULL checks.

booted & tested on i686-pc-linux-gnu, ok

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-11-22  Nathan Sidwell  <nathan@codesourcery.com>

	* basic-block.h (OBSTACK_ALLOC_REG_SET): Adjust.
	(FREE_REG_SET): Adjust.
	* bitmap.c (bitmap_obstack_free): Cope with NULL bitmap.
	* bitmap.h (BITMAP_OBSTACK_ALLOC): Rename to ...
	(BITMAP_ALLOC): ... here.
	(BITMAP_OBSTACK_FREE): Rename to ...
	(BITMAP_FREE): Don't check for NULL bitmap here.
	* tree-ssa-pre.c (value_insert_into_set_bitmap,
	bitmap_set_new): Use new names.

	* bt-load.c (migrate_btr_defs): Remove unneeded NULL check.
	* df.c (df_free): Likewise.
	* ra-build.c (ra_build_free, ra_build_free_all): Likewise.
	* tree-ssa-loop-ivopts.c (set_use_iv_cost): Likewise.

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.229
diff -c -3 -p -r1.229 basic-block.h
*** basic-block.h	22 Nov 2004 12:23:42 -0000	1.229
--- basic-block.h	23 Nov 2004 16:20:14 -0000
*************** typedef bitmap_iterator reg_set_iterator
*** 102,111 ****
    EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI)	\
  
  /* Allocate a register set with oballoc.  */
! #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
  
  /* Do any cleanup needed on a regset when it is no longer used.  */
! #define FREE_REG_SET(REGSET) BITMAP_OBSTACK_FREE(REGSET)
  
  /* Allocate a register set with xmalloc.  */
  #define XMALLOC_REG_SET() BITMAP_XMALLOC ()
--- 102,111 ----
    EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI)	\
  
  /* Allocate a register set with oballoc.  */
! #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_ALLOC (OBSTACK)
  
  /* Do any cleanup needed on a regset when it is no longer used.  */
! #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET)
  
  /* Allocate a register set with xmalloc.  */
  #define XMALLOC_REG_SET() BITMAP_XMALLOC ()
Index: bitmap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.c,v
retrieving revision 1.61
diff -c -3 -p -r1.61 bitmap.c
*** bitmap.c	22 Nov 2004 12:23:43 -0000	1.61
--- bitmap.c	23 Nov 2004 16:20:20 -0000
*************** bitmap_malloc_alloc (void)
*** 251,259 ****
  void
  bitmap_obstack_free (bitmap map)
  {
!   bitmap_clear (map);
!   map->first = (void *)map->obstack->heads;
!   map->obstack->heads = map;
  }
  
  /* Release a malloc allocated bitmap.  */
--- 251,262 ----
  void
  bitmap_obstack_free (bitmap map)
  {
!   if (map)
!     {
!       bitmap_clear (map);
!       map->first = (void *)map->obstack->heads;
!       map->obstack->heads = map;
!     }
  }
  
  /* Release a malloc allocated bitmap.  */
Index: bitmap.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.h,v
retrieving revision 1.50
diff -c -3 -p -r1.50 bitmap.h
*** bitmap.h	22 Nov 2004 12:23:43 -0000	1.50
--- bitmap.h	23 Nov 2004 16:20:21 -0000
*************** extern void bitmap_malloc_free (bitmap);
*** 156,162 ****
  extern unsigned bitmap_first_set_bit (bitmap);
  
  /* Allocate a bitmap from a bit obstack.  */
! #define BITMAP_OBSTACK_ALLOC(OBSTACK) bitmap_obstack_alloc (OBSTACK)
  
  /* Allocate a gc'd bitmap.  */
  #define BITMAP_GGC_ALLOC() bitmap_gc_alloc ()
--- 156,162 ----
  extern unsigned bitmap_first_set_bit (bitmap);
  
  /* Allocate a bitmap from a bit obstack.  */
! #define BITMAP_ALLOC(OBSTACK) bitmap_obstack_alloc (OBSTACK)
  
  /* Allocate a gc'd bitmap.  */
  #define BITMAP_GGC_ALLOC() bitmap_gc_alloc ()
*************** extern unsigned bitmap_first_set_bit (bi
*** 165,178 ****
  #define BITMAP_XMALLOC() bitmap_malloc_alloc ()
  
  /* Do any cleanup needed on a bitmap when it is no longer used.  */
! #define BITMAP_OBSTACK_FREE(BITMAP)			\
! do {						\
!   if (BITMAP)					\
!     {						\
!       bitmap_obstack_free (BITMAP);		\
!       (BITMAP) = 0;				\
!     }						\
! } while (0)
  
  /* Do any cleanup needed on an xmalloced bitmap when it is no longer used.  */
  #define BITMAP_XFREE(BITMAP)			\
--- 165,172 ----
  #define BITMAP_XMALLOC() bitmap_malloc_alloc ()
  
  /* Do any cleanup needed on a bitmap when it is no longer used.  */
! #define BITMAP_FREE(BITMAP)			\
!       	((void)(bitmap_obstack_free (BITMAP), (BITMAP) = NULL))
  
  /* Do any cleanup needed on an xmalloced bitmap when it is no longer used.  */
  #define BITMAP_XFREE(BITMAP)			\
Index: bt-load.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bt-load.c,v
retrieving revision 2.28
diff -c -3 -p -r2.28 bt-load.c
*** bt-load.c	22 Nov 2004 12:23:43 -0000	2.28
--- bt-load.c	23 Nov 2004 16:20:24 -0000
*************** migrate_btr_defs (enum reg_class btr_cla
*** 1385,1394 ****
  	    }
  	}
        else
! 	{
! 	  if (def->live_range)
! 	    BITMAP_XFREE (def->live_range);
! 	}
      }
  
    free (btrs_live);
--- 1385,1391 ----
  	    }
  	}
        else
! 	BITMAP_XFREE (def->live_range);
      }
  
    free (btrs_live);
Index: df.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/df.c,v
retrieving revision 1.77
diff -c -3 -p -r1.77 df.c
*** df.c	4 Nov 2004 08:57:51 -0000	1.77
--- df.c	23 Nov 2004 16:23:47 -0000
*************** df_free (struct df *df)
*** 580,591 ****
    df->regs = 0;
    df->reg_size = 0;
  
!   if (df->bbs_modified)
!     BITMAP_XFREE (df->bbs_modified);
    df->bbs_modified = 0;
  
!   if (df->insns_modified)
!     BITMAP_XFREE (df->insns_modified);
    df->insns_modified = 0;
  
    BITMAP_XFREE (df->all_blocks);
--- 580,589 ----
    df->regs = 0;
    df->reg_size = 0;
  
!   BITMAP_XFREE (df->bbs_modified);
    df->bbs_modified = 0;
  
!   BITMAP_XFREE (df->insns_modified);
    df->insns_modified = 0;
  
    BITMAP_XFREE (df->all_blocks);
Index: ra-build.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-build.c,v
retrieving revision 1.38
diff -c -3 -p -r1.38 ra-build.c
*** ra-build.c	11 Nov 2004 10:36:27 -0000	1.38
--- ra-build.c	23 Nov 2004 16:30:21 -0000
*************** ra_build_free (void)
*** 3125,3134 ****
      {
        struct tagged_conflict *cl;
        for (cl = web_parts[i].sub_conflicts; cl; cl = cl->next)
! 	{
! 	  if (cl->conflicts)
! 	    BITMAP_XFREE (cl->conflicts);
! 	}
        web_parts[i].sub_conflicts = NULL;
      }
  
--- 3125,3131 ----
      {
        struct tagged_conflict *cl;
        for (cl = web_parts[i].sub_conflicts; cl; cl = cl->next)
! 	BITMAP_XFREE (cl->conflicts);
        web_parts[i].sub_conflicts = NULL;
      }
  
*************** ra_build_free_all (struct df *df)
*** 3154,3163 ****
      {
        struct tagged_conflict *cl;
        for (cl = web_parts[i].sub_conflicts; cl; cl = cl->next)
! 	{
! 	  if (cl->conflicts)
! 	    BITMAP_XFREE (cl->conflicts);
! 	}
        web_parts[i].sub_conflicts = NULL;
      }
    sbitmap_free (live_over_abnormal);
--- 3151,3157 ----
      {
        struct tagged_conflict *cl;
        for (cl = web_parts[i].sub_conflicts; cl; cl = cl->next)
! 	BITMAP_XFREE (cl->conflicts);
        web_parts[i].sub_conflicts = NULL;
      }
    sbitmap_free (live_over_abnormal);
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.30
diff -c -3 -p -r2.30 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c	14 Nov 2004 23:35:02 -0000	2.30
--- tree-ssa-loop-ivopts.c	23 Nov 2004 16:34:33 -0000
*************** set_use_iv_cost (struct ivopts_data *dat
*** 2049,2056 ****
  
    if (cost == INFTY)
      {
!       if (depends_on)
! 	BITMAP_XFREE (depends_on);
        return;
      }
  
--- 2049,2055 ----
  
    if (cost == INFTY)
      {
!       BITMAP_XFREE (depends_on);
        return;
      }
  
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-pre.c,v
retrieving revision 2.54
diff -c -3 -p -r2.54 tree-ssa-pre.c
*** tree-ssa-pre.c	22 Nov 2004 12:23:58 -0000	2.54
--- tree-ssa-pre.c	23 Nov 2004 16:34:47 -0000
*************** value_insert_into_set_bitmap (value_set_
*** 462,468 ****
    gcc_assert (set->indexed);
  
    if (set->values == NULL)
!     set->values = BITMAP_OBSTACK_ALLOC (&grand_bitmap_obstack);
  
    bitmap_set_bit (set->values, VALUE_HANDLE_ID (v));
  }
--- 462,468 ----
    gcc_assert (set->indexed);
  
    if (set->values == NULL)
!     set->values = BITMAP_ALLOC (&grand_bitmap_obstack);
  
    bitmap_set_bit (set->values, VALUE_HANDLE_ID (v));
  }
*************** static bitmap_set_t 
*** 474,481 ****
  bitmap_set_new (void)
  {
    bitmap_set_t ret = pool_alloc (bitmap_set_pool);
!   ret->expressions = BITMAP_OBSTACK_ALLOC (&grand_bitmap_obstack);
!   ret->values = BITMAP_OBSTACK_ALLOC (&grand_bitmap_obstack);
    return ret;
  }
  
--- 474,481 ----
  bitmap_set_new (void)
  {
    bitmap_set_t ret = pool_alloc (bitmap_set_pool);
!   ret->expressions = BITMAP_ALLOC (&grand_bitmap_obstack);
!   ret->values = BITMAP_ALLOC (&grand_bitmap_obstack);
    return ret;
  }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]