public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
@ 2016-06-29 12:19 ` tbsaunde+gcc
  2016-06-29 13:48   ` David Malcolm
  2016-06-29 12:19 ` [PATCH 1/9] tree.c: add [cd]tors to free_lang_data_d tbsaunde+gcc
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/c/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* c-decl.c (struct c_struct_parse_info): Add constructor and
	change member types from vec to auto_vec.
	(start_struct): Adjust.
	(finish_struct): Likewise.
---
 gcc/c/c-decl.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 8b966fe..c173796 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -574,15 +574,15 @@ struct c_struct_parse_info
 {
   /* If warn_cxx_compat, a list of types defined within this
      struct.  */
-  vec<tree> struct_types;
+  auto_vec<tree> struct_types;
   /* If warn_cxx_compat, a list of field names which have bindings,
      and which are defined in this struct, but which are not defined
      in any enclosing struct.  This is used to clear the in_struct
      field of the c_bindings structure.  */
-  vec<c_binding_ptr> fields;
+  auto_vec<c_binding_ptr> fields;
   /* If warn_cxx_compat, a list of typedef names used when defining
      fields in this struct.  */
-  vec<tree> typedefs_seen;
+  auto_vec<tree> typedefs_seen;
 };
 
 /* Information for the struct or union currently being parsed, or
@@ -7443,10 +7443,7 @@ start_struct (location_t loc, enum tree_code code, tree name,
     TYPE_PACKED (v) = flag_pack_struct;
 
   *enclosing_struct_parse_info = struct_parse_info;
-  struct_parse_info = XNEW (struct c_struct_parse_info);
-  struct_parse_info->struct_types.create (0);
-  struct_parse_info->fields.create (0);
-  struct_parse_info->typedefs_seen.create (0);
+  struct_parse_info = new c_struct_parse_info ();
 
   /* FIXME: This will issue a warning for a use of a type defined
      within a statement expr used within sizeof, et. al.  This is not
@@ -8088,10 +8085,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
   if (warn_cxx_compat)
     warn_cxx_compat_finish_struct (fieldlist, TREE_CODE (t), loc);
 
-  struct_parse_info->struct_types.release ();
-  struct_parse_info->fields.release ();
-  struct_parse_info->typedefs_seen.release ();
-  XDELETE (struct_parse_info);
+  delete struct_parse_info;
 
   struct_parse_info = enclosing_struct_parse_info;
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 8/9] use auto_vec for more local variables
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (2 preceding siblings ...)
  2016-06-29 12:19 ` [PATCH 7/9] tree-ssa-sccvn.c: use auto_vec for sccvn_dom_walker::cond_stack tbsaunde+gcc
@ 2016-06-29 12:19 ` tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 5/9] cfgexpand.c: use auto_vec in stack_vars_data tbsaunde+gcc
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/c/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* c-parser.c (c_parser_generic_selection): Make type of variable
	auto_vec.
	(c_parser_omp_declare_simd): Likewise.

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* cfgexpand.c (expand_used_vars): Make the type of a local variable auto_vec.
	* genmatch.c (lower_for): Likewise.
	* haifa-sched.c (haifa_sched_init): Likewise.
	(add_to_speculative_block): Likewise.
	(create_check_block_twin): Likewise.
	* predict.c (handle_missing_profiles): Likewise.
	* tree-data-ref.c (loop_nest_has_data_refs): Likewise.
	* tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Likewise.
	* tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk): Likewise.
	(maybe_lower_iteration_bound): Likewise.
	* tree-ssa-sccvn.c (DFS): Likewise.
	* tree-stdarg.c (reachable_at_most_once): Likewise.
	* tree-vect-stmts.c (vectorizable_conversion): Likewise.
	(vectorizable_store): Likewise.
---
 gcc/c/c-parser.c          | 22 ++++++----------------
 gcc/cfgexpand.c           |  3 +--
 gcc/genmatch.c            | 12 ++++--------
 gcc/haifa-sched.c         | 15 ++++-----------
 gcc/predict.c             |  4 +---
 gcc/tree-data-ref.c       |  5 +----
 gcc/tree-diagnostic.c     |  4 +---
 gcc/tree-ssa-loop-niter.c |  6 ++----
 gcc/tree-ssa-sccvn.c      | 16 ++++------------
 gcc/tree-stdarg.c         |  3 +--
 gcc/tree-vect-stmts.c     |  8 ++------
 11 files changed, 27 insertions(+), 71 deletions(-)

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 7f491f1..18dc618 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -7243,7 +7243,6 @@ struct c_generic_association
 static struct c_expr
 c_parser_generic_selection (c_parser *parser)
 {
-  vec<c_generic_association> associations = vNULL;
   struct c_expr selector, error_expr;
   tree selector_type;
   struct c_generic_association matched_assoc;
@@ -7300,6 +7299,7 @@ c_parser_generic_selection (c_parser *parser)
       return error_expr;
     }
 
+  auto_vec<c_generic_association> associations;
   while (1)
     {
       struct c_generic_association assoc, *iter;
@@ -7320,13 +7320,13 @@ c_parser_generic_selection (c_parser *parser)
 	  if (type_name == NULL)
 	    {
 	      c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
-	      goto error_exit;
+	      return error_expr;
 	    }
 	  assoc.type = groktypename (type_name, NULL, NULL);
 	  if (assoc.type == error_mark_node)
 	    {
 	      c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
-	      goto error_exit;
+	      return error_expr;
 	    }
 
 	  if (TREE_CODE (assoc.type) == FUNCTION_TYPE)
@@ -7345,14 +7345,14 @@ c_parser_generic_selection (c_parser *parser)
       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
 	{
 	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
-	  goto error_exit;
+	  return error_expr;
 	}
 
       assoc.expression = c_parser_expr_no_commas (parser, NULL);
       if (assoc.expression.value == error_mark_node)
 	{
 	  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
-	  goto error_exit;
+	  return error_expr;
 	}
 
       for (ix = 0; associations.iterate (ix, &iter); ++ix)
@@ -7408,8 +7408,6 @@ c_parser_generic_selection (c_parser *parser)
       c_parser_consume_token (parser);
     }
 
-  associations.release ();
-
   if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
     {
       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
@@ -7425,10 +7423,6 @@ c_parser_generic_selection (c_parser *parser)
     }
 
   return matched_assoc.expression;
-
- error_exit:
-  associations.release ();
-  return error_expr;
 }
 
 /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2).
@@ -16362,14 +16356,13 @@ check_clauses:
 static void
 c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context)
 {
-  vec<c_token> clauses = vNULL;
+  auto_vec<c_token> clauses;
   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
     {
       c_token *token = c_parser_peek_token (parser);
       if (token->type == CPP_EOF)
 	{
 	  c_parser_skip_to_pragma_eol (parser);
-	  clauses.release ();
 	  return;
 	}
       clauses.safe_push (*token);
@@ -16391,7 +16384,6 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context)
 			  "%<#pragma omp declare simd%> must be followed by "
 			  "function declaration or definition or another "
 			  "%<#pragma omp declare simd%>");
-	  clauses.release ();
 	  return;
 	}
       c_parser_consume_pragma (parser);
@@ -16401,7 +16393,6 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context)
 	  if (token->type == CPP_EOF)
 	    {
 	      c_parser_skip_to_pragma_eol (parser);
-	      clauses.release ();
 	      return;
 	    }
 	  clauses.safe_push (*token);
@@ -16473,7 +16464,6 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context)
     default:
       gcc_unreachable ();
     }
-  clauses.release ();
 }
 
 /* Finalize #pragma omp declare simd clauses after FNDECL has been parsed,
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 9750586..f270e76 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2012,7 +2012,7 @@ static rtx_insn *
 expand_used_vars (void)
 {
   tree var, outer_block = DECL_INITIAL (current_function_decl);
-  vec<tree> maybe_local_decls = vNULL;
+  auto_vec<tree> maybe_local_decls;
   rtx_insn *var_end_seq = NULL;
   unsigned i;
   unsigned len;
@@ -2253,7 +2253,6 @@ expand_used_vars (void)
       if (rtl && (MEM_P (rtl) || GET_CODE (rtl) == CONCAT))
 	add_local_decl (cfun, var);
     }
-  maybe_local_decls.release ();
 
   /* If the target requires that FRAME_OFFSET be aligned, do it.  */
   if (STACK_ALIGNMENT_NEEDED)
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index f5aa29b..02e945a 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -1416,8 +1416,7 @@ lower_for (simplify *sin, vec<simplify *>& simplifiers)
 	    {
 	      operand *match_op = s->match;
 	      operand *result_op = s->result;
-	      vec<std::pair<user_id *, id_base *> > subst;
-	      subst.create (n_ids);
+	      auto_vec<std::pair<user_id *, id_base *> > subst (n_ids);
 	      bool skip = false;
 	      for (unsigned i = 0; i < n_ids; ++i)
 		{
@@ -1437,18 +1436,15 @@ lower_for (simplify *sin, vec<simplify *>& simplifiers)
 		    result_op = replace_id (result_op, id, oper);
 		}
 	      if (skip)
-		{
-		  subst.release ();
-		  continue;
-		}
+		continue;
+
 	      simplify *ns = new simplify (s->kind, match_op, result_op,
 					   vNULL, s->capture_ids);
 	      ns->for_subst_vec.safe_splice (s->for_subst_vec);
 	      if (result_op
 		  && can_delay_subst)
 		ns->for_subst_vec.safe_splice (subst);
-	      else
-		subst.release ();
+
 	      worklist.safe_push (ns);
 	    }
 	}
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 1f1e763..9503576 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -7416,20 +7416,16 @@ haifa_sched_init (void)
   /* Initialize luids, dependency caches, target and h_i_d for the
      whole function.  */
   {
-    bb_vec_t bbs;
-    bbs.create (n_basic_blocks_for_fn (cfun));
-    basic_block bb;
-
     sched_init_bbs ();
 
+    auto_vec<basic_block> bbs (n_basic_blocks_for_fn (cfun));
+    basic_block bb;
     FOR_EACH_BB_FN (bb, cfun)
       bbs.quick_push (bb);
     sched_init_luids (bbs);
     sched_deps_init (true);
     sched_extend_target ();
     haifa_init_h_i_d (bbs);
-
-    bbs.release ();
   }
 
   sched_init_only_bb = haifa_init_only_bb;
@@ -7996,7 +7992,6 @@ add_to_speculative_block (rtx_insn *insn)
   sd_iterator_def sd_it;
   dep_t dep;
   rtx_insn_list *twins = NULL;
-  rtx_vec_t priorities_roots;
 
   ts = TODO_SPEC (insn);
   gcc_assert (!(ts & ~BE_IN_SPEC));
@@ -8029,7 +8024,7 @@ add_to_speculative_block (rtx_insn *insn)
 	sd_iterator_next (&sd_it);
     }
 
-  priorities_roots.create (0);
+  auto_vec<rtx_insn *> priorities_roots;
   clear_priorities (insn, &priorities_roots);
 
   while (1)
@@ -8124,7 +8119,6 @@ add_to_speculative_block (rtx_insn *insn)
     }
 
   calc_priorities (priorities_roots);
-  priorities_roots.release ();
 }
 
 /* Extends and fills with zeros (only the new part) array pointed to by P.  */
@@ -8620,11 +8614,10 @@ create_check_block_twin (rtx_insn *insn, bool mutate_p)
     /* Fix priorities.  If MUTATE_P is nonzero, this is not necessary,
        because it'll be done later in add_to_speculative_block.  */
     {
-      rtx_vec_t priorities_roots = rtx_vec_t ();
+      auto_vec<rtx_insn *> priorities_roots;
 
       clear_priorities (twin, &priorities_roots);
       calc_priorities (priorities_roots);
-      priorities_roots.release ();
     }
 }
 
diff --git a/gcc/predict.c b/gcc/predict.c
index d505d9c..32de2d9 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -2966,8 +2966,7 @@ handle_missing_profiles (void)
 {
   struct cgraph_node *node;
   int unlikely_count_fraction = PARAM_VALUE (UNLIKELY_BB_COUNT_FRACTION);
-  vec<struct cgraph_node *> worklist;
-  worklist.create (64);
+  auto_vec<struct cgraph_node *, 64> worklist;
 
   /* See if 0 count function has non-0 count callers.  In this case we
      lost some profile.  Drop its function profile to PROFILE_GUESSED.  */
@@ -3024,7 +3023,6 @@ handle_missing_profiles (void)
             }
         }
     }
-  worklist.release ();
 }
 
 /* Convert counts measured by profile driven feedback to frequencies.
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index ed28ca1..1a7a2ea 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -3942,8 +3942,7 @@ bool
 loop_nest_has_data_refs (loop_p loop)
 {
   basic_block *bbs = get_loop_body (loop);
-  vec<data_ref_loc> references;
-  references.create (3);
+  auto_vec<data_ref_loc, 3> references;
 
   for (unsigned i = 0; i < loop->num_nodes; i++)
     {
@@ -3957,13 +3956,11 @@ loop_nest_has_data_refs (loop_p loop)
 	  if (references.length ())
 	    {
 	      free (bbs);
-	      references.release ();
 	      return true;
 	    }
 	}
     }
   free (bbs);
-  references.release ();
 
   if (loop->inner)
     {
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index 5377ec2..234d0fd 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -102,7 +102,7 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context,
                                  source_location where)
 {
   const struct line_map *map;
-  vec<loc_map_pair> loc_vec = vNULL;
+  auto_vec<loc_map_pair> loc_vec;
   unsigned ix;
   loc_map_pair loc, *iter;
 
@@ -219,8 +219,6 @@ maybe_unwind_expanded_macro_loc (diagnostic_context *context,
                                 "in expansion of macro %qs",
                                 linemap_map_get_macro_name (iter->map));
       }
-
-  loc_vec.release ();
 }
 
 /*  This is a diagnostic finalizer implementation that is aware of
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 32fe2f9..7d52dd9 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3438,7 +3438,7 @@ static void
 discover_iteration_bound_by_body_walk (struct loop *loop)
 {
   struct nb_iter_bound *elt;
-  vec<widest_int> bounds = vNULL;
+  auto_vec<widest_int> bounds;
   vec<vec<basic_block> > queues = vNULL;
   vec<basic_block> queue = vNULL;
   ptrdiff_t queue_index;
@@ -3593,7 +3593,6 @@ discover_iteration_bound_by_body_walk (struct loop *loop)
     }
 
   queues.release ();
-  bounds.release ();
 }
 
 /* See if every path cross the loop goes through a statement that is known
@@ -3606,7 +3605,7 @@ maybe_lower_iteration_bound (struct loop *loop)
   hash_set<gimple *> *not_executed_last_iteration = NULL;
   struct nb_iter_bound *elt;
   bool found_exit = false;
-  vec<basic_block> queue = vNULL;
+  auto_vec<basic_block> queue;
   bitmap visited;
 
   /* Collect all statements with interesting (i.e. lower than
@@ -3698,7 +3697,6 @@ maybe_lower_iteration_bound (struct loop *loop)
     }
 
   BITMAP_FREE (visited);
-  queue.release ();
   delete not_executed_last_iteration;
 }
 
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 95306c5..184e062 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4109,8 +4109,8 @@ extract_and_process_scc_for_name (tree name)
 static bool
 DFS (tree name)
 {
-  vec<ssa_op_iter> itervec = vNULL;
-  vec<tree> namevec = vNULL;
+  auto_vec<ssa_op_iter> itervec;
+  auto_vec<tree> namevec;
   use_operand_p usep = NULL;
   gimple *defstmt;
   tree use;
@@ -4147,19 +4147,11 @@ start_over:
 	  /* See if we found an SCC.  */
 	  if (VN_INFO (name)->low == VN_INFO (name)->dfsnum)
 	    if (!extract_and_process_scc_for_name (name))
-	      {
-		namevec.release ();
-		itervec.release ();
-		return false;
-	      }
+	      return false;
 
 	  /* Check if we are done.  */
 	  if (namevec.is_empty ())
-	    {
-	      namevec.release ();
-	      itervec.release ();
-	      return true;
-	    }
+	    return true;
 
 	  /* Restore the last use walker and continue walking there.  */
 	  use = name;
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index 13b92f0..81a380e 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -53,7 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 static bool
 reachable_at_most_once (basic_block va_arg_bb, basic_block va_start_bb)
 {
-  vec<edge> stack = vNULL;
+  auto_vec<edge, 10> stack;
   edge e;
   edge_iterator ei;
   sbitmap visited;
@@ -105,7 +105,6 @@ reachable_at_most_once (basic_block va_arg_bb, basic_block va_start_bb)
 	}
     }
 
-  stack.release ();
   sbitmap_free (visited);
   return ret;
 }
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 5c65502..3281860 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -3633,7 +3633,6 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
   vec_info *vinfo = stmt_info->vinfo;
   int multi_step_cvt = 0;
-  vec<tree> vec_dsts = vNULL;
   vec<tree> interm_types = vNULL;
   tree last_oprnd, intermediate_type, cvt_type = NULL_TREE;
   int op_type;
@@ -3932,7 +3931,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
      We create vector destinations for the intermediate type (TYPES) received
      from supportable_*_operation, and store them in the correct order
      for future use in vect_create_vectorized_*_stmts ().  */
-  vec_dsts.create (multi_step_cvt + 1);
+  auto_vec<tree> vec_dsts (multi_step_cvt + 1);
   vec_dest = vect_create_destination_var (scalar_dest,
 					  (cvt_type && modifier == WIDEN)
 					  ? cvt_type : vectype_out);
@@ -4183,7 +4182,6 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
 
   vec_oprnds0.release ();
   vec_oprnds1.release ();
-  vec_dsts.release ();
   interm_types.release ();
 
   return true;
@@ -5216,7 +5214,6 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   bool grouped_store = false;
   bool store_lanes_p = false;
   unsigned int group_size, i;
-  vec<tree> dr_chain = vNULL;
   vec<tree> oprnds = vNULL;
   vec<tree> result_chain = vNULL;
   bool inv_p;
@@ -5792,7 +5789,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       return true;
     }
 
-  dr_chain.create (group_size);
+  auto_vec<tree> dr_chain (group_size);
   oprnds.create (group_size);
 
   alignment_support_scheme = vect_supportable_dr_alignment (first_dr, false);
@@ -6067,7 +6064,6 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
 	}
     }
 
-  dr_chain.release ();
   oprnds.release ();
   result_chain.release ();
   vec_oprnds.release ();
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/9] tree.c: add [cd]tors to free_lang_data_d
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info tbsaunde+gcc
@ 2016-06-29 12:19 ` tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 7/9] tree-ssa-sccvn.c: use auto_vec for sccvn_dom_walker::cond_stack tbsaunde+gcc
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* tree.c (struct free_lang_data_d): Add constructor and change
	types of members to ones that automatically manage resources.
	(fld_worklist_push): Adjust.
	(find_decls_types): Likewise.
	(find_decls_types_in_eh_region): Likewise.
	(free_lang_data_in_cgraph): Stop manually creating and
	destroying members of free_lang_data_d.
---
 gcc/tree.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/gcc/tree.c b/gcc/tree.c
index bc60190..617f326 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5500,17 +5500,19 @@ free_lang_data_in_decl (tree decl)
 
 struct free_lang_data_d
 {
+  free_lang_data_d () : decls (100), types (100) {}
+
   /* Worklist to avoid excessive recursion.  */
-  vec<tree> worklist;
+  auto_vec<tree> worklist;
 
   /* Set of traversed objects.  Used to avoid duplicate visits.  */
-  hash_set<tree> *pset;
+  hash_set<tree> pset;
 
   /* Array of symbols to process with free_lang_data_in_decl.  */
-  vec<tree> decls;
+  auto_vec<tree> decls;
 
   /* Array of types to process with free_lang_data_in_type.  */
-  vec<tree> types;
+  auto_vec<tree> types;
 };
 
 
@@ -5569,7 +5571,7 @@ add_tree_to_fld_list (tree t, struct free_lang_data_d *fld)
 static inline void
 fld_worklist_push (tree t, struct free_lang_data_d *fld)
 {
-  if (t && !is_lang_specific (t) && !fld->pset->contains (t))
+  if (t && !is_lang_specific (t) && !fld->pset.contains (t))
     fld->worklist.safe_push ((t));
 }
 
@@ -5738,8 +5740,8 @@ find_decls_types (tree t, struct free_lang_data_d *fld)
 {
   while (1)
     {
-      if (!fld->pset->contains (t))
-	walk_tree (&t, find_decls_types_r, fld, fld->pset);
+      if (!fld->pset.contains (t))
+	walk_tree (&t, find_decls_types_r, fld, &fld->pset);
       if (fld->worklist.is_empty ())
 	break;
       t = fld->worklist.pop ();
@@ -5793,7 +5795,7 @@ find_decls_types_in_eh_region (eh_region r, struct free_lang_data_d *fld)
 	for (c = r->u.eh_try.first_catch; c ; c = c->next_catch)
 	  {
 	    c->type_list = get_eh_types_for_runtime (c->type_list);
-	    walk_tree (&c->type_list, find_decls_types_r, fld, fld->pset);
+	    walk_tree (&c->type_list, find_decls_types_r, fld, &fld->pset);
 	  }
       }
       break;
@@ -5801,12 +5803,12 @@ find_decls_types_in_eh_region (eh_region r, struct free_lang_data_d *fld)
     case ERT_ALLOWED_EXCEPTIONS:
       r->u.allowed.type_list
 	= get_eh_types_for_runtime (r->u.allowed.type_list);
-      walk_tree (&r->u.allowed.type_list, find_decls_types_r, fld, fld->pset);
+      walk_tree (&r->u.allowed.type_list, find_decls_types_r, fld, &fld->pset);
       break;
 
     case ERT_MUST_NOT_THROW:
       walk_tree (&r->u.must_not_throw.failure_decl,
-		 find_decls_types_r, fld, fld->pset);
+		 find_decls_types_r, fld, &fld->pset);
       break;
     }
 }
@@ -5948,12 +5950,6 @@ free_lang_data_in_cgraph (void)
   unsigned i;
   alias_pair *p;
 
-  /* Initialize sets and arrays to store referenced decls and types.  */
-  fld.pset = new hash_set<tree>;
-  fld.worklist.create (0);
-  fld.decls.create (100);
-  fld.types.create (100);
-
   /* Find decls and types in the body of every function in the callgraph.  */
   FOR_EACH_FUNCTION (n)
     find_decls_types_in_node (n, &fld);
@@ -5983,11 +5979,6 @@ free_lang_data_in_cgraph (void)
       FOR_EACH_VEC_ELT (fld.types, i, t)
 	verify_type (t);
     }
-
-  delete fld.pset;
-  fld.worklist.release ();
-  fld.decls.release ();
-  fld.types.release ();
 }
 
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/9] genextract.c: add [cd]tors to accum_extract
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (4 preceding siblings ...)
  2016-06-29 12:19 ` [PATCH 5/9] cfgexpand.c: use auto_vec in stack_vars_data tbsaunde+gcc
@ 2016-06-29 12:19 ` tbsaunde+gcc
  2016-06-29 12:38 ` [PATCH 4/9] ipa.c: remove static_{ctors,dtors} globals tbsaunde+gcc
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* genextract.c (struct accum_extract): Add constructor and make
	members auto_vec.
	(gen_insn): Adjust.
---
 gcc/genextract.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/gcc/genextract.c b/gcc/genextract.c
index d591781..e6d5337 100644
--- a/gcc/genextract.c
+++ b/gcc/genextract.c
@@ -69,10 +69,12 @@ static struct code_ptr *peepholes;
 
 struct accum_extract
 {
-  vec<locstr> oplocs;
-  vec<locstr> duplocs;
-  vec<int> dupnums;
-  vec<char> pathstr;
+  accum_extract () : oplocs (10), duplocs (10), dupnums (10), pathstr (20) {}
+
+  auto_vec<locstr> oplocs;
+  auto_vec<locstr> duplocs;
+  auto_vec<int> dupnums;
+  auto_vec<char> pathstr;
 };
 
 /* Forward declarations.  */
@@ -87,11 +89,6 @@ gen_insn (md_rtx_info *info)
   struct code_ptr *link;
   struct accum_extract acc;
 
-  acc.oplocs.create (10);
-  acc.duplocs.create (10);
-  acc.dupnums.create (10);
-  acc.pathstr.create (20);
-
   /* Walk the insn's pattern, remembering at all times the path
      down to the walking point.  */
 
@@ -142,7 +139,7 @@ gen_insn (md_rtx_info *info)
       /* This extraction is the same as ours.  Just link us in.  */
       link->next = p->insns;
       p->insns = link;
-      goto done;
+      return;
     }
 
   /* Otherwise, make a new extraction method.  We stash the arrays
@@ -166,12 +163,6 @@ gen_insn (md_rtx_info *info)
   memcpy (p->oplocs, acc.oplocs.address (), op_count * sizeof (locstr));
   memcpy (p->duplocs, acc.duplocs.address (), dup_count * sizeof (locstr));
   memcpy (p->dupnums, acc.dupnums.address (), dup_count * sizeof (int));
-
- done:
-  acc.oplocs.release ();
-  acc.duplocs.release ();
-  acc.dupnums.release ();
-  acc.pathstr.release ();
 }
 \f
 /* Helper subroutine of walk_rtx: given a vec<locstr>, an index, and a
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 0/9] remove some manual memory management
@ 2016-06-29 12:19 tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info tbsaunde+gcc
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Hi,

This is just a bunch of adding constructors and destructors and switching to
use auto_vec more.

patches individually bootstrapped and regtested on x86_64-linux-gnu, ok?

Trev

Trevor Saunders (9):
  tree.c: add [cd]tors to free_lang_data_d
  c-decl.c: add [cd]tors to c_struct_parse_info
  genextract.c: add [cd]tors to accum_extract
  ipa.c: remove static_{ctors,dtors} globals
  cfgexpand.c: use auto_vec in stack_vars_data
  ree.c: use auto_vec in ext_state
  tree-ssa-sccvn.c: use auto_vec for sccvn_dom_walker::cond_stack
  use auto_vec for more local variables
  remove unnecessary calls to vec::release

 gcc/c/c-decl.c            | 16 +++++-----------
 gcc/c/c-parser.c          | 22 ++++++----------------
 gcc/cfgexpand.c           | 12 +++---------
 gcc/genextract.c          | 23 +++++++----------------
 gcc/genmatch.c            | 12 ++++--------
 gcc/haifa-sched.c         | 15 ++++-----------
 gcc/ipa.c                 | 37 +++++++++++++++++--------------------
 gcc/predict.c             |  4 +---
 gcc/ree.c                 | 19 ++++++-------------
 gcc/tree-data-ref.c       |  8 ++------
 gcc/tree-diagnostic.c     |  4 +---
 gcc/tree-ssa-alias.c      | 21 +++++++--------------
 gcc/tree-ssa-loop-niter.c |  6 ++----
 gcc/tree-ssa-sccvn.c      | 26 ++++++--------------------
 gcc/tree-stdarg.c         |  3 +--
 gcc/tree-vect-stmts.c     | 11 ++---------
 gcc/tree.c                | 33 ++++++++++++---------------------
 17 files changed, 86 insertions(+), 186 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/9] tree-ssa-sccvn.c: use auto_vec for sccvn_dom_walker::cond_stack
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 1/9] tree.c: add [cd]tors to free_lang_data_d tbsaunde+gcc
@ 2016-06-29 12:19 ` tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 8/9] use auto_vec for more local variables tbsaunde+gcc
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* tree-ssa-sccvn.c (sccvn_dom_walker::~sccvn_dom_walker): remove.
(sccvn_dom_walker): make cond_stack an auto_vec.
---
 gcc/tree-ssa-sccvn.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 0cbd2cd..95306c5 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4444,8 +4444,7 @@ class sccvn_dom_walker : public dom_walker
 {
 public:
   sccvn_dom_walker ()
-    : dom_walker (CDI_DOMINATORS, true), fail (false), cond_stack (vNULL) {}
-  ~sccvn_dom_walker ();
+    : dom_walker (CDI_DOMINATORS, true), fail (false), cond_stack (0) {}
 
   virtual edge before_dom_children (basic_block);
   virtual void after_dom_children (basic_block);
@@ -4456,15 +4455,10 @@ public:
 		     enum tree_code code, tree lhs, tree rhs, bool value);
 
   bool fail;
-  vec<std::pair <basic_block, std::pair <vn_nary_op_t, vn_nary_op_t> > >
+  auto_vec<std::pair <basic_block, std::pair <vn_nary_op_t, vn_nary_op_t> > >
     cond_stack;
 };
 
-sccvn_dom_walker::~sccvn_dom_walker ()
-{
-  cond_stack.release ();
-}
-
 /* Record a temporary condition for the BB and its dominated blocks.  */
 
 void
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/9] cfgexpand.c: use auto_vec in stack_vars_data
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (3 preceding siblings ...)
  2016-06-29 12:19 ` [PATCH 8/9] use auto_vec for more local variables tbsaunde+gcc
@ 2016-06-29 12:19 ` tbsaunde+gcc
  2016-06-29 12:19 ` [PATCH 3/9] genextract.c: add [cd]tors to accum_extract tbsaunde+gcc
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:19 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* cfgexpand.c (struct stack_vars_data): Make type of fields
	auto_vec.
	(expand_used_vars): Adjust.
---
 gcc/cfgexpand.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index e4ddb3a..9750586 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1030,10 +1030,10 @@ struct stack_vars_data
   /* Vector of offset pairs, always end of some padding followed
      by start of the padding that needs Address Sanitizer protection.
      The vector is in reversed, highest offset pairs come first.  */
-  vec<HOST_WIDE_INT> asan_vec;
+  auto_vec<HOST_WIDE_INT> asan_vec;
 
   /* Vector of partition representative decls in between the paddings.  */
-  vec<tree> asan_decl_vec;
+  auto_vec<tree> asan_decl_vec;
 
   /* Base pseudo register for Address Sanitizer protected automatic vars.  */
   rtx asan_base;
@@ -2179,8 +2179,6 @@ expand_used_vars (void)
     {
       struct stack_vars_data data;
 
-      data.asan_vec = vNULL;
-      data.asan_decl_vec = vNULL;
       data.asan_base = NULL_RTX;
       data.asan_alignb = 0;
 
@@ -2239,9 +2237,6 @@ expand_used_vars (void)
 	}
 
       expand_stack_vars (NULL, &data);
-
-      data.asan_vec.release ();
-      data.asan_decl_vec.release ();
     }
 
   fini_vars_expansion ();
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/9] ipa.c: remove static_{ctors,dtors} globals
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (5 preceding siblings ...)
  2016-06-29 12:19 ` [PATCH 3/9] genextract.c: add [cd]tors to accum_extract tbsaunde+gcc
@ 2016-06-29 12:38 ` tbsaunde+gcc
  2016-06-29 12:39 ` [PATCH 9/9] remove unnecessary calls to vec::release tbsaunde+gcc
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:38 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* ipa.c (record_cdtor_fn): Adjust.
	(build_cdtor_fns): Likewise.
	(ipa_cdtor_merge): Make static_ctors and static_dtors local
	variables.
---
 gcc/ipa.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/gcc/ipa.c b/gcc/ipa.c
index 6722d3b..2609e32 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -989,11 +989,6 @@ cgraph_build_static_cdtor (char which, tree body, int priority)
   cgraph_build_static_cdtor_1 (which, body, priority, false);
 }
 
-/* A vector of FUNCTION_DECLs declared as static constructors.  */
-static vec<tree> static_ctors;
-/* A vector of FUNCTION_DECLs declared as static destructors.  */
-static vec<tree> static_dtors;
-
 /* When target does not have ctors and dtors, we call all constructor
    and destructor by special initialization/destruction function
    recognized by collect2.
@@ -1002,12 +997,12 @@ static vec<tree> static_dtors;
    destructors and turn them into normal functions.  */
 
 static void
-record_cdtor_fn (struct cgraph_node *node)
+record_cdtor_fn (struct cgraph_node *node, vec<tree> *ctors, vec<tree> *dtors)
 {
   if (DECL_STATIC_CONSTRUCTOR (node->decl))
-    static_ctors.safe_push (node->decl);
+    ctors->safe_push (node->decl);
   if (DECL_STATIC_DESTRUCTOR (node->decl))
-    static_dtors.safe_push (node->decl);
+    dtors->safe_push (node->decl);
   node = cgraph_node::get (node->decl);
   DECL_DISREGARD_INLINE_LIMITS (node->decl) = 1;
 }
@@ -1018,7 +1013,7 @@ record_cdtor_fn (struct cgraph_node *node)
    they are destructors.  */
 
 static void
-build_cdtor (bool ctor_p, vec<tree> cdtors)
+build_cdtor (bool ctor_p, const vec<tree> &cdtors)
 {
   size_t i,j;
   size_t len = cdtors.length ();
@@ -1135,20 +1130,20 @@ compare_dtor (const void *p1, const void *p2)
    functions have magic names which are detected by collect2.  */
 
 static void
-build_cdtor_fns (void)
+build_cdtor_fns (vec<tree> *ctors, vec<tree> *dtors)
 {
-  if (!static_ctors.is_empty ())
+  if (!ctors->is_empty ())
     {
       gcc_assert (!targetm.have_ctors_dtors || in_lto_p);
-      static_ctors.qsort (compare_ctor);
-      build_cdtor (/*ctor_p=*/true, static_ctors);
+      ctors->qsort (compare_ctor);
+      build_cdtor (/*ctor_p=*/true, *ctors);
     }
 
-  if (!static_dtors.is_empty ())
+  if (!dtors->is_empty ())
     {
       gcc_assert (!targetm.have_ctors_dtors || in_lto_p);
-      static_dtors.qsort (compare_dtor);
-      build_cdtor (/*ctor_p=*/false, static_dtors);
+      dtors->qsort (compare_dtor);
+      build_cdtor (/*ctor_p=*/false, *dtors);
     }
 }
 
@@ -1161,14 +1156,16 @@ build_cdtor_fns (void)
 static unsigned int
 ipa_cdtor_merge (void)
 {
+  /* A vector of FUNCTION_DECLs declared as static constructors.  */
+  auto_vec<tree, 20> ctors;
+  /* A vector of FUNCTION_DECLs declared as static destructors.  */
+  auto_vec<tree, 20> dtors;
   struct cgraph_node *node;
   FOR_EACH_DEFINED_FUNCTION (node)
     if (DECL_STATIC_CONSTRUCTOR (node->decl)
 	|| DECL_STATIC_DESTRUCTOR (node->decl))
-       record_cdtor_fn (node);
-  build_cdtor_fns ();
-  static_ctors.release ();
-  static_dtors.release ();
+       record_cdtor_fn (node, &ctors, &dtors);
+  build_cdtor_fns (&ctors, &dtors);
   return 0;
 }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 9/9] remove unnecessary calls to vec::release
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (6 preceding siblings ...)
  2016-06-29 12:38 ` [PATCH 4/9] ipa.c: remove static_{ctors,dtors} globals tbsaunde+gcc
@ 2016-06-29 12:39 ` tbsaunde+gcc
  2016-06-29 13:00 ` [PATCH 6/9] ree.c: use auto_vec in ext_state tbsaunde+gcc
  2016-06-30 10:36 ` [PATCH 0/9] remove some manual memory management Bernd Schmidt
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 12:39 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

There's no point in calling release () on an auto_vec just before it goes
out of scope.

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* tree-data-ref.c (find_data_references_in_stmt): Remove
	unnecessary call to vec::release.
	(graphite_find_data_references_in_stmt): Likewise.
	* tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): Likewise.
	* tree-vect-stmts.c (vectorizable_condition): Likewise.
---
 gcc/tree-data-ref.c   |  3 +--
 gcc/tree-ssa-alias.c  | 21 +++++++--------------
 gcc/tree-vect-stmts.c |  3 ---
 3 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 1a7a2ea..acdaa2f 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -3999,7 +3999,7 @@ find_data_references_in_stmt (struct loop *nest, gimple *stmt,
       gcc_assert (dr != NULL);
       datarefs->safe_push (dr);
     }
-  references.release ();
+
   return ret;
 }
 
@@ -4029,7 +4029,6 @@ graphite_find_data_references_in_stmt (loop_p nest, loop_p loop, gimple *stmt,
       datarefs->safe_push (dr);
     }
 
-  references.release ();
   return ret;
 }
 
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index b663ddf..0ffa8c2 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -865,7 +865,7 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
   if (TREE_CODE (ref1) == MEM_REF)
     {
       if (!integer_zerop (TREE_OPERAND (ref1, 1)))
-	goto may_overlap;
+	return false;
       ref1 = TREE_OPERAND (TREE_OPERAND (ref1, 0), 0);
     }
 
@@ -878,7 +878,7 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
   if (TREE_CODE (ref2) == MEM_REF)
     {
       if (!integer_zerop (TREE_OPERAND (ref2, 1)))
-	goto may_overlap;
+	return false;
       ref2 = TREE_OPERAND (TREE_OPERAND (ref2, 0), 0);
     }
 
@@ -898,7 +898,7 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
       do
 	{
 	  if (component_refs1.is_empty ())
-	    goto may_overlap;
+	    return false;
 	  ref1 = component_refs1.pop ();
 	}
       while (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (ref1, 0))));
@@ -906,7 +906,7 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
       do
 	{
 	  if (component_refs2.is_empty ())
-	     goto may_overlap;
+	     return false;
 	  ref2 = component_refs2.pop ();
 	}
       while (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (ref2, 0))));
@@ -914,7 +914,7 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
       /* Beware of BIT_FIELD_REF.  */
       if (TREE_CODE (ref1) != COMPONENT_REF
 	  || TREE_CODE (ref2) != COMPONENT_REF)
-	goto may_overlap;
+	return false;
 
       tree field1 = TREE_OPERAND (ref1, 1);
       tree field2 = TREE_OPERAND (ref2, 1);
@@ -927,21 +927,14 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
 
       /* We cannot disambiguate fields in a union or qualified union.  */
       if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE)
-	 goto may_overlap;
+	 return false;
 
       /* Different fields of the same record type cannot overlap.
 	 ??? Bitfields can overlap at RTL level so punt on them.  */
       if (field1 != field2)
-	{
-	  component_refs1.release ();
-	  component_refs2.release ();
-	  return !(DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2));
-	}
+	return !(DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2));
     }
 
-may_overlap:
-  component_refs1.release ();
-  component_refs2.release ();
   return false;
 }
 
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 3281860..0238504 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -7614,9 +7614,6 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
 	      if (!masked)
 		vec_oprnds1 = vec_defs.pop ();
 	      vec_oprnds0 = vec_defs.pop ();
-
-              ops.release ();
-              vec_defs.release ();
             }
           else
             {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/9] ree.c: use auto_vec in ext_state
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (7 preceding siblings ...)
  2016-06-29 12:39 ` [PATCH 9/9] remove unnecessary calls to vec::release tbsaunde+gcc
@ 2016-06-29 13:00 ` tbsaunde+gcc
  2016-06-30 10:36 ` [PATCH 0/9] remove some manual memory management Bernd Schmidt
  9 siblings, 0 replies; 15+ messages in thread
From: tbsaunde+gcc @ 2016-06-29 13:00 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* ree.c (struct ext_state): Make type of members auto_vec.
	(find_and_remove_re): Adjust.
---
 gcc/ree.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/gcc/ree.c b/gcc/ree.c
index 4627b4f..3245ac5 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -544,10 +544,10 @@ struct ext_state
   /* In order to avoid constant alloc/free, we keep these
      4 vectors live through the entire find_and_remove_re and just
      truncate them each time.  */
-  vec<rtx_insn *> defs_list;
-  vec<rtx_insn *> copies_list;
-  vec<rtx_insn *> modified_list;
-  vec<rtx_insn *> work_list;
+  auto_vec<rtx_insn *> defs_list;
+  auto_vec<rtx_insn *> copies_list;
+  auto_vec<rtx_insn *> modified_list;
+  auto_vec<rtx_insn *> work_list;
 
   /* For instructions that have been successfully modified, this is
      the original mode from which the insn is extending and
@@ -1147,7 +1147,6 @@ find_and_remove_re (void)
   vec<ext_cand> reinsn_list;
   auto_vec<rtx_insn *> reinsn_del_list;
   auto_vec<rtx_insn *> reinsn_copy_list;
-  ext_state state;
 
   /* Construct DU chain to get all reaching definitions of each
      extension instruction.  */
@@ -1159,10 +1158,8 @@ find_and_remove_re (void)
 
   max_insn_uid = get_max_uid ();
   reinsn_list = find_removable_extensions ();
-  state.defs_list.create (0);
-  state.copies_list.create (0);
-  state.modified_list.create (0);
-  state.work_list.create (0);
+
+  ext_state state;
   if (reinsn_list.is_empty ())
     state.modified = NULL;
   else
@@ -1238,10 +1235,6 @@ find_and_remove_re (void)
     delete_insn (curr_insn);
 
   reinsn_list.release ();
-  state.defs_list.release ();
-  state.copies_list.release ();
-  state.modified_list.release ();
-  state.work_list.release ();
   XDELETEVEC (state.modified);
 
   if (dump_file && num_re_opportunities > 0)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info
  2016-06-29 12:19 ` [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info tbsaunde+gcc
@ 2016-06-29 13:48   ` David Malcolm
  2016-06-29 14:35     ` Trevor Saunders
  0 siblings, 1 reply; 15+ messages in thread
From: David Malcolm @ 2016-06-29 13:48 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On Wed, 2016-06-29 at 08:26 -0400, tbsaunde+gcc@tbsaunde.org wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> 
> gcc/c/ChangeLog:

I may be missing my coffee here but you mention adding a constructor in
the ChangeLog here:

> 2016-06-29  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
> 
> 	* c-decl.c (struct c_struct_parse_info): Add constructor and
                                                 ^^^^^^^^^^^^^^^

> > 	change member types from vec to auto_vec.
> 	(start_struct): Adjust.
> 	(finish_struct): Likewise.
> ---
>  gcc/c/c-decl.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
> index 8b966fe..c173796 100644
> --- a/gcc/c/c-decl.c
> +++ b/gcc/c/c-decl.c
> @@ -574,15 +574,15 @@ struct c_struct_parse_info
>  {
>    /* If warn_cxx_compat, a list of types defined within this
>       struct.  */
> -  vec<tree> struct_types;
> +  auto_vec<tree> struct_types;
>    /* If warn_cxx_compat, a list of field names which have bindings,
>       and which are defined in this struct, but which are not defined
>       in any enclosing struct.  This is used to clear the in_struct
>       field of the c_bindings structure.  */
> -  vec<c_binding_ptr> fields;
> +  auto_vec<c_binding_ptr> fields;
>    /* If warn_cxx_compat, a list of typedef names used when defining
>       fields in this struct.  */
> -  vec<tree> typedefs_seen;
> +  auto_vec<tree> typedefs_seen;

...I don't see an explicit constructor here.

>  };
>  
>  /* Information for the struct or union currently being parsed, or
> @@ -7443,10 +7443,7 @@ start_struct (location_t loc, enum tree_code
> code, tree name,
>      TYPE_PACKED (v) = flag_pack_struct;
>  
>    *enclosing_struct_parse_info = struct_parse_info;
> -  struct_parse_info = XNEW (struct c_struct_parse_info);
> -  struct_parse_info->struct_types.create (0);
> -  struct_parse_info->fields.create (0);
> -  struct_parse_info->typedefs_seen.create (0);
> +  struct_parse_info = new c_struct_parse_info ();
>  
>    /* FIXME: This will issue a warning for a use of a type defined
>       within a statement expr used within sizeof, et. al.  This is
> not
> @@ -8088,10 +8085,7 @@ finish_struct (location_t loc, tree t, tree
> fieldlist, tree attributes,
>    if (warn_cxx_compat)
>      warn_cxx_compat_finish_struct (fieldlist, TREE_CODE (t), loc);
>  
> -  struct_parse_info->struct_types.release ();
> -  struct_parse_info->fields.release ();
> -  struct_parse_info->typedefs_seen.release ();
> -  XDELETE (struct_parse_info);
> +  delete struct_parse_info;
>  
>    struct_parse_info = enclosing_struct_parse_info;
>  

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info
  2016-06-29 13:48   ` David Malcolm
@ 2016-06-29 14:35     ` Trevor Saunders
  0 siblings, 0 replies; 15+ messages in thread
From: Trevor Saunders @ 2016-06-29 14:35 UTC (permalink / raw)
  To: David Malcolm; +Cc: tbsaunde+gcc, gcc-patches

On Wed, Jun 29, 2016 at 09:21:01AM -0400, David Malcolm wrote:
> On Wed, 2016-06-29 at 08:26 -0400, tbsaunde+gcc@tbsaunde.org wrote:
> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> > 
> > gcc/c/ChangeLog:
> 
> I may be missing my coffee here but you mention adding a constructor in
> the ChangeLog here:

No, I think I was missing mine, and you are right.  I'll update the
ChangeLog locally.

Trev

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/9] remove some manual memory management
  2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
                   ` (8 preceding siblings ...)
  2016-06-29 13:00 ` [PATCH 6/9] ree.c: use auto_vec in ext_state tbsaunde+gcc
@ 2016-06-30 10:36 ` Bernd Schmidt
  2016-07-07  0:47   ` Trevor Saunders
  9 siblings, 1 reply; 15+ messages in thread
From: Bernd Schmidt @ 2016-06-30 10:36 UTC (permalink / raw)
  To: tbsaunde+gcc, gcc-patches

On 06/29/2016 02:26 PM, tbsaunde+gcc@tbsaunde.org wrote:
> patches individually bootstrapped and regtested on x86_64-linux-gnu, ok?

I think these all look sensible. ChangeLogs ought to have slightly more 
information than "Adjust" in some cases, especially when you're changing 
function arguments.


Bernd

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/9] remove some manual memory management
  2016-06-30 10:36 ` [PATCH 0/9] remove some manual memory management Bernd Schmidt
@ 2016-07-07  0:47   ` Trevor Saunders
  2016-07-07 10:19     ` Eric Botcazou
  0 siblings, 1 reply; 15+ messages in thread
From: Trevor Saunders @ 2016-07-07  0:47 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: tbsaunde+gcc, gcc-patches

On Thu, Jun 30, 2016 at 12:33:24PM +0200, Bernd Schmidt wrote:
> On 06/29/2016 02:26 PM, tbsaunde+gcc@tbsaunde.org wrote:
> > patches individually bootstrapped and regtested on x86_64-linux-gnu, ok?
> 
> I think these all look sensible. ChangeLogs ought to have slightly more
> information than "Adjust" in some cases, especially when you're changing
> function arguments.

I'm still a little suprised people actually read ChangeLogs, but anyway

I doubt people want to be spammed with a bunch more email just for some
changes to ChangeLogs so I'll try and fix that up and then commit this.
Generally I've tried to just comment in the ChangeLog about the
meaningful change in the commit and then the rest generally is just
adjustments for that change, but not always and I guess that isn't
always the best textual description of a diff.

Thanks!

Trev

> 
> 
> Bernd
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/9] remove some manual memory management
  2016-07-07  0:47   ` Trevor Saunders
@ 2016-07-07 10:19     ` Eric Botcazou
  0 siblings, 0 replies; 15+ messages in thread
From: Eric Botcazou @ 2016-07-07 10:19 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: gcc-patches, Bernd Schmidt, tbsaunde+gcc

> I'm still a little suprised people actually read ChangeLogs, but anyway

ChangeLogs are a very effective mean of knowing whether changes were intended 
or instead made by mistake for example.

> I doubt people want to be spammed with a bunch more email just for some
> changes to ChangeLogs so I'll try and fix that up and then commit this.

You don't need to post patches to ChangeLogs, just apply them silently.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-07-07 10:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 12:19 [PATCH 0/9] remove some manual memory management tbsaunde+gcc
2016-06-29 12:19 ` [PATCH 2/9] c-decl.c: add [cd]tors to c_struct_parse_info tbsaunde+gcc
2016-06-29 13:48   ` David Malcolm
2016-06-29 14:35     ` Trevor Saunders
2016-06-29 12:19 ` [PATCH 1/9] tree.c: add [cd]tors to free_lang_data_d tbsaunde+gcc
2016-06-29 12:19 ` [PATCH 7/9] tree-ssa-sccvn.c: use auto_vec for sccvn_dom_walker::cond_stack tbsaunde+gcc
2016-06-29 12:19 ` [PATCH 8/9] use auto_vec for more local variables tbsaunde+gcc
2016-06-29 12:19 ` [PATCH 5/9] cfgexpand.c: use auto_vec in stack_vars_data tbsaunde+gcc
2016-06-29 12:19 ` [PATCH 3/9] genextract.c: add [cd]tors to accum_extract tbsaunde+gcc
2016-06-29 12:38 ` [PATCH 4/9] ipa.c: remove static_{ctors,dtors} globals tbsaunde+gcc
2016-06-29 12:39 ` [PATCH 9/9] remove unnecessary calls to vec::release tbsaunde+gcc
2016-06-29 13:00 ` [PATCH 6/9] ree.c: use auto_vec in ext_state tbsaunde+gcc
2016-06-30 10:36 ` [PATCH 0/9] remove some manual memory management Bernd Schmidt
2016-07-07  0:47   ` Trevor Saunders
2016-07-07 10:19     ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).