summaryrefslogtreecommitdiff
path: root/gcc/gcse.c
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-11 21:50:06 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-11 21:50:06 +0000
commit2f80019135c611caee65bc6e37bef6e6beb8c787 (patch)
treeed747a969cd89ad24c3eb6752bede07e6a121bc9 /gcc/gcse.c
parent9c985aeccc2419d2c3af8eb0a36954e4709d6ce6 (diff)
downloadgcc-2f80019135c611caee65bc6e37bef6e6beb8c787.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcse.c')
-rw-r--r--gcc/gcse.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 06f7fd9efa0..066747b3c3a 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -549,8 +549,9 @@ struct null_pointer_info
};
static void compute_can_copy (void);
-static void *gmalloc (unsigned int);
-static void *grealloc (void *, unsigned int);
+static void *gmalloc (size_t) ATTRIBUTE_MALLOC;
+static void *gcalloc (size_t, size_t) ATTRIBUTE_MALLOC;
+static void *grealloc (void *, size_t);
static void *gcse_alloc (unsigned long);
static void alloc_gcse_mem (rtx);
static void free_gcse_mem (void);
@@ -821,11 +822,8 @@ gcse_main (rtx f, FILE *file)
if (changed)
{
free_modify_mem_tables ();
- modify_mem_list = gmalloc (last_basic_block * sizeof (rtx));
- canon_modify_mem_list
- = 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));
+ modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
+ canon_modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
}
free_reg_set_mem ();
alloc_reg_set_mem (max_reg_num ());
@@ -960,12 +958,21 @@ gmalloc (unsigned int 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.
We don't record the additional size since we don't know it.
It won't affect memory usage stats much anyway. */
static void *
-grealloc (void *ptr, unsigned int size)
+grealloc (void *ptr, size_t size)
{
return xrealloc (ptr, size);
}
@@ -987,7 +994,7 @@ gcse_alloc (unsigned long size)
static void
alloc_gcse_mem (rtx f)
{
- int i, n;
+ int i;
rtx insn;
/* Find the largest UID and create a mapping from UIDs to CUIDs.
@@ -995,9 +1002,7 @@ alloc_gcse_mem (rtx f)
and only apply to real insns. */
max_uid = get_max_uid ();
- n = (max_uid + 1) * sizeof (int);
- uid_cuid = gmalloc (n);
- memset (uid_cuid, 0, n);
+ uid_cuid = gcalloc (max_uid + 1, sizeof (int));
for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
{
if (INSN_P (insn))
@@ -1009,9 +1014,7 @@ alloc_gcse_mem (rtx f)
/* Create a table mapping cuids to insns. */
max_cuid = i;
- n = (max_cuid + 1) * sizeof (rtx);
- cuid_insn = gmalloc (n);
- memset (cuid_insn, 0, n);
+ cuid_insn = gcalloc (max_cuid + 1, sizeof (rtx));
for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
if (INSN_P (insn))
CUID_INSN (i++) = insn;
@@ -1023,10 +1026,8 @@ alloc_gcse_mem (rtx f)
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
basic block. */
- modify_mem_list = gmalloc (last_basic_block * sizeof (rtx));
- canon_modify_mem_list = 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));
+ modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
+ canon_modify_mem_list = gcalloc (last_basic_block, sizeof (rtx));
modify_mem_list_set = BITMAP_XMALLOC ();
canon_modify_mem_list_set = BITMAP_XMALLOC ();
}
@@ -1189,12 +1190,8 @@ static struct obstack reg_set_obstack;
static void
alloc_reg_set_mem (int n_regs)
{
- unsigned int n;
-
reg_set_table_size = n_regs + REG_SET_TABLE_SLOP;
- n = reg_set_table_size * sizeof (struct reg_set *);
- reg_set_table = gmalloc (n);
- memset (reg_set_table, 0, n);
+ reg_set_table = gcalloc (reg_set_table_size, sizeof (struct reg_set *));
gcc_obstack_init (&reg_set_obstack);
}