Commit 9fe15a12 by Kaveh R. Ghazi Committed by Kaveh Ghazi

gcse.c (gmalloc): Argument is a size_t.

	* gcse.c (gmalloc): Argument is a size_t.  Add ATTRIBUTE_MALLOC.
	(grealloc): Size argument is a size_t.
	(gcalloc): New function.  Use throughout in lieu of
	gmalloc/memset.

From-SVN: r70338
parent 29da5c92
2003-08-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2003-08-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcse.c (gmalloc): Argument is a size_t. Add ATTRIBUTE_MALLOC.
(grealloc): Size argument is a size_t.
(gcalloc): New function. Use throughout in lieu of
gmalloc/memset.
* config/avr/avr.c (avr_init_once): Use xcalloc in lieu of * config/avr/avr.c (avr_init_once): Use xcalloc in lieu of
xmalloc/memset. xmalloc/memset.
* config/ia64/ia64.c (ia64_reorg): Likewise. * config/ia64/ia64.c (ia64_reorg): Likewise.
......
...@@ -549,8 +549,9 @@ struct null_pointer_info ...@@ -549,8 +549,9 @@ struct null_pointer_info
}; };
static void compute_can_copy (void); static void compute_can_copy (void);
static void *gmalloc (unsigned int); static void *gmalloc (size_t) ATTRIBUTE_MALLOC;
static void *grealloc (void *, unsigned int); static void *gcalloc (size_t, size_t) ATTRIBUTE_MALLOC;
static void *grealloc (void *, size_t);
static void *gcse_alloc (unsigned long); static void *gcse_alloc (unsigned long);
static void alloc_gcse_mem (rtx); static void alloc_gcse_mem (rtx);
static void free_gcse_mem (void); static void free_gcse_mem (void);
...@@ -821,11 +822,8 @@ gcse_main (rtx f, FILE *file) ...@@ -821,11 +822,8 @@ gcse_main (rtx f, FILE *file)
if (changed) if (changed)
{ {
free_modify_mem_tables (); free_modify_mem_tables ();
modify_mem_list = gmalloc (last_basic_block * sizeof (rtx)); modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
canon_modify_mem_list canon_modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
= gmalloc (last_basic_block * sizeof (rtx));
memset (modify_mem_list, 0, last_basic_block * sizeof (rtx));
memset (canon_modify_mem_list, 0, last_basic_block * sizeof (rtx));
} }
free_reg_set_mem (); free_reg_set_mem ();
alloc_reg_set_mem (max_reg_num ()); alloc_reg_set_mem (max_reg_num ());
...@@ -960,12 +958,21 @@ gmalloc (unsigned int size) ...@@ -960,12 +958,21 @@ gmalloc (unsigned int size)
return xmalloc (size); return xmalloc (size);
} }
/* Cover function to xcalloc to record bytes allocated. */
static void *
gcalloc (size_t nelem, size_t elsize)
{
bytes_used += nelem * elsize;
return xcalloc (nelem, elsize);
}
/* Cover function to xrealloc. /* Cover function to xrealloc.
We don't record the additional size since we don't know it. We don't record the additional size since we don't know it.
It won't affect memory usage stats much anyway. */ It won't affect memory usage stats much anyway. */
static void * static void *
grealloc (void *ptr, unsigned int size) grealloc (void *ptr, size_t size)
{ {
return xrealloc (ptr, size); return xrealloc (ptr, size);
} }
...@@ -987,7 +994,7 @@ gcse_alloc (unsigned long size) ...@@ -987,7 +994,7 @@ gcse_alloc (unsigned long size)
static void static void
alloc_gcse_mem (rtx f) alloc_gcse_mem (rtx f)
{ {
int i, n; int i;
rtx insn; rtx insn;
/* Find the largest UID and create a mapping from UIDs to CUIDs. /* Find the largest UID and create a mapping from UIDs to CUIDs.
...@@ -995,9 +1002,7 @@ alloc_gcse_mem (rtx f) ...@@ -995,9 +1002,7 @@ alloc_gcse_mem (rtx f)
and only apply to real insns. */ and only apply to real insns. */
max_uid = get_max_uid (); max_uid = get_max_uid ();
n = (max_uid + 1) * sizeof (int); uid_cuid = gcalloc (max_uid + 1, sizeof (int));
uid_cuid = gmalloc (n);
memset (uid_cuid, 0, n);
for (insn = f, i = 0; insn; insn = NEXT_INSN (insn)) for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
{ {
if (INSN_P (insn)) if (INSN_P (insn))
...@@ -1009,9 +1014,7 @@ alloc_gcse_mem (rtx f) ...@@ -1009,9 +1014,7 @@ alloc_gcse_mem (rtx f)
/* Create a table mapping cuids to insns. */ /* Create a table mapping cuids to insns. */
max_cuid = i; max_cuid = i;
n = (max_cuid + 1) * sizeof (rtx); cuid_insn = gcalloc (max_cuid + 1, sizeof (rtx));
cuid_insn = gmalloc (n);
memset (cuid_insn, 0, n);
for (insn = f, i = 0; insn; insn = NEXT_INSN (insn)) for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
if (INSN_P (insn)) if (INSN_P (insn))
CUID_INSN (i++) = insn; CUID_INSN (i++) = insn;
...@@ -1023,10 +1026,8 @@ alloc_gcse_mem (rtx f) ...@@ -1023,10 +1026,8 @@ alloc_gcse_mem (rtx f)
reg_set_in_block = sbitmap_vector_alloc (last_basic_block, max_gcse_regno); reg_set_in_block = sbitmap_vector_alloc (last_basic_block, max_gcse_regno);
/* Allocate array to keep a list of insns which modify memory in each /* Allocate array to keep a list of insns which modify memory in each
basic block. */ basic block. */
modify_mem_list = gmalloc (last_basic_block * sizeof (rtx)); modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
canon_modify_mem_list = gmalloc (last_basic_block * sizeof (rtx)); canon_modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
memset (modify_mem_list, 0, last_basic_block * sizeof (rtx));
memset (canon_modify_mem_list, 0, last_basic_block * sizeof (rtx));
modify_mem_list_set = BITMAP_XMALLOC (); modify_mem_list_set = BITMAP_XMALLOC ();
canon_modify_mem_list_set = BITMAP_XMALLOC (); canon_modify_mem_list_set = BITMAP_XMALLOC ();
} }
...@@ -1189,12 +1190,8 @@ static struct obstack reg_set_obstack; ...@@ -1189,12 +1190,8 @@ static struct obstack reg_set_obstack;
static void static void
alloc_reg_set_mem (int n_regs) alloc_reg_set_mem (int n_regs)
{ {
unsigned int n;
reg_set_table_size = n_regs + REG_SET_TABLE_SLOP; reg_set_table_size = n_regs + REG_SET_TABLE_SLOP;
n = reg_set_table_size * sizeof (struct reg_set *); reg_set_table = gcalloc (reg_set_table_size, sizeof (struct reg_set *));
reg_set_table = gmalloc (n);
memset (reg_set_table, 0, n);
gcc_obstack_init (&reg_set_obstack); gcc_obstack_init (&reg_set_obstack);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment