alias.c (init_alias_analysis): Use VEC_safe_grow_cleared.

* 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.

From-SVN: r120386
This commit is contained in:
Kazu Hirata 2007-01-03 08:04:01 +00:00
parent 7bda5cc2e6
commit a590ac6560
10 changed files with 74 additions and 77 deletions

View File

@ -6,7 +6,18 @@
* config/i386/i386.md (*sse_prologue_save_insn): Use return
instead of RET.
2006-01-03 Zdenek Dvorak <dvorakz@suse.cz>
* 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-03 Zdenek Dvorak <dvorakz@suse.cz>
* loop-unswitch.c (unswitch_loop): Pass probabilities to loopify.
* tree-ssa-loop-unswitch.c (tree_unswitch_loop): Pass probabilities

View File

@ -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);

View File

@ -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);

View File

@ -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++;

View File

@ -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]);
}

View File

@ -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);

View File

@ -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)
{

View File

@ -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
@ -4694,7 +4677,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);
@ -4721,9 +4703,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,
@ -4759,11 +4740,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);

View File

@ -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 ();

View File

@ -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,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) \
{ \