Skip to content

Commit

Permalink
Introduce vNULL to use as a nil initializer for vec<>.
Browse files Browse the repository at this point in the history
This patch implements Jakub's idea of adding an empty struct with
a typecast operator that returns nil vectors.  This is useful to
shorten all the initializers when declaring vec instances or passing
nil vectors as function arguments.

2012-11-20  Diego Novillo  <[email protected]>
	    Jakub Jelinek  <[email protected]>

ChangeLog
	* vec.h (struct vnull): Declare.
	(vNULL): Declare.
	* vec.c (vNULL): Define.
	* bb-reorder.c: Replace all vec<T, A>() initializers with vNULL.
	* cfgexpand.c: Likewise.
	* cfgloop.c: Likewise.
	* cfgloopanal.c: Likewise.
	* cfgloopmanip.c: Likewise.
	* cgraph.c: Likewise.
	* config/c6x/c6x.c: Likewise.
	* config/i386/i386.c: Likewise.
	* df-core.c: Likewise.
	* dominance.c: Likewise.
	* dwarf2out.c: Likewise.
	* except.c: Likewise.
	* function.c: Likewise.
	* gcse.c: Likewise.
	* genautomata.c: Likewise.
	* graphds.c: Likewise.
	* graphite-scop-detection.c: Likewise.
	* graphite.c: Likewise.
	* haifa-sched.c: Likewise.
	* ifcvt.c: Likewise.
	* ipa-cp.c: Likewise.
	* ipa-inline-analysis.c: Likewise.
	* ipa-inline-transform.c: Likewise.
	* ipa-inline.c: Likewise.
	* ipa-prop.c: Likewise.
	* ipa-split.c: Likewise.
	* ipa-utils.c: Likewise.
	* ira-build.c: Likewise.
	* lto-cgraph.c: Likewise.
	* lto-streamer-in.c: Likewise.
	* lto-symtab.c: Likewise.
	* opts-global.c: Likewise.
	* passes.c: Likewise.
	* ree.c: Likewise.
	* sched-deps.c: Likewise.
	* sel-sched-ir.c: Likewise.
	* sel-sched-ir.h: Likewise.
	* sel-sched.c: Likewise.
	* stor-layout.c: Likewise.
	* trans-mem.c: Likewise.
	* tree-call-cdce.c: Likewise.
	* tree-cfg.c: Likewise.
	* tree-data-ref.c: Likewise.
	* tree-diagnostic.c: Likewise.
	* tree-eh.c: Likewise.
	* tree-loop-distribution.c: Likewise.
	* tree-predcom.c: Likewise.
	* tree-ssa-loop-im.c: Likewise.
	* tree-ssa-loop-ivcanon.c: Likewise.
	* tree-ssa-loop-manip.c: Likewise.
	* tree-ssa-loop-niter.c: Likewise.
	* tree-ssa-loop-prefetch.c: Likewise.
	* tree-ssa-math-opts.c: Likewise.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-pre.c: Likewise.
	* tree-ssa-propagate.c: Likewise.
	* tree-ssa-reassoc.c: Likewise.
	* tree-ssa-sccvn.c: Likewise.
	* tree-ssa-structalias.c: Likewise.
	* tree-ssa-threadedge.c: Likewise.
	* tree-ssa-uninit.c: Likewise.
	* tree-stdarg.c: Likewise.
	* tree-switch-conversion.c: Likewise.
	* tree-vect-data-refs.c: Likewise.
	* tree-vect-loop.c: Likewise.
	* tree-vect-slp.c: Likewise.
	* tree-vect-stmts.c: Likewise.
	* value-prof.c: Likewise.
	* varasm.c: Likewise.

ada/ChangeLog
	* gcc-interface/decl.c: Replace all vec<T,A>()
	initializers with vNULL.

cp/ChangeLog
	* name-lookup.c: Replace all vec<T, A>() initializers
	with vNULL.
	* semantics.c: Likewise.

fortran/ChangeLog
	* trans-openmp.c: Replace all vec<T, A>() initializers
	with vNULL.

lto/ChangeLog
	* lto.c: Replace all vec<T, A>() initializers with vNULL.

objc/ChangeLog
	* objc-act.c: Replace all vec<T, A>() initializers with vNULL.

Co-Authored-By: Jakub Jelinek <[email protected]>

From-SVN: r193677
  • Loading branch information
dnovillo authored and Diego Novillo committed Nov 20, 2012
1 parent b014e12 commit 6e1aa84
Show file tree
Hide file tree
Showing 83 changed files with 355 additions and 251 deletions.
76 changes: 76 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,82 @@
* config/rs6000/rs6000.md (largetoc_low): Revert.
(largetoc_low_aix<mode>): New.

2012-11-20 Diego Novillo <[email protected]>
Jakub Jelinek <[email protected]>

* vec.h (struct vnull): Declare.
(vNULL): Declare.
* vec.c (vNULL): Define.
* bb-reorder.c: Replace all vec<T, A>() initializers with vNULL.
* cfgexpand.c: Likewise.
* cfgloop.c: Likewise.
* cfgloopanal.c: Likewise.
* cfgloopmanip.c: Likewise.
* cgraph.c: Likewise.
* config/c6x/c6x.c: Likewise.
* config/i386/i386.c: Likewise.
* df-core.c: Likewise.
* dominance.c: Likewise.
* dwarf2out.c: Likewise.
* except.c: Likewise.
* function.c: Likewise.
* gcse.c: Likewise.
* genautomata.c: Likewise.
* graphds.c: Likewise.
* graphite-scop-detection.c: Likewise.
* graphite.c: Likewise.
* haifa-sched.c: Likewise.
* ifcvt.c: Likewise.
* ipa-cp.c: Likewise.
* ipa-inline-analysis.c: Likewise.
* ipa-inline-transform.c: Likewise.
* ipa-inline.c: Likewise.
* ipa-prop.c: Likewise.
* ipa-split.c: Likewise.
* ipa-utils.c: Likewise.
* ira-build.c: Likewise.
* lto-cgraph.c: Likewise.
* lto-streamer-in.c: Likewise.
* lto-symtab.c: Likewise.
* opts-global.c: Likewise.
* passes.c: Likewise.
* ree.c: Likewise.
* sched-deps.c: Likewise.
* sel-sched-ir.c: Likewise.
* sel-sched-ir.h: Likewise.
* sel-sched.c: Likewise.
* stor-layout.c: Likewise.
* trans-mem.c: Likewise.
* tree-call-cdce.c: Likewise.
* tree-cfg.c: Likewise.
* tree-data-ref.c: Likewise.
* tree-diagnostic.c: Likewise.
* tree-eh.c: Likewise.
* tree-loop-distribution.c: Likewise.
* tree-predcom.c: Likewise.
* tree-ssa-loop-im.c: Likewise.
* tree-ssa-loop-ivcanon.c: Likewise.
* tree-ssa-loop-manip.c: Likewise.
* tree-ssa-loop-niter.c: Likewise.
* tree-ssa-loop-prefetch.c: Likewise.
* tree-ssa-math-opts.c: Likewise.
* tree-ssa-phiopt.c: Likewise.
* tree-ssa-pre.c: Likewise.
* tree-ssa-propagate.c: Likewise.
* tree-ssa-reassoc.c: Likewise.
* tree-ssa-sccvn.c: Likewise.
* tree-ssa-structalias.c: Likewise.
* tree-ssa-threadedge.c: Likewise.
* tree-ssa-uninit.c: Likewise.
* tree-stdarg.c: Likewise.
* tree-switch-conversion.c: Likewise.
* tree-vect-data-refs.c: Likewise.
* tree-vect-loop.c: Likewise.
* tree-vect-slp.c: Likewise.
* tree-vect-stmts.c: Likewise.
* value-prof.c: Likewise.
* varasm.c: Likewise.

2012-11-20 Diego Novillo <[email protected]>

* Makefile.in (tlink.o): Add dependency on VEC_H.
Expand Down
6 changes: 6 additions & 0 deletions gcc/ada/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2012-11-20 Diego Novillo <[email protected]>
Jakub Jelinek <[email protected]>

* gcc-interface/decl.c: Replace all vec<T,A>()
initializers with vNULL.

2012-11-18 Eric Botcazou <[email protected]>

* gcc-interface/decl.c: Remove trailing spaces.
Expand Down
4 changes: 2 additions & 2 deletions gcc/ada/gcc-interface/decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3327,7 +3327,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_variant_list
= build_variant_list (TREE_TYPE (gnu_variant_part),
gnu_subst_list,
vec<variant_desc>());
vNULL);

/* If all the qualifiers are unconditionally true, the
innermost variant is statically selected. */
Expand Down Expand Up @@ -7552,7 +7552,7 @@ build_position_list (tree gnu_type, bool do_not_flatten_variant, tree gnu_pos,
static vec<subst_pair>
build_subst_list (Entity_Id gnat_subtype, Entity_Id gnat_type, bool definition)
{
vec<subst_pair> gnu_list = vec<subst_pair>();
vec<subst_pair> gnu_list = vNULL;
Entity_Id gnat_discrim;
Node_Id gnat_value;

Expand Down
2 changes: 1 addition & 1 deletion gcc/bb-reorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ fix_up_crossing_landing_pad (eh_landing_pad old_lp, basic_block old_bb)
static vec<edge>
find_rarely_executed_basic_blocks_and_crossing_edges (void)
{
vec<edge> crossing_edges = vec<edge>();
vec<edge> crossing_edges = vNULL;
basic_block bb;
edge e;
edge_iterator ei;
Expand Down
6 changes: 3 additions & 3 deletions gcc/cfgexpand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ static rtx
expand_used_vars (void)
{
tree var, outer_block = DECL_INITIAL (current_function_decl);
vec<tree> maybe_local_decls = vec<tree>();
vec<tree> maybe_local_decls = vNULL;
rtx var_end_seq = NULL_RTX;
struct pointer_map_t *ssa_name_decls;
unsigned i;
Expand Down Expand Up @@ -1675,8 +1675,8 @@ expand_used_vars (void)
{
struct stack_vars_data data;

data.asan_vec = vec<HOST_WIDE_INT>();
data.asan_decl_vec = vec<tree>();
data.asan_vec = vNULL;
data.asan_decl_vec = vNULL;

/* Reorder decls to be protected by iterating over the variables
array multiple times, and allocating out of each phase in turn. */
Expand Down
6 changes: 3 additions & 3 deletions gcc/cfgloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ get_loop_latch_edges (const struct loop *loop)
{
edge_iterator ei;
edge e;
vec<edge> ret = vec<edge>();
vec<edge> ret = vNULL;

FOR_EACH_EDGE (e, ei, loop->header->preds)
{
Expand Down Expand Up @@ -225,7 +225,7 @@ flow_loops_free (struct loops *loops)
int
flow_loop_nodes_find (basic_block header, struct loop *loop)
{
vec<basic_block> stack = vec<basic_block>();
vec<basic_block> stack = vNULL;
int num_nodes = 1;
edge latch;
edge_iterator latch_ei;
Expand Down Expand Up @@ -1117,7 +1117,7 @@ release_recorded_exits (void)
vec<edge>
get_loop_exit_edges (const struct loop *loop)
{
vec<edge> edges = vec<edge>();
vec<edge> edges = vNULL;
edge e;
unsigned i;
basic_block *body;
Expand Down
2 changes: 1 addition & 1 deletion gcc/cfgloopanal.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ vec<basic_block>
get_loop_hot_path (const struct loop *loop)
{
basic_block bb = loop->header;
vec<basic_block> path = vec<basic_block>();
vec<basic_block> path = vNULL;
bitmap visited = BITMAP_ALLOC (NULL);

while (true)
Expand Down
2 changes: 1 addition & 1 deletion gcc/cfgloopmanip.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ scale_loop_profile (struct loop *loop, int scale, int iteration_bound)
static void
update_dominators_in_loop (struct loop *loop)
{
vec<basic_block> dom_bbs = vec<basic_block>();
vec<basic_block> dom_bbs = vNULL;
sbitmap seen;
basic_block *body;
unsigned i;
Expand Down
2 changes: 1 addition & 1 deletion gcc/cgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ collect_callers_of_node_1 (struct cgraph_node *node, void *data)
vec<cgraph_edge_p>
collect_callers_of_node (struct cgraph_node *node)
{
vec<cgraph_edge_p> redirect_callers = vec<cgraph_edge_p>();
vec<cgraph_edge_p> redirect_callers = vNULL;
cgraph_for_node_and_aliases (node, collect_callers_of_node_1,
&redirect_callers, false);
return redirect_callers;
Expand Down
2 changes: 1 addition & 1 deletion gcc/config/c6x/c6x.c
Original file line number Diff line number Diff line change
Expand Up @@ -3420,7 +3420,7 @@ try_rename_operands (rtx head, rtx tail, unit_req_table reqs, rtx insn,
int i;
unsigned tmp_mask;
int best_reg, old_reg;
vec<du_head_p> involved_chains = vec<du_head_p>();
vec<du_head_p> involved_chains = vNULL;
unit_req_table new_reqs;

for (i = 0, tmp_mask = op_mask; tmp_mask; i++)
Expand Down
4 changes: 2 additions & 2 deletions gcc/config/i386/i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -28768,7 +28768,7 @@ dispatch_function_versions (tree dispatch_decl,
/* Function version dispatch is via IFUNC. IFUNC resolvers fire before
constructors, so explicity call __builtin_cpu_init here. */
ifunc_cpu_init_stmt = gimple_build_call_vec (
ix86_builtins [(int) IX86_BUILTIN_CPU_INIT], vec<tree>());
ix86_builtins [(int) IX86_BUILTIN_CPU_INIT], vNULL);
gimple_seq_add_stmt (&gseq, ifunc_cpu_init_stmt);
gimple_set_bb (ifunc_cpu_init_stmt, *empty_bb);
set_bb_seq (*empty_bb, gseq);
Expand Down Expand Up @@ -29275,7 +29275,7 @@ ix86_generate_version_dispatcher_body (void *node_p)
{
tree resolver_decl;
basic_block empty_bb;
vec<tree> fn_ver_vec = vec<tree>();
vec<tree> fn_ver_vec = vNULL;
tree default_ver_decl;
struct cgraph_node *versn;
struct cgraph_node *node;
Expand Down
7 changes: 7 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2012-11-20 Diego Novillo <[email protected]>
Jakub Jelinek <[email protected]>

* name-lookup.c: Replace all vec<T, A>() initializers
with vNULL.
* semantics.c: Likewise.

2012-11-19 Paolo Carlini <[email protected]>

PR c++/55368
Expand Down
8 changes: 4 additions & 4 deletions gcc/cp/name-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4222,8 +4222,8 @@ remove_hidden_names (tree fns)
void
suggest_alternatives_for (location_t location, tree name)
{
vec<tree> candidates = vec<tree>();
vec<tree> namespaces_to_search = vec<tree>();
vec<tree> candidates = vNULL;
vec<tree> namespaces_to_search = vNULL;
int max_to_search = PARAM_VALUE (CXX_MAX_NAMESPACES_FOR_DIAGNOSTIC_HELP);
int n_searched = 0;
tree t;
Expand Down Expand Up @@ -5900,7 +5900,7 @@ store_binding (tree id, vec<cxx_saved_binding, va_gc> **old_bindings)
static void
store_bindings (tree names, vec<cxx_saved_binding, va_gc> **old_bindings)
{
static vec<tree> bindings_need_stored = vec<tree>();
static vec<tree> bindings_need_stored = vNULL;
tree t, id;
size_t i;

Expand Down Expand Up @@ -5936,7 +5936,7 @@ static void
store_class_bindings (vec<cp_class_binding, va_gc> *names,
vec<cxx_saved_binding, va_gc> **old_bindings)
{
static vec<tree> bindings_need_stored = vec<tree>();
static vec<tree> bindings_need_stored = vNULL;
size_t i;
cp_class_binding *cb;

Expand Down
4 changes: 2 additions & 2 deletions gcc/cp/semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -6510,7 +6510,7 @@ cxx_bind_parameters_in_call (const constexpr_call *old_call, tree t,
These do not need to be marked for PCH or GC. */

/* FIXME remember and print actual constant arguments. */
static vec<tree> call_stack = vec<tree>();
static vec<tree> call_stack = vNULL;
static int call_stack_tick;
static int last_cx_error_tick;

Expand All @@ -6536,7 +6536,7 @@ pop_cx_call_context (void)
vec<tree>
cx_error_context (void)
{
vec<tree> r = vec<tree>();
vec<tree> r = vNULL;
if (call_stack_tick != last_cx_error_tick
&& !call_stack.is_empty ())
r = call_stack;
Expand Down
2 changes: 1 addition & 1 deletion gcc/df-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
bitmap worklist = BITMAP_ALLOC (&df_bitmap_obstack);
int age = 0;
bool changed;
vec<int> last_visit_age = vec<int>();
vec<int> last_visit_age = vNULL;
int prev_age;
basic_block bb;
int i;
Expand Down
8 changes: 4 additions & 4 deletions gcc/dominance.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,12 @@ get_dominated_by (enum cdi_direction dir, basic_block bb)
{
unsigned int dir_index = dom_convert_dir_to_idx (dir);
struct et_node *node = bb->dom[dir_index], *son = node->son, *ason;
vec<basic_block> bbs = vec<basic_block>();
vec<basic_block> bbs = vNULL;

gcc_checking_assert (dom_computed[dir_index]);

if (!son)
return vec<basic_block>();
return vNULL;

bbs.safe_push ((basic_block) son->data);
for (ason = son->right; ason != son; ason = ason->right)
Expand All @@ -769,7 +769,7 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region,
{
unsigned i;
basic_block dom;
vec<basic_block> doms = vec<basic_block>();
vec<basic_block> doms = vNULL;

for (i = 0; i < n_region; i++)
region[i]->flags |= BB_DUPLICATED;
Expand All @@ -793,7 +793,7 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region,
vec<basic_block>
get_dominated_to_depth (enum cdi_direction dir, basic_block bb, int depth)
{
vec<basic_block> bbs = vec<basic_block>();
vec<basic_block> bbs = vNULL;
unsigned i;
unsigned next_level_start;

Expand Down
2 changes: 1 addition & 1 deletion gcc/dwarf2out.c
Original file line number Diff line number Diff line change
Expand Up @@ -18740,7 +18740,7 @@ static char *
gen_producer_string (void)
{
size_t j;
vec<dchar_p> switches = vec<dchar_p>();
vec<dchar_p> switches = vNULL;
const char *language_string = lang_hooks.name;
char *producer, *tail;
const char *p;
Expand Down
2 changes: 1 addition & 1 deletion gcc/except.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ sjlj_emit_dispatch_table (rtx dispatch_label, int num_dispatch)
eh_region r;
edge e;
int i, disp_index;
vec<tree> dispatch_labels = vec<tree>();
vec<tree> dispatch_labels = vNULL;

fc = crtl->eh.sjlj_fc;

Expand Down
6 changes: 6 additions & 0 deletions gcc/fortran/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2012-11-20 Diego Novillo <[email protected]>
Jakub Jelinek <[email protected]>

* trans-openmp.c: Replace all vec<T, A>() initializers
with vNULL.

2012-11-17 Diego Novillo <[email protected]>

Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec)
Expand Down
2 changes: 1 addition & 1 deletion gcc/fortran/trans-openmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
stmtblock_t body;
gfc_omp_clauses *clauses = code->ext.omp_clauses;
int i, collapse = clauses->collapse;
vec<dovar_init> inits = vec<dovar_init>();
vec<dovar_init> inits = vNULL;
dovar_init *di;
unsigned ix;

Expand Down
6 changes: 3 additions & 3 deletions gcc/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,7 @@ assign_parms_augmented_arg_list (struct assign_parm_data_all *all)
{
tree fndecl = current_function_decl;
tree fntype = TREE_TYPE (fndecl);
vec<tree> fnargs = vec<tree>();
vec<tree> fnargs = vNULL;
tree arg;

for (arg = DECL_ARGUMENTS (fndecl); arg; arg = DECL_CHAIN (arg))
Expand Down Expand Up @@ -5874,7 +5874,7 @@ thread_prologue_and_epilogue_insns (void)
{
bool inserted;
#ifdef HAVE_simple_return
vec<edge> unconverted_simple_returns = vec<edge>();
vec<edge> unconverted_simple_returns = vNULL;
bool nonempty_prologue;
bitmap_head bb_flags;
unsigned max_grow_size;
Expand Down Expand Up @@ -6374,7 +6374,7 @@ thread_prologue_and_epilogue_insns (void)

if (LABEL_P (BB_HEAD (last_bb))
&& !active_insn_between (BB_HEAD (last_bb), BB_END (last_bb)))
convert_jumps_to_returns (last_bb, false, vec<edge>());
convert_jumps_to_returns (last_bb, false, vNULL);

if (EDGE_COUNT (last_bb->preds) != 0
&& single_succ_p (last_bb))
Expand Down
2 changes: 1 addition & 1 deletion gcc/gcse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3193,7 +3193,7 @@ hoist_code (void)
/* Number of occurrences of EXPR that can be hoisted to BB. */
int hoistable = 0;
/* Occurrences reachable from BB. */
vec<occr_t> occrs_to_hoist = vec<occr_t>();
vec<occr_t> occrs_to_hoist = vNULL;
/* We want to insert the expression into BB only once, so
note when we've inserted it. */
int insn_inserted_p;
Expand Down
Loading

0 comments on commit 6e1aa84

Please sign in to comment.