Skip to content
Permalink
Browse files

Remove unnecessary VEC function overloads.

Several VEC member functions that accept an element 'T' used to have
two overloads: one taking 'T', the second taking 'T *'.

This used to be needed because of the interface dichotomy between
vectors of objects and vectors of pointers.  In the past, vectors of
pointers would use pass-by-value semantics, but vectors of objects
would use pass-by-reference semantics.  This is no longer necessary,
but the distinction had remained.

The main side-effect of this change is some code reduction in code
that manipulates vectors of objects.  For instance,

-  struct iterator_use *iuse;
-
-  iuse = VEC_safe_push (iterator_use, heap, iterator_uses, NULL);
-  iuse->iterator = iterator;
-  iuse->ptr = ptr;
+  struct iterator_use iuse = {iterator, ptr};
+  VEC_safe_push (iterator_use, heap, iterator_uses, iuse);

Compile time performance was not affected.

Tested on x86_64 and ppc64.

Also built all-gcc on all targets using VEC routines: arm, bfin, c6x,
epiphany, ia64, mips, sh, spu, and vms.

2012-09-10  Diego Novillo  <dnovillo@google.com>

	* vec.h (vec_t::quick_push): Remove overload that accepts 'T *'.
	Update all users.
	(vec_t::safe_push): Likewise.
	(vec_t::quick_insert): Likewise.
	(vec_t::lower_bound): Likewise.
	(vec_t::safe_insert): Likewise.
	(vec_t::replace): Change second argument to 'T &'.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191165 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information...
dnovillo
dnovillo committed Sep 11, 2012
1 parent 85c0e76 commit e82e4eb5e9b3db07789a999a88a1b7909fd2dd45
Showing with 410 additions and 580 deletions.
  1. +10 −0 gcc/ChangeLog
  2. +4 −9 gcc/ada/gcc-interface/decl.c
  3. +4 −7 gcc/ada/gcc-interface/utils.c
  4. +2 −2 gcc/alias.c
  5. +1 −1 gcc/c-family/c-common.c
  6. +6 −9 gcc/c-family/c-pragma.c
  7. +4 −4 gcc/c/c-decl.c
  8. +2 −2 gcc/c/c-tree.h
  9. +2 −4 gcc/c/c-typeck.c
  10. +2 −2 gcc/config/mips/mips.c
  11. +2 −4 gcc/config/pa/pa.c
  12. +2 −5 gcc/config/rs6000/rs6000-c.c
  13. +2 −5 gcc/config/rs6000/rs6000.c
  14. +3 −5 gcc/cp/class.c
  15. +7 −9 gcc/cp/decl.c
  16. +2 −5 gcc/cp/except.c
  17. +13 −14 gcc/cp/init.c
  18. +8 −12 gcc/cp/name-lookup.c
  19. +8 −13 gcc/cp/parser.c
  20. +1 −1 gcc/cp/pt.c
  21. +6 −14 gcc/cp/semantics.c
  22. +28 −30 gcc/dwarf2cfi.c
  23. +15 −15 gcc/dwarf2out.c
  24. +1 −1 gcc/emit-rtl.c
  25. +3 −3 gcc/except.c
  26. +2 −3 gcc/fortran/trans-openmp.c
  27. +1 −1 gcc/fwprop.c
  28. +1 −1 gcc/gcc.c
  29. +4 −4 gcc/gcse.c
  30. +2 −3 gcc/genautomata.c
  31. +1 −1 gcc/genextract.c
  32. +1 −1 gcc/genopinit.c
  33. +1 −1 gcc/gimple-low.c
  34. +28 −19 gcc/go/gofrontend/expressions.cc
  35. +20 −15 gcc/go/gofrontend/gogo-tree.cc
  36. +1 −1 gcc/graphite-sese-to-poly.c
  37. +4 −4 gcc/ipa-inline-analysis.c
  38. +21 −24 gcc/ipa-prop.c
  39. +2 −2 gcc/ipa-split.c
  40. +4 −3 gcc/java/class.c
  41. +2 −3 gcc/java/expr.c
  42. +1 −1 gcc/lto-cgraph.c
  43. +7 −7 gcc/objc/objc-next-runtime-abi-02.c
  44. +2 −6 gcc/opts-common.c
  45. +4 −11 gcc/read-rtl.c
  46. +2 −5 gcc/ree.c
  47. +3 −6 gcc/reload1.c
  48. +1 −1 gcc/sel-sched-ir.c
  49. +2 −2 gcc/tree-call-cdce.c
  50. +10 −10 gcc/tree-data-ref.c
  51. +1 −1 gcc/tree-dfa.c
  52. +1 −1 gcc/tree-diagnostic.c
  53. +14 −14 gcc/tree-emutls.c
  54. +19 −20 gcc/tree-sra.c
  55. +3 −3 gcc/tree-ssa-dom.c
  56. +1 −1 gcc/tree-ssa-pre.c
  57. +2 −2 gcc/tree-ssa-reassoc.c
  58. +8 −8 gcc/tree-ssa-sccvn.c
  59. +39 −43 gcc/tree-ssa-structalias.c
  60. +1 −1 gcc/tree-ssa.c
  61. +8 −11 gcc/tree-switch-conversion.c
  62. +2 −3 gcc/tree-vect-generic.c
  63. +1 −1 gcc/tree-vect-loop-manip.c
  64. +2 −2 gcc/tree-vect-slp.c
  65. +1 −1 gcc/tree-vectorizer.h
  66. +1 −1 gcc/tree-vrp.c
  67. +2 −4 gcc/tree.c
  68. +2 −3 gcc/tree.h
  69. +9 −7 gcc/var-tracking.c
  70. +7 −14 gcc/varasm.c
  71. +21 −128 gcc/vec.h
@@ -1,3 +1,13 @@
2012-09-10 Diego Novillo <dnovillo@google.com>

* vec.h (vec_t::quick_push): Remove overload that accepts 'T *'.
Update all users.
(vec_t::safe_push): Likewise.
(vec_t::quick_insert): Likewise.
(vec_t::lower_bound): Likewise.
(vec_t::safe_insert): Likewise.
(vec_t::replace): Change second argument to 'T &'.

2012-09-10 Maciej W. Rozycki <macro@codesourcery.com>

* config/rs6000/rs6000.md: Move a splitter next to its insn.
@@ -7507,9 +7507,8 @@ build_subst_list (Entity_Id gnat_subtype, Entity_Id gnat_type, bool definition)
(Node (gnat_value), gnat_subtype,
get_entity_name (gnat_discrim),
definition, true, false));
subst_pair *s = VEC_safe_push (subst_pair, heap, gnu_list, NULL);
s->discriminant = gnu_field;
s->replacement = replacement;
subst_pair s = {gnu_field, replacement};
VEC_safe_push (subst_pair, heap, gnu_list, s);
}

return gnu_list;
@@ -7541,14 +7540,10 @@ build_variant_list (tree qual_union_type, VEC(subst_pair,heap) *subst_list,
still be accessed. */
if (!integer_zerop (qual))
{
variant_desc *v;
tree variant_type = TREE_TYPE (gnu_field), variant_subpart;
variant_desc v = {variant_type, gnu_field, qual, NULL_TREE};

v = VEC_safe_push (variant_desc, heap, gnu_list, NULL);
v->type = variant_type;
v->field = gnu_field;
v->qual = qual;
v->new_type = NULL_TREE;
VEC_safe_push (variant_desc, heap, gnu_list, v);

/* Recurse on the variant subpart of the variant, if any. */
variant_subpart = get_variant_part (variant_type);
@@ -4615,16 +4615,14 @@ convert (tree type, tree expr)

FOR_EACH_CONSTRUCTOR_ELT(e, idx, index, value)
{
constructor_elt *elt;
/* We expect only simple constructors. */
if (!SAME_FIELD_P (index, efield))
break;
/* The field must be the same. */
if (!SAME_FIELD_P (efield, field))
break;
elt = VEC_quick_push (constructor_elt, v, NULL);
elt->index = field;
elt->value = convert (TREE_TYPE (field), value);
constructor_elt elt = {field, convert (TREE_TYPE (field), value)};
VEC_quick_push (constructor_elt, v, elt);

/* If packing has made this field a bitfield and the input
value couldn't be emitted statically any more, we need to
@@ -4690,9 +4688,8 @@ convert (tree type, tree expr)
v = VEC_alloc (constructor_elt, gc, len);
FOR_EACH_CONSTRUCTOR_VALUE (e, ix, value)
{
constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL);
elt->index = NULL_TREE;
elt->value = value;
constructor_elt elt = {NULL_TREE, value};
VEC_quick_push (constructor_elt, v, elt);
}
expr = copy_node (expr);
TREE_TYPE (expr) = type;
@@ -855,8 +855,8 @@ new_alias_set (void)
if (flag_strict_aliasing)
{
if (alias_sets == 0)
VEC_safe_push (alias_set_entry, gc, alias_sets, (alias_set_entry) 0);
VEC_safe_push (alias_set_entry, gc, alias_sets, (alias_set_entry) 0);
VEC_safe_push (alias_set_entry, gc, alias_sets, 0);
VEC_safe_push (alias_set_entry, gc, alias_sets, 0);
return VEC_length (alias_set_entry, alias_sets) - 1;
}
else
@@ -8535,7 +8535,7 @@ parse_optimize_options (tree args, bool attr_p)
/* Build up argv vector. Just in case the string is stored away, use garbage
collected strings. */
VEC_truncate (const_char_p, optimize_args, 0);
VEC_safe_push (const_char_p, gc, optimize_args, (const_char_p)NULL);
VEC_safe_push (const_char_p, gc, optimize_args, NULL);

for (ap = args; ap != NULL_TREE; ap = TREE_CHAIN (ap))
{
@@ -372,10 +372,8 @@ handle_pragma_weak (cpp_reader * ARG_UNUSED (dummy))
}
else
{
pending_weak *pe;
pe = VEC_safe_push (pending_weak, gc, pending_weaks, NULL);
pe->name = name;
pe->value = value;
pending_weak pe = {name, value};
VEC_safe_push (pending_weak, gc, pending_weaks, pe);
}
}

@@ -499,9 +497,8 @@ add_to_renaming_pragma_list (tree oldname, tree newname)
return;
}

p = VEC_safe_push (pending_redefinition, gc, pending_redefine_extname, NULL);
p->oldname = oldname;
p->newname = newname;
pending_redefinition e = {oldname, newname};
VEC_safe_push (pending_redefinition, gc, pending_redefine_extname, e);
}

/* The current prefix set by #pragma extern_prefix. */
@@ -1236,14 +1233,14 @@ c_register_pragma_1 (const char *space, const char *name,

ns_name.space = space;
ns_name.name = name;
VEC_safe_push (pragma_ns_name, heap, registered_pp_pragmas, &ns_name);
VEC_safe_push (pragma_ns_name, heap, registered_pp_pragmas, ns_name);
id = VEC_length (pragma_ns_name, registered_pp_pragmas);
id += PRAGMA_FIRST_EXTERNAL - 1;
}
else
{
VEC_safe_push (internal_pragma_handler, heap, registered_pragmas,
&ihandler);
ihandler);
id = VEC_length (internal_pragma_handler, registered_pragmas);
id += PRAGMA_FIRST_EXTERNAL - 1;

@@ -6437,7 +6437,7 @@ get_parm_info (bool ellipsis, tree expr)
{
tree decl = b->decl;
tree type = TREE_TYPE (decl);
c_arg_tag *tag;
c_arg_tag tag;
const char *keyword;

switch (TREE_CODE (decl))
@@ -6511,9 +6511,9 @@ get_parm_info (bool ellipsis, tree expr)
}
}

tag = VEC_safe_push (c_arg_tag, gc, tags, NULL);
tag->id = b->id;
tag->type = decl;
tag.id = b->id;
tag.type = decl;
VEC_safe_push (c_arg_tag, gc, tags, tag);
break;

case CONST_DECL:
@@ -142,8 +142,8 @@ DEF_VEC_ALLOC_O (c_expr_t, heap);
/* Append a new c_expr_t element to V. */
#define C_EXPR_APPEND(V, ELEM) \
do { \
c_expr_t *__elem_p = VEC_safe_push (c_expr_t, gc, V, NULL); \
*__elem_p = (ELEM); \
c_expr_t __elem = (ELEM); \
VEC_safe_push (c_expr_t, gc, V, __elem); \
} while (0)

/* A kind of type specifier. Note that this information is currently
@@ -7709,7 +7709,6 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type,
struct obstack * braced_init_obstack)
{
tree semantic_type = NULL_TREE;
constructor_elt *celt;
bool maybe_const = true;
bool npc;

@@ -7876,9 +7875,8 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type,
/* Otherwise, output this element either to
constructor_elements or to the assembler file. */

celt = VEC_safe_push (constructor_elt, gc, constructor_elements, NULL);
celt->index = field;
celt->value = value;
constructor_elt celt = {field, value};
VEC_safe_push (constructor_elt, gc, constructor_elements, celt);

/* Advance the variable that indicates sequential elements output. */
if (TREE_CODE (constructor_type) == ARRAY_TYPE)
@@ -3989,8 +3989,8 @@ mips_multi_start (void)
static struct mips_multi_member *
mips_multi_add (void)
{
return VEC_safe_push (mips_multi_member, heap, mips_multi_members,
(struct mips_multi_member *) 0);
mips_multi_member empty;
return VEC_safe_push (mips_multi_member, heap, mips_multi_members, empty);
}

/* Add a normal insn with the given asm format to the current multi-insn
@@ -9948,11 +9948,9 @@ static GTY(()) VEC(extern_symbol,gc) *extern_symbols;
void
pa_hpux_asm_output_external (FILE *file, tree decl, const char *name)
{
extern_symbol * p = VEC_safe_push (extern_symbol, gc, extern_symbols, NULL);

gcc_assert (file == asm_out_file);
p->decl = decl;
p->name = name;
extern_symbol p = {decl, name};
VEC_safe_push (extern_symbol, gc, extern_symbols, p);
}

/* Output text required at the end of an assembler file.
@@ -3582,11 +3582,8 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
vec = VEC_alloc (constructor_elt, gc, size);
for(i = 0; i < size; i++)
{
constructor_elt *elt;

elt = VEC_quick_push (constructor_elt, vec, NULL);
elt->index = NULL_TREE;
elt->value = arg;
constructor_elt elt = {NULL_TREE, arg};
VEC_quick_push (constructor_elt, vec, elt);
}
return build_constructor (type, vec);
}
add_compiler_branch_island (tree label_name, tree function_name,
int line_number)
{
branch_island *bi = VEC_safe_push (branch_island, gc, branch_islands, NULL);

bi->function_name = function_name;
bi->label_name = label_name;
bi->line_number = line_number;
branch_island bi = {function_name, label_name, line_number};
VEC_safe_push (branch_island, gc, branch_islands, bi);
}

/* Generate far-jump branch islands for everything recorded in
@@ -8835,11 +8835,9 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid)
offset. */
if (vid->binfo == TYPE_BINFO (vid->derived))
{
tree_pair_p elt = VEC_safe_push (tree_pair_s, gc,
CLASSTYPE_VCALL_INDICES (vid->derived),
NULL);
elt->purpose = orig_fn;
elt->value = vid->index;
tree_pair_s elt = {orig_fn, vid->index};
VEC_safe_push (tree_pair_s, gc, CLASSTYPE_VCALL_INDICES (vid->derived),
elt);
}

/* The next vcall offset will be found at a more negative
@@ -2639,16 +2639,16 @@ tree
declare_local_label (tree id)
{
tree decl;
cp_label_binding *bind;
cp_label_binding bind;

/* Add a new entry to the SHADOWED_LABELS list so that when we leave
this scope we can restore the old value of IDENTIFIER_TYPE_VALUE. */
bind = VEC_safe_push (cp_label_binding, gc,
current_binding_level->shadowed_labels, NULL);
bind->prev_value = IDENTIFIER_LABEL_VALUE (id);
bind.prev_value = IDENTIFIER_LABEL_VALUE (id);

decl = make_label_decl (id, /*local_p=*/1);
bind->label = decl;
bind.label = decl;
VEC_safe_push (cp_label_binding, gc, current_binding_level->shadowed_labels,
bind);

return decl;
}
@@ -13782,10 +13782,8 @@ maybe_register_incomplete_var (tree var)
|| (TYPE_LANG_SPECIFIC (inner_type)
&& TYPE_BEING_DEFINED (inner_type)))
{
incomplete_var *iv
= VEC_safe_push (incomplete_var, gc, incomplete_vars, NULL);
iv->decl = var;
iv->incomplete_type = inner_type;
incomplete_var iv = {var, inner_type};
VEC_safe_push (incomplete_var, gc, incomplete_vars, iv);
}
}
}
@@ -1249,11 +1249,8 @@ expr_noexcept_p (tree expr, tsubst_flags_t complain)
if (!DECL_INITIAL (fn))
{
/* Not defined yet; check again at EOF. */
pending_noexcept *p
= VEC_safe_push (pending_noexcept, gc,
pending_noexcept_checks, NULL);
p->fn = fn;
p->loc = input_location;
pending_noexcept p = {fn, input_location};
VEC_safe_push (pending_noexcept, gc, pending_noexcept_checks, p);
}
else
maybe_noexcept_warning (fn);
@@ -253,21 +253,21 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
{
constructor_elt *ce;
constructor_elt ce;

v = VEC_alloc (constructor_elt, gc, 1);
ce = VEC_quick_push (constructor_elt, v, NULL);

/* If this is a one element array, we just use a regular init. */
if (tree_int_cst_equal (size_zero_node, max_index))
ce->index = size_zero_node;
ce.index = size_zero_node;
else
ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
max_index);

ce->value = build_zero_init_1 (TREE_TYPE (type),
ce.value = build_zero_init_1 (TREE_TYPE (type),
/*nelts=*/NULL_TREE,
static_storage_p, NULL_TREE);
VEC_quick_push (constructor_elt, v, ce);
}

/* Build a constructor to contain the initializations. */
@@ -448,28 +448,27 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
{
constructor_elt *ce;
constructor_elt ce;

v = VEC_alloc (constructor_elt, gc, 1);
ce = VEC_quick_push (constructor_elt, v, NULL);

/* If this is a one element array, we just use a regular init. */
if (tree_int_cst_equal (size_zero_node, max_index))
ce->index = size_zero_node;
ce.index = size_zero_node;
else
ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
max_index);
ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node, max_index);

ce->value = build_value_init (TREE_TYPE (type), complain);
ce.value = build_value_init (TREE_TYPE (type), complain);
VEC_quick_push (constructor_elt, v, ce);

if (ce->value == error_mark_node)
if (ce.value == error_mark_node)
return error_mark_node;

/* We shouldn't have gotten here for anything that would need
non-trivial initialization, and gimplify_init_ctor_preeval
would need to be fixed to allow it. */
gcc_assert (TREE_CODE (ce->value) != TARGET_EXPR
&& TREE_CODE (ce->value) != AGGR_INIT_EXPR);
gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR
&& TREE_CODE (ce.value) != AGGR_INIT_EXPR);
}

/* Build a constructor to contain the initializations. */

0 comments on commit e82e4eb

Please sign in to comment.
You can’t perform that action at this time.