This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Use XCNEW instead of XNEW+memset
- From: Dirk Mueller <dmueller at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 13 Nov 2006 14:07:41 +0100
- Subject: [PATCH] Use XCNEW instead of XNEW+memset
Hi,
This just cleans up some allocation+memset into zero-initialized-allocations.
I've had this in my tree for several weeks and couldn't find an issue with
it, and it does seem to make the compiler a few bytes smaller ;)
Ok for mainline, assuming that another full regtest passes?
2006-11-13 Dirk Mueller <dmueller@suse.de>
* tree-vrp.c (get_value_range): Use XCNEW instead
of XNEW and memset.
(insert_range_assertions): Use XCNEWVEC instead
of XNEWVEC and memset.
(vrp_initialize): Same.
(vrp_finalize): Same.
* tree-ssa-ccp.c (ccp_initialize): Same.
* predict.c (tree_bb_level_predictions): Same.
* calls.c (expand_call): Same.
* tree-ssa-copy.c (init_copy_prop): Same.
(fini_copy_prop): Same.
* tree-ssa-alias.c (get_ptr_info): Use GGC_CNEW instead
of GGC_NEW and memset.
* name-lookup.c (begin_scope): Use GGC_CNEW instead of
GGC_NEW and memset.
--- gcc/tree-vrp.c (revision 116062)
+++ gcc/tree-vrp.c (working copy)
@@ -265,8 +265,7 @@ get_value_range (tree var)
return vr;
/* Create a default value range. */
- vr_value[ver] = vr = XNEW (value_range_t);
- memset (vr, 0, sizeof (*vr));
+ vr_value[ver] = vr = XCNEW (value_range_t);
/* Allocate an equivalence set. */
vr->equiv = BITMAP_ALLOC (NULL);
@@ -3262,8 +3261,7 @@ insert_range_assertions (void)
sbitmap_zero (blocks_visited);
need_assert_for = BITMAP_ALLOC (NULL);
- asserts_for = XNEWVEC (assert_locus_t, num_ssa_names);
- memset (asserts_for, 0, num_ssa_names * sizeof (assert_locus_t));
+ asserts_for = XCNEWVEC (assert_locus_t, num_ssa_names);
calculate_dominance_info (CDI_DOMINATORS);
@@ -3401,8 +3399,7 @@ vrp_initialize (void)
{
basic_block bb;
- vr_value = XNEWVEC (value_range_t *, num_ssa_names);
- memset (vr_value, 0, num_ssa_names * sizeof (value_range_t *));
+ vr_value = XCNEWVEC (value_range_t *, num_ssa_names);
FOR_EACH_BB (bb)
{
@@ -4582,8 +4579,7 @@ vrp_finalize (void)
/* We may have ended with ranges that have exactly one value. Those
values can be substituted as any other copy/const propagated
value using substitute_and_fold. */
- single_val_range = XNEWVEC (prop_value_t, num_ssa_names);
- memset (single_val_range, 0, num_ssa_names * sizeof (*single_val_range));
+ single_val_range = XCNEWVEC (prop_value_t, num_ssa_names);
do_value_subst_p = false;
for (i = 0; i < num_ssa_names; i++)
--- gcc/cp/name-lookup.c (revision 115775)
+++ gcc/cp/name-lookup.c (working copy)
@@ -1271,11 +1271,11 @@ begin_scope (scope_kind kind, tree entit
if (!ENABLE_SCOPE_CHECKING && free_binding_level)
{
scope = free_binding_level;
+ memset (scope, 0, sizeof (cxx_scope));
free_binding_level = scope->level_chain;
}
else
- scope = GGC_NEW (cxx_scope);
- memset (scope, 0, sizeof (cxx_scope));
+ scope = GGC_CNEW (cxx_scope);
scope->this_entity = entity;
scope->more_cleanups_ok = true;
Index: gcc/tree-ssa-ccp.c
===================================================================
--- gcc/tree-ssa-ccp.c (revision 115775)
+++ gcc/tree-ssa-ccp.c (working copy)
@@ -536,8 +536,7 @@ ccp_initialize (void)
{
basic_block bb;
- const_val = XNEWVEC (prop_value_t, num_ssa_names);
- memset (const_val, 0, num_ssa_names * sizeof (*const_val));
+ const_val = XCNEWVEC (prop_value_t, num_ssa_names);
/* Initialize simulation flags for PHI nodes and statements. */
FOR_EACH_BB (bb)
--- gcc/tree-ssa-alias.c (revision 115775)
+++ gcc/tree-ssa-alias.c (working copy)
@@ -2456,8 +2456,7 @@ get_ptr_info (tree t)
pi = SSA_NAME_PTR_INFO (t);
if (pi == NULL)
{
- pi = GGC_NEW (struct ptr_info_def);
- memset ((void *)pi, 0, sizeof (*pi));
+ pi = GGC_CNEW (struct ptr_info_def);
SSA_NAME_PTR_INFO (t) = pi;
}
--- gcc/predict.c (revision 115775)
+++ gcc/predict.c (working copy)
@@ -1191,8 +1191,7 @@ tree_bb_level_predictions (void)
basic_block bb;
int *heads;
- heads = XNEWVEC (int, last_basic_block);
- memset (heads, ENTRY_BLOCK, sizeof (int) * last_basic_block);
+ heads = XCNEWVEC (int, last_basic_block);
heads[ENTRY_BLOCK_PTR->next_bb->index] = last_basic_block;
apply_return_prediction (heads);
--- gcc/calls.c (revision 115775)
+++ gcc/calls.c (working copy)
@@ -2477,9 +2477,8 @@ expand_call (tree exp, rtx target, int i
/* Make a new map for the new argument list. */
if (stack_usage_map_buf)
free (stack_usage_map_buf);
- stack_usage_map_buf = XNEWVEC (char, highest_outgoing_arg_in_use);
+ stack_usage_map_buf = XCNEWVEC (char, highest_outgoing_arg_in_use);
stack_usage_map = stack_usage_map_buf;
- memset (stack_usage_map, 0, highest_outgoing_arg_in_use);
highest_outgoing_arg_in_use = 0;
}
allocate_dynamic_stack_space (push_size, NULL_RTX,
--- gcc/tree-ssa-copy.c (revision 115775)
+++ gcc/tree-ssa-copy.c (working copy)
@@ -882,11 +882,9 @@ init_copy_prop (void)
{
basic_block bb;
- copy_of = XNEWVEC (prop_value_t, num_ssa_names);
- memset (copy_of, 0, num_ssa_names * sizeof (*copy_of));
+ copy_of = XCNEWVEC (prop_value_t, num_ssa_names);
- cached_last_copy_of = XNEWVEC (tree, num_ssa_names);
- memset (cached_last_copy_of, 0, num_ssa_names * sizeof
(*cached_last_copy_of));
+ cached_last_copy_of = XCNEWVEC (tree, num_ssa_names);
FOR_EACH_BB (bb)
{
@@ -954,8 +952,7 @@ fini_copy_prop (void)
/* Set the final copy-of value for each variable by traversing the
copy-of chains. */
- tmp = XNEWVEC (prop_value_t, num_ssa_names);
- memset (tmp, 0, num_ssa_names * sizeof (*tmp));
+ tmp = XCNEWVEC (prop_value_t, num_ssa_names);
for (i = 1; i < num_ssa_names; i++)
{
tree var = ssa_name (i);