From 5ebf7810cd29c83954f1b5522d2098ff758a62f0 Mon Sep 17 00:00:00 2001 From: kazu Date: Tue, 2 Jan 2007 18:06:37 +0000 Subject: [PATCH] Revert: 2007-01-02 Kazu Hirata * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120351 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 18 +++++++++++++++++- gcc/alias.c | 4 +++- gcc/cfgbuild.c | 4 +++- gcc/cfgrtl.c | 6 +++++- gcc/function.c | 10 +++++++++- gcc/reg-stack.c | 8 +++++++- gcc/regclass.c | 12 ++++++++---- gcc/tree-cfg.c | 46 ++++++++++++++++++++++++++++++++++------------ gcc/tree-complex.c | 11 +++++++---- gcc/vec.h | 46 ---------------------------------------------- 10 files changed, 93 insertions(+), 72 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 30e9a20759a..9406b46185a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,20 @@ -2006-01-02 Ian Lance Taylor +2007-01-02 Kazu Hirata + + Revert: + 2007-01-02 Kazu Hirata + + * 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 * c-common.c (c_common_truthvalue_conversion): When warning about using an assignment as a truth value, set TREE_NO_WARNING. diff --git a/gcc/alias.c b/gcc/alias.c index 01429715f5d..ba7f948c89e 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -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); diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c index 3d05ebca0b7..967aa6cb7fc 100644 --- a/gcc/cfgbuild.c +++ b/gcc/cfgbuild.c @@ -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); diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index c6cc08f9018..bb70bdf56f3 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -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++; diff --git a/gcc/function.c b/gcc/function.c index b657e2490eb..581c0834d44 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -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]); } diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c index 793c6b58ec4..49c733eb742 100644 --- a/gcc/reg-stack.c +++ b/gcc/reg-stack.c @@ -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); diff --git a/gcc/regclass.c b/gcc/regclass.c index 7726ea1ec72..8a0bab19026 100644 --- a/gcc/regclass.c +++ b/gcc/regclass.c @@ -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) { diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 973cd5c9949..51c0d266aa0 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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); diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index f985503a835..c3f4e0453ad 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -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 (); diff --git a/gcc/vec.h b/gcc/vec.h index b4f9f246fb7..1f134528374 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -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) \ { \ -- 2.11.4.GIT