summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/alias.c4
-rw-r--r--gcc/cfgbuild.c4
-rw-r--r--gcc/cfgrtl.c6
-rw-r--r--gcc/function.c10
-rw-r--r--gcc/reg-stack.c8
-rw-r--r--gcc/regclass.c12
-rw-r--r--gcc/tree-cfg.c46
-rw-r--r--gcc/tree-complex.c11
-rw-r--r--gcc/vec.h46
10 files changed, 84 insertions, 76 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2e3e2abd9a6..6b3103eefac 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2007-01-02 Kazu Hirata <kazu@codesourcery.com>
+
+ * alias.c (init_alias_analysis): Use VEC_safe_grow_cleared.
+ * cfgbuild.c (find_basic_blocks): Likewise.
+ * cfgrtl.c (rtl_create_basic_block): Likewise.
+ * function.c (temp_slots_at_level): Likewise.
+ * reg-stack.c (stack_regs_mentioned): Likewise.
+ * regclass.c (allocate_reg_info): Likewise.
+ * tree-cfg.c (init_empty_tree_cfg, build_tree_cfg, create_bb,
+ set_bb_for_stmt, move_block_to_fn): Likewise.
+ * tree-complex.c (tree_lower_complex): Likewise.
+ * vec.h (VEC_safe_grow_cleared): New.
+
2007-01-02 Douglas Gregor <doug.gregor@gmail.com>
* c-common.c(c_common_nodes_and_builtins): Since variants of
diff --git a/gcc/alias.c b/gcc/alias.c
index ba7f948c89e..01429715f5d 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2453,9 +2453,7 @@ init_alias_analysis (void)
if (reg_base_value)
VEC_truncate (rtx, reg_base_value, 0);
- VEC_safe_grow (rtx, gc, reg_base_value, maxreg);
- memset (VEC_address (rtx, reg_base_value), 0,
- sizeof (rtx) * VEC_length (rtx, reg_base_value));
+ VEC_safe_grow_cleared (rtx, gc, reg_base_value, maxreg);
new_reg_base_value = XNEWVEC (rtx, maxreg);
reg_seen = XNEWVEC (char, maxreg);
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 967aa6cb7fc..3d05ebca0b7 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -543,9 +543,7 @@ find_basic_blocks (rtx f)
actually lay them out. */
basic_block_info = VEC_alloc (basic_block, gc, n_basic_blocks);
- VEC_safe_grow (basic_block, gc, basic_block_info, n_basic_blocks);
- memset (VEC_address (basic_block, basic_block_info), 0,
- sizeof (basic_block) * n_basic_blocks);
+ VEC_safe_grow_cleared (basic_block, gc, basic_block_info, n_basic_blocks);
SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index bb70bdf56f3..c6cc08f9018 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -327,12 +327,8 @@ rtl_create_basic_block (void *headp, void *endp, basic_block after)
/* Grow the basic block array if needed. */
if ((size_t) last_basic_block >= VEC_length (basic_block, basic_block_info))
{
- size_t old_size = VEC_length (basic_block, basic_block_info);
size_t new_size = last_basic_block + (last_basic_block + 3) / 4;
- basic_block *p;
- VEC_safe_grow (basic_block, gc, basic_block_info, new_size);
- p = VEC_address (basic_block, basic_block_info);
- memset (&p[old_size], 0, sizeof (basic_block) * (new_size - old_size));
+ VEC_safe_grow_cleared (basic_block, gc, basic_block_info, new_size);
}
n_basic_blocks++;
diff --git a/gcc/function.c b/gcc/function.c
index 581c0834d44..b657e2490eb 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -544,15 +544,7 @@ static struct temp_slot **
temp_slots_at_level (int level)
{
if (level >= (int) VEC_length (temp_slot_p, used_temp_slots))
- {
- size_t old_length = VEC_length (temp_slot_p, used_temp_slots);
- temp_slot_p *p;
-
- VEC_safe_grow (temp_slot_p, gc, used_temp_slots, level + 1);
- p = VEC_address (temp_slot_p, used_temp_slots);
- memset (&p[old_length], 0,
- sizeof (temp_slot_p) * (level + 1 - old_length));
- }
+ VEC_safe_grow_cleared (temp_slot_p, gc, used_temp_slots, level + 1);
return &(VEC_address (temp_slot_p, used_temp_slots)[level]);
}
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 49c733eb742..793c6b58ec4 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -315,16 +315,10 @@ stack_regs_mentioned (rtx insn)
max = VEC_length (char, stack_regs_mentioned_data);
if (uid >= max)
{
- char *p;
- unsigned int old_max = max;
-
/* Allocate some extra size to avoid too many reallocs, but
do not grow too quickly. */
max = uid + uid / 20 + 1;
- VEC_safe_grow (char, heap, stack_regs_mentioned_data, max);
- p = VEC_address (char, stack_regs_mentioned_data);
- memset (&p[old_max], 0,
- sizeof (char) * (max - old_max));
+ VEC_safe_grow_cleared (char, heap, stack_regs_mentioned_data, max);
}
test = VEC_index (char, stack_regs_mentioned_data, uid);
diff --git a/gcc/regclass.c b/gcc/regclass.c
index 8a0bab19026..7726ea1ec72 100644
--- a/gcc/regclass.c
+++ b/gcc/regclass.c
@@ -2177,9 +2177,8 @@ allocate_reg_info (size_t num_regs, int new_p, int renumber_p)
if (!reg_n_info)
{
reg_n_info = VEC_alloc (reg_info_p, heap, regno_allocated);
- VEC_safe_grow (reg_info_p, heap, reg_n_info, regno_allocated);
- memset (VEC_address (reg_info_p, reg_n_info), 0,
- sizeof (reg_info_p) * regno_allocated);
+ VEC_safe_grow_cleared (reg_info_p, heap, reg_n_info,
+ regno_allocated);
renumber = xmalloc (size_renumber);
reg_pref_buffer = XNEWVEC (struct reg_pref, regno_allocated);
}
@@ -2188,11 +2187,8 @@ allocate_reg_info (size_t num_regs, int new_p, int renumber_p)
size_t old_length = VEC_length (reg_info_p, reg_n_info);
if (old_length < regno_allocated)
{
- reg_info_p *addr;
- VEC_safe_grow (reg_info_p, heap, reg_n_info, regno_allocated);
- addr = VEC_address (reg_info_p, reg_n_info);
- memset (&addr[old_length], 0,
- sizeof (reg_info_p) * (regno_allocated - old_length));
+ VEC_safe_grow_cleared (reg_info_p, heap, reg_n_info,
+ regno_allocated);
}
else if (regno_allocated < old_length)
{
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 51c0d266aa0..973cd5c9949 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -133,15 +133,13 @@ init_empty_tree_cfg (void)
n_basic_blocks = NUM_FIXED_BLOCKS;
last_basic_block = NUM_FIXED_BLOCKS;
basic_block_info = VEC_alloc (basic_block, gc, initial_cfg_capacity);
- VEC_safe_grow (basic_block, gc, basic_block_info, initial_cfg_capacity);
- memset (VEC_address (basic_block, basic_block_info), 0,
- sizeof (basic_block) * initial_cfg_capacity);
+ VEC_safe_grow_cleared (basic_block, gc, basic_block_info,
+ initial_cfg_capacity);
/* Build a mapping of labels to their associated blocks. */
label_to_block_map = VEC_alloc (basic_block, gc, initial_cfg_capacity);
- VEC_safe_grow (basic_block, gc, label_to_block_map, initial_cfg_capacity);
- memset (VEC_address (basic_block, label_to_block_map),
- 0, sizeof (basic_block) * initial_cfg_capacity);
+ VEC_safe_grow_cleared (basic_block, gc, label_to_block_map,
+ initial_cfg_capacity);
SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
@@ -183,14 +181,7 @@ build_tree_cfg (tree *tp)
/* Adjust the size of the array. */
if (VEC_length (basic_block, basic_block_info) < (size_t) n_basic_blocks)
- {
- size_t old_size = VEC_length (basic_block, basic_block_info);
- basic_block *p;
- VEC_safe_grow (basic_block, gc, basic_block_info, n_basic_blocks);
- p = VEC_address (basic_block, basic_block_info);
- memset (&p[old_size], 0,
- sizeof (basic_block) * (n_basic_blocks - old_size));
- }
+ VEC_safe_grow_cleared (basic_block, gc, basic_block_info, n_basic_blocks);
/* To speed up statement iterator walks, we first purge dead labels. */
cleanup_dead_labels ();
@@ -397,12 +388,8 @@ create_bb (void *h, void *e, basic_block after)
/* Grow the basic block array if needed. */
if ((size_t) last_basic_block == VEC_length (basic_block, basic_block_info))
{
- size_t old_size = VEC_length (basic_block, basic_block_info);
size_t new_size = last_basic_block + (last_basic_block + 3) / 4;
- basic_block *p;
- VEC_safe_grow (basic_block, gc, basic_block_info, new_size);
- p = VEC_address (basic_block, basic_block_info);
- memset (&p[old_size], 0, sizeof (basic_block) * (new_size - old_size));
+ VEC_safe_grow_cleared (basic_block, gc, basic_block_info, new_size);
}
/* Add the newly created block to the array. */
@@ -2751,14 +2738,10 @@ set_bb_for_stmt (tree t, basic_block bb)
LABEL_DECL_UID (t) = uid = cfun->last_label_uid++;
if (old_len <= (unsigned) uid)
{
- basic_block *addr;
unsigned new_len = 3 * uid / 2;
- VEC_safe_grow (basic_block, gc, label_to_block_map,
- new_len);
- addr = VEC_address (basic_block, label_to_block_map);
- memset (&addr[old_len],
- 0, sizeof (basic_block) * (new_len - old_len));
+ VEC_safe_grow_cleared (basic_block, gc, label_to_block_map,
+ new_len);
}
}
else
@@ -4692,7 +4675,6 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
block_stmt_iterator si;
struct move_stmt_d d;
unsigned old_len, new_len;
- basic_block *addr;
/* Link BB to the new linked list. */
move_block_after (bb, after);
@@ -4719,9 +4701,8 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
if ((unsigned) cfg->x_last_basic_block >= old_len)
{
new_len = cfg->x_last_basic_block + (cfg->x_last_basic_block + 3) / 4;
- VEC_safe_grow (basic_block, gc, cfg->x_basic_block_info, new_len);
- addr = VEC_address (basic_block, cfg->x_basic_block_info);
- memset (&addr[old_len], 0, sizeof (basic_block) * (new_len - old_len));
+ VEC_safe_grow_cleared (basic_block, gc, cfg->x_basic_block_info,
+ new_len);
}
VEC_replace (basic_block, cfg->x_basic_block_info,
@@ -4757,11 +4738,8 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
if (old_len <= (unsigned) uid)
{
new_len = 3 * uid / 2;
- VEC_safe_grow (basic_block, gc, cfg->x_label_to_block_map,
- new_len);
- addr = VEC_address (basic_block, cfg->x_label_to_block_map);
- memset (&addr[old_len], 0,
- sizeof (basic_block) * (new_len - old_len));
+ VEC_safe_grow_cleared (basic_block, gc,
+ cfg->x_label_to_block_map, new_len);
}
VEC_replace (basic_block, cfg->x_label_to_block_map, uid, bb);
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index c3f4e0453ad..f985503a835 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -1492,10 +1492,8 @@ tree_lower_complex (void)
return 0;
complex_lattice_values = VEC_alloc (complex_lattice_t, heap, num_ssa_names);
- VEC_safe_grow (complex_lattice_t, heap,
- complex_lattice_values, num_ssa_names);
- memset (VEC_address (complex_lattice_t, complex_lattice_values), 0,
- num_ssa_names * sizeof(complex_lattice_t));
+ VEC_safe_grow_cleared (complex_lattice_t, heap,
+ complex_lattice_values, num_ssa_names);
init_parameter_lattice_values ();
ssa_propagate (complex_visit_stmt, complex_visit_phi);
@@ -1504,9 +1502,8 @@ tree_lower_complex (void)
int_tree_map_eq, free);
complex_ssa_name_components = VEC_alloc (tree, heap, 2*num_ssa_names);
- VEC_safe_grow (tree, heap, complex_ssa_name_components, 2*num_ssa_names);
- memset (VEC_address (tree, complex_ssa_name_components), 0,
- 2 * num_ssa_names * sizeof(tree));
+ VEC_safe_grow_cleared (tree, heap, complex_ssa_name_components,
+ 2 * num_ssa_names);
update_parameter_components ();
diff --git a/gcc/vec.h b/gcc/vec.h
index 1f134528374..b4f9f246fb7 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -302,6 +302,16 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#define VEC_safe_grow(T,A,V,I) \
(VEC_OP(T,A,safe_grow)(&(V),I VEC_CHECK_INFO MEM_STAT_INFO))
+/* Grow to a specific length.
+ void VEC_T_A_safe_grow_cleared (VEC(T,A) *&v, int len);
+
+ Grow the vector to a specific length. The LEN must be as
+ long or longer than the current length. The new elements are
+ initialized to zero. */
+
+#define VEC_safe_grow_cleared(T,A,V,I) \
+ (VEC_OP(T,A,safe_grow_cleared)(&(V),I VEC_CHECK_INFO MEM_STAT_INFO))
+
/* Replace element
T VEC_T_replace (VEC(T) *v, unsigned ix, T val); // Integer
T VEC_T_replace (VEC(T) *v, unsigned ix, T val); // Pointer
@@ -745,6 +755,15 @@ static inline void VEC_OP (T,A,safe_grow) \
VEC_BASE (*vec_)->num = size_; \
} \
\
+static inline void VEC_OP (T,A,safe_grow_cleared) \
+ (VEC(T,A) **vec_, int size_ VEC_CHECK_DECL MEM_STAT_DECL) \
+{ \
+ int oldsize = VEC_OP(T,base,length) VEC_BASE(*vec_); \
+ VEC_OP (T,A,safe_grow) (vec_, size_ VEC_CHECK_PASS PASS_MEM_STAT); \
+ memset (&(VEC_OP (T,base,address) (VEC_BASE(*vec_)))[oldsize], 0, \
+ sizeof (T) * (size_ - oldsize)); \
+} \
+ \
static inline T *VEC_OP (T,A,safe_push) \
(VEC(T,A) **vec_, T obj_ VEC_CHECK_DECL MEM_STAT_DECL) \
{ \
@@ -1014,6 +1033,15 @@ static inline void VEC_OP (T,A,safe_grow) \
VEC_BASE (*vec_)->num = size_; \
} \
\
+static inline void VEC_OP (T,A,safe_grow_cleared) \
+ (VEC(T,A) **vec_, int size_ VEC_CHECK_DECL MEM_STAT_DECL) \
+{ \
+ int oldsize = VEC_OP(T,base,length) VEC_BASE(*vec_); \
+ VEC_OP (T,A,safe_grow) (vec_, size_ VEC_CHECK_PASS PASS_MEM_STAT); \
+ memset (&(VEC_OP (T,base,address) (VEC_BASE(*vec_)))[oldsize], 0, \
+ sizeof (T) * (size_ - oldsize)); \
+} \
+ \
static inline T *VEC_OP (T,A,safe_push) \
(VEC(T,A) **vec_, const T *obj_ VEC_CHECK_DECL MEM_STAT_DECL) \
{ \
@@ -1097,6 +1125,24 @@ static inline void VEC_OP (T,A,safe_grow) \
VEC_BASE (*vec_)->num = size_; \
} \
\
+static inline void VEC_OP (T,A,safe_grow_cleared) \
+ (VEC(T,A) **vec_, int size_ VEC_CHECK_DECL MEM_STAT_DECL) \
+{ \
+ int oldsize = VEC_OP(T,base,length) VEC_BASE(*vec_); \
+ VEC_OP (T,A,safe_grow) (vec, size_); \
+ memset ((VEC_OP (T,base,address) (vec_))[oldsize], 0, \
+ sizeof (T) * (size_ - oldsize)); \
+} \
+ \
+static inline void VEC_OP (T,A,safe_grow_cleared) \
+ (VEC(T,A) **vec_, int size_ VEC_CHECK_DECL MEM_STAT_DECL) \
+{ \
+ int oldsize = VEC_OP(T,base,length) VEC_BASE(*vec_); \
+ VEC_OP (T,A,safe_grow) (vec_, size_ VEC_CHECK_PASS PASS_MEM_STAT); \
+ memset (&(VEC_OP (T,base,address) (VEC_BASE(*vec_)))[oldsize], 0, \
+ sizeof (T) * (size_ - oldsize)); \
+} \
+ \
static inline T *VEC_OP (T,A,safe_push) \
(VEC(T,A) **vec_, const T obj_ VEC_CHECK_DECL MEM_STAT_DECL) \
{ \