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.

From-SVN: r120351
This commit is contained in:
Kazu Hirata 2007-01-02 18:06:37 +00:00
parent fbc8d2d30e
commit 61465e7563
10 changed files with 93 additions and 72 deletions

View File

@ -1,4 +1,20 @@
2006-01-02 Ian Lance Taylor <iant@google.com>
2007-01-02 Kazu Hirata <kazu@codesourcery.com>
Revert:
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 Ian Lance Taylor <iant@google.com>
* c-common.c (c_common_truthvalue_conversion): When warning about
using an assignment as a truth value, set TREE_NO_WARNING.

View File

@ -2453,7 +2453,9 @@ init_alias_analysis (void)
if (reg_base_value)
VEC_truncate (rtx, reg_base_value, 0);
VEC_safe_grow_cleared (rtx, gc, reg_base_value, maxreg);
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));
new_reg_base_value = XNEWVEC (rtx, maxreg);
reg_seen = XNEWVEC (char, maxreg);

View File

@ -543,7 +543,9 @@ find_basic_blocks (rtx f)
actually lay them out. */
basic_block_info = VEC_alloc (basic_block, gc, n_basic_blocks);
VEC_safe_grow_cleared (basic_block, gc, basic_block_info, 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);
SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);

View File

@ -327,8 +327,12 @@ 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;
VEC_safe_grow_cleared (basic_block, gc, basic_block_info, new_size);
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));
}
n_basic_blocks++;

View File

@ -544,7 +544,15 @@ static struct temp_slot **
temp_slots_at_level (int level)
{
if (level >= (int) VEC_length (temp_slot_p, used_temp_slots))
VEC_safe_grow_cleared (temp_slot_p, gc, used_temp_slots, level + 1);
{
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));
}
return &(VEC_address (temp_slot_p, used_temp_slots)[level]);
}

View File

@ -315,10 +315,16 @@ 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_cleared (char, heap, stack_regs_mentioned_data, max);
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));
}
test = VEC_index (char, stack_regs_mentioned_data, uid);

View File

@ -2177,8 +2177,9 @@ 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_cleared (reg_info_p, heap, reg_n_info,
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);
renumber = xmalloc (size_renumber);
reg_pref_buffer = XNEWVEC (struct reg_pref, regno_allocated);
}
@ -2187,8 +2188,11 @@ 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)
{
VEC_safe_grow_cleared (reg_info_p, heap, reg_n_info,
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));
}
else if (regno_allocated < old_length)
{

View File

@ -133,13 +133,15 @@ 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_cleared (basic_block, gc, basic_block_info,
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);
/* Build a mapping of labels to their associated blocks. */
label_to_block_map = VEC_alloc (basic_block, gc, initial_cfg_capacity);
VEC_safe_grow_cleared (basic_block, gc, label_to_block_map,
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);
SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
@ -181,7 +183,14 @@ build_tree_cfg (tree *tp)
/* Adjust the size of the array. */
if (VEC_length (basic_block, basic_block_info) < (size_t) n_basic_blocks)
VEC_safe_grow_cleared (basic_block, gc, basic_block_info, 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));
}
/* To speed up statement iterator walks, we first purge dead labels. */
cleanup_dead_labels ();
@ -388,8 +397,12 @@ 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;
VEC_safe_grow_cleared (basic_block, gc, basic_block_info, new_size);
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));
}
/* Add the newly created block to the array. */
@ -2738,10 +2751,14 @@ 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_cleared (basic_block, gc, label_to_block_map,
new_len);
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));
}
}
else
@ -4675,6 +4692,7 @@ 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);
@ -4701,8 +4719,9 @@ 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_cleared (basic_block, gc, cfg->x_basic_block_info,
new_len);
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_replace (basic_block, cfg->x_basic_block_info,
@ -4738,8 +4757,11 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb,
if (old_len <= (unsigned) uid)
{
new_len = 3 * uid / 2;
VEC_safe_grow_cleared (basic_block, gc,
cfg->x_label_to_block_map, new_len);
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_replace (basic_block, cfg->x_label_to_block_map, uid, bb);

View File

@ -1492,8 +1492,10 @@ tree_lower_complex (void)
return 0;
complex_lattice_values = VEC_alloc (complex_lattice_t, heap, num_ssa_names);
VEC_safe_grow_cleared (complex_lattice_t, heap,
complex_lattice_values, 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));
init_parameter_lattice_values ();
ssa_propagate (complex_visit_stmt, complex_visit_phi);
@ -1502,8 +1504,9 @@ tree_lower_complex (void)
int_tree_map_eq, free);
complex_ssa_name_components = VEC_alloc (tree, heap, 2*num_ssa_names);
VEC_safe_grow_cleared (tree, heap, complex_ssa_name_components,
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));
update_parameter_components ();

View File

@ -302,16 +302,6 @@ 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
@ -755,15 +745,6 @@ 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) \
{ \
@ -1033,15 +1014,6 @@ 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) \
{ \
@ -1125,24 +1097,6 @@ 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) \
{ \