aboutsummaryrefslogtreecommitdiff
path: root/gcc/trans-mem.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2012-11-18 02:54:30 +0000
committerDiego Novillo <dnovillo@google.com>2012-11-18 02:54:30 +0000
commit85943a92f41f04a401d537cbf56857d68ec51033 (patch)
tree1b9f930d315fa3e0a5ed7fa6e27ec5bd0a3436a4 /gcc/trans-mem.c
parent5b4a7ac01f066ea476ad7b58e0aa7cf08c526dac (diff)
This patch rewrites the old VEC macro-based interface into a new one
based on the template class 'vec'. The user-visible changes are described in http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec. I have tested the patch pretty extensively: - Regular bootstraps on x86_64, ppc, ia64, sparc and hppa. - Bootstraps with --enable-checking=release - Bootstraps with --enable-checking=gc,gcac - Basic builds on all targets (using contrib/config-list.mk). We no longer access the vectors via VEC_* macros. The pattern is "VEC_operation (T, A, V, args)" becomes "V.operation (args)". The only thing I could not do is create proper ctors and dtors for the vec class. Since these vectors are stored in unions, we have to keep them as PODs (C++03 does not allow non-PODs in unions). This means that creation and destruction must be explicit. There is a new method vec<type, allocation, layout>::create() and another vec<type, allocation, layout>::destroy() to allocate the internal vector. For vectors that must be pointers, there is a family of free functions that implement the operations that need to tolerate NULL vectors. These functions all start with the prefix 'vec_safe_'. See the wiki page for details. The gengtype change removes the special handling for VEC() that used to exist in gengtype. Additionally, it allows gengtype to recognize templates of more than one argument and introduces the concept of an undefined type (useful for template arguments that may or may not be types). When a TYPE_UNDEFINED is reached, gengtype will ignore it if it happens inside a type marked with GTY((user)). Otherwise, it will emit an error. Finally, gengtype rejects root types marked GTY((user)) that are not first class pointers. 2012-11-16 Diego Novillo <dnovillo@google.com> VEC API overhaul (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec) * vec.c (register_overhead): Convert it into member function of vec_prefix. (release_overhead): Likewise. (calculate_allocation): Likewise. (vec_heap_free): Remove. (vec_gc_o_reserve_1): Remove. (vec_heap_o_reserve_1): Remove. (vec_stack_o_reserve_1): Remove. (vec_stack_o_reserve_exact): Remove. (register_stack_vec): New. (stack_vec_register_index): New. (unregister_stack_vec): New. (vec_assert_fail): Remove. * vec.h: Conditionally include ggc.h. Document conditional hackery. Update top-level documentation. (ALONE_VEC_CHECK_INFO): Remove. (VEC_CHECK_INFO): Remove. (ALONE_VEC_CHECK_DECL): Remove. (VEC_CHECK_DECL): Remove. (ALONE_VEC_CHECK_PASS): Remove. (VEC_CHECK_PASS): Remove. (VEC_ASSERT): Remove. (vec_prefix): Add friends va_gc, va_gc_atomic, va_heap and va_stack. Mark fields alloc_ and num_ as protected. (struct vec_t): Remove. Remove all function members. (struct vl_embed): Declare. (struct vl_ptr): Declare. (free): Remove. (reserve_exact): Remove. (reserve): Remove. (safe_splice): Remove. (safe_push): Remove. (safe_grow): Remove. (safe_grow_cleared): Remove. (safe_insert): Remove. (DEF_VEC_I): Remove. (DEF_VEC_ALLOC_I): Remove. (DEF_VEC_P): Remove. (DEF_VEC_ALLOC_P): Remove. (DEF_VEC_O): Remove. (DEF_VEC_ALLOC_O): Remove. (DEF_VEC_ALLOC_P_STACK): Remove. (DEF_VEC_ALLOC_O_STACK): Remove. (DEF_VEC_ALLOC_I_STACK): Remove. (DEF_VEC_A): Remove. (DEF_VEC_ALLOC_A): Remove. (vec_stack_p_reserve_exact_1): Remove. (vec_stack_o_reserve): Remove. (vec_stack_o_reserve_exact): Remove. (VEC_length): Remove. (VEC_empty): Remove. (VEC_address): Remove. (vec_address): Remove. (VEC_last): Remove. (VEC_index): Remove. (VEC_iterate): Remove. (VEC_embedded_size): Remove. (VEC_embedded_init): Remove. (VEC_free): Remove. (VEC_copy): Remove. (VEC_space): Remove. (VEC_reserve): Remove. (VEC_reserve_exact): Remove. (VEC_splice): Remove. (VEC_safe_splice): Remove. (VEC_quick_push): Remove. (VEC_safe_push): Remove. (VEC_pop): Remove. (VEC_truncate): Remove. (VEC_safe_grow): Remove. (VEC_replace): Remove. (VEC_quick_insert): Remove. (VEC_safe_insert): Remove. (VEC_ordered_remove): Remove. (VEC_unordered_remove): Remove. (VEC_block_remove): Remove. (VEC_lower_bound): Remove. (VEC_alloc): Remove. (VEC_qsort): Remove. (va_heap): Declare. (va_heap::default_layout): New typedef to vl_ptr. (va_heap::reserve): New. (va_heap::release): New. (va_gc): Declare. (va_gc::default_layout): New typedef to vl_embed. (va_gc::reserve): New. (va_gc::release): New. (va_gc_atomic): Declare. Inherit from va_gc. (va_stack): Declare. (va_stack::default_layout): New typedef to vl_ptr. (va_stack::alloc): New. (va_stack::reserve): New. (va_stack::release): New. (register_stack_vec): Declare. (stack_vec_register_index): Declare. (unregister_stack_vec): Declare. (vec<T, A = va_heap, L = typename A::default_layout>): Declare empty vec template. (vec<T, A, vl_embed>): Partial specialization for embedded layout. (vec<T, A, vl_embed>::allocated): New. (vec<T, A, vl_embed>::length): New. (vec<T, A, vl_embed>::is_empty): New. (vec<T, A, vl_embed>::address): New. (vec<T, A, vl_embed>::operator[]): New. (vec<T, A, vl_embed>::last New. (vec<T, A, vl_embed>::space): New. (vec<T, A, vl_embed>::iterate): New. (vec<T, A, vl_embed>::iterate): New. (vec<T, A, vl_embed>::copy): New. (vec<T, A, vl_embed>::splice): New. (vec<T, A, vl_embed>::quick_push New. (vec<T, A, vl_embed>::pop New. (vec<T, A, vl_embed>::truncate): New. (vec<T, A, vl_embed>::quick_insert): New. (vec<T, A, vl_embed>::ordered_remove): New. (vec<T, A, vl_embed>::unordered_remove): New. (vec<T, A, vl_embed>::block_remove): New. (vec<T, A, vl_embed>::qsort): New. (vec<T, A, vl_embed>::lower_bound): New. (vec<T, A, vl_embed>::embedded_size): New. (vec<T, A, vl_embed>::embedded_init): New. (vec<T, A, vl_embed>::quick_grow): New. (vec<T, A, vl_embed>::quick_grow_cleared): New. (vec_safe_space): New. (vec_safe_length): New. (vec_safe_address): New. (vec_safe_is_empty): New. (vec_safe_reserve): New. (vec_safe_reserve_exact): New. (vec_alloc): New. (vec_free): New. (vec_safe_grow): New. (vec_safe_grow_cleared): New. (vec_safe_iterate): New. (vec_safe_push): New. (vec_safe_insert): New. (vec_safe_truncate): New. (vec_safe_copy): New. (vec_safe_splice): New. (vec<T, A, vl_ptr>): New partial specialization for the space efficient layout. (vec<T, A, vl_ptr>::exists): New. (vec<T, A, vl_ptr>::is_empty): New. (vec<T, A, vl_ptr>::length): New. (vec<T, A, vl_ptr>::address): New. (vec<T, A, vl_ptr>::operator[]): New. (vec<T, A, vl_ptr>::operator!=): New. (vec<T, A, vl_ptr>::operator==): New. (vec<T, A, vl_ptr>::last): New. (vec<T, A, vl_ptr>::space): New. (vec<T, A, vl_ptr>::iterate): New. (vec<T, A, vl_ptr>::copy): New. (vec<T, A, vl_ptr>::reserve): New. (vec<T, A, vl_ptr>::reserve_exact): New. (vec<T, A, vl_ptr>::splice): New. (vec<T, A, vl_ptr>::safe_splice): New. (vec<T, A, vl_ptr>::quick_push): New. (vec<T, A, vl_ptr>::safe_push): New. (vec<T, A, vl_ptr>::pop): New. (vec<T, A, vl_ptr>::truncate): New. (vec<T, A, vl_ptr>::safe_grow): New. (vec<T, A, vl_ptr>::safe_grow_cleared): New. (vec<T, A, vl_ptr>::quick_grow): New. (vec<T, A, vl_ptr>::quick_grow_cleared): New. (vec<T, A, vl_ptr>::quick_insert): New. (vec<T, A, vl_ptr>::safe_insert): New. (vec<T, A, vl_ptr>::ordered_remove): New. (vec<T, A, vl_ptr>::unordered_remove): New. (vec<T, A, vl_ptr>::block_remove): New. (vec<T, A, vl_ptr>::qsort): New. (vec<T, A, vl_ptr>::lower_bound): New. (vec_stack_alloc): Define. (FOR_EACH_VEC_SAFE_ELT): Define. * vecir.h: Remove. Update all users. * vecprim.h: Remove. Update all users. Move uchar to coretypes.h. * Makefile.in (VEC_H): Add $(GGC_H). Remove vecir.h and vecprim.h dependencies everywhere. 2012-11-16 Diego Novillo <dnovillo@google.com> * gengtype-lex.l (VEC): Remove. Add characters in the set [\!\>\.-]. * gengtype-parse.c (token_names): Remove "VEC". (require_template_declaration): Remove handling of VEC_TOKEN. (type): Likewise. Call create_user_defined_type when parsing GTY((user)). * gengtype-state.c (type_lineloc): handle TYPE_UNDEFINED. (write_state_undefined_type): New. (write_state_type): Call write_state_undefined_type for TYPE_UNDEFINED. (read_state_type): Call read_state_undefined_type for TYPE_UNDEFINED. * gengtype.c (dbgprint_count_type_at): Handle TYPE_UNDEFINED. (create_user_defined_type): Make extern. (type_for_name): Factor out of resolve_typedef. (create_undefined_type): New (resolve_typedef): Call it when we cannot find a previous typedef and the type is not a template. (find_structure): Accept TYPE_UNDEFINED. (set_gc_used_type): Add argument ALLOWED_UNDEFINED_TYPES, default to false. Emit an error for TYPE_UNDEFINED unless LEVEL is GC_UNUSED or ALLOWED_UNDEFINED_TYPES is set. Set ALLOWED_UNDEFINED_TYPES to true for TYPE_USER_STRUCT. (filter_type_name): Accept templates with more than one argument. (output_mangled_typename): Handle TYPE_UNDEFINED (walk_type): Likewise. (write_types_process_field): Likewise. (write_func_for_structure): If CHAIN_NEXT is set, ORIG_S should not be a user-defined type. (write_types_local_user_process_field): Handle TYPE_ARRAY, TYPE_NONE and TYPE_UNDEFINED. (write_types_local_process_field): Likewise. (contains_scalar_p): Return 0 for TYPE_USER_STRUCT. (write_root): Reject user-defined types that are not pointers. Handle TYPE_NONE, TYPE_UNDEFINED, TYPE_UNION, TYPE_LANG_STRUCT and TYPE_PARAM_STRUCT. (output_typename): Handle TYPE_NONE, TYPE_UNDEFINED, and TYPE_ARRAY. (dump_typekind): Handle TYPE_UNDEFINED. * gengtype.h (enum typekind): Add TYPE_UNDEFINED. (create_user_defined_type): Declare. (enum gty_token): Remove VEC_TOKEN. 2012-11-16 Diego Novillo <dnovillo@google.com> Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec) * coretypes.h (uchar): Define. * alias.c: Use new vec API in vec.h. * asan.c: Likewise. * attribs.c: Likewise. * basic-block.h: Likewise. * bb-reorder.c: Likewise. * builtins.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgcleanup.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfghooks.h: Likewise. * cfgloop.c: Likewise. * cfgloop.h: Likewise. * cfgloopanal.c: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphclones.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * compare-elim.c: Likewise. * coverage.c: Likewise. * cprop.c: Likewise. * data-streamer.h: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * domwalk.h: Likewise. * dse.c: Likewise. * dwarf2cfi.c: Likewise. * dwarf2out.c: Likewise. * dwarf2out.h: Likewise. * emit-rtl.c: Likewise. * except.c: Likewise. * except.h: Likewise. * expr.c: Likewise. * expr.h: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * function.h: Likewise. * fwprop.c: Likewise. * gcc.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * genattrtab.c: Likewise. * genautomata.c: Likewise. * genextract.c: Likewise. * genopinit.c: Likewise * ggc-common.c: Likewise. * ggc.h: Likewise. * gimple-low.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * gimple-streamer-in.c: Likewise. * gimple.c: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * graph.c: Likewise. * graphds.c: Likewise. * graphds.h: Likewise. * graphite-blocking.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-optimize-isl.c: Likewise. * graphite-poly.c: Likewise. * graphite-poly.h: Likewise. * graphite-scop-detection.c: Likewise. * graphite-scop-detection.h: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * godump.c: Likewise. * haifa-sched.c: Likewise. * hw-doloop.c: Likewise. * hw-doloop.h: Likewise. * ifcvt.c: Likewise. * insn-addr.h: Likewise. * ipa-cp.c: Likewise. * ipa-inline-analysis.c: Likewise. * ipa-inline-transform.c: Likewise. * ipa-inline.c: Likewise. * ipa-inline.h: Likewise. * ipa-prop.c: Likewise. * ipa-prop.h: Likewise. * ipa-pure-const.c: Likewise. * ipa-ref-inline.h: Likewise. * ipa-ref.c: Likewise. * ipa-ref.h: Likewise. * ipa-reference.c: Likewise. * ipa-split.c: Likewise. * ipa-utils.c: Likewise. * ipa-utils.h: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-emit.c: Likewise. * ira-int.h: Likewise. * ira.c: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lra-lives.c: Likewise. * lra.c: Likewise. * lto-cgraph.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.h: Likewise. * lto-symtab.c: Likewise. * mcf.c: Likewise. * modulo-sched.c: Likewise. * omp-low.c: Likewise. * opts-common.c: Likewise. * opts-global.c: Likewise. * opts.c: Likewise. * opts.h: Likewise. * passes.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * profile.h: Likewise. * read-rtl.c: Likewise. * ree.c: Likewise. * reg-stack.c: Likewise. * regrename.c: Likewise. * regrename.h: Likewise. * reload.c: Likewise. * reload.h: Likewise. * reload1.c: Likewise. * rtl.h: Likewise. * sched-deps.c: Likewise. * sched-int.h: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched-ir.h: Likewise. * sel-sched.c: Likewise. * sese.c: Likewise. * sese.h: Likewise. * statistics.h: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * tlink.c: Likewise. * toplev.c: Likewise. * trans-mem.c: Likewise. * tree-browser.c: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-chrec.h: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-data-ref.h: Likewise. * tree-dfa.c: Likewise. * tree-diagnostic.c: Likewise. * tree-dump.c: Likewise. * tree-eh.c: Likewise. * tree-emutls.c: Likewise. * tree-flow.h: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-inline.h: Likewise. * tree-into-ssa.c: Likewise. * tree-iterator.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-mudflap.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.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-operands.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sccvn.h: Likewise. * tree-ssa-strlen.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-tail-merge.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-ssa.c: Likewise. * tree-ssanames.c: Likewise. * tree-stdarg.c: Likewise. * tree-streamer-in.c: Likewise. * tree-streamer-out.c: Likewise. * tree-streamer.c: Likewise. * tree-streamer.h: Likewise. * tree-switch-conversion.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * tree.h: Likewise. * value-prof.c: Likewise. * value-prof.h: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vmsdbgout.c: Likewise. * config/bfin/bfin.c: Likewise. * config/c6x/c6x.c: Likewise. * config/darwin.c: Likewise. * config/i386/i386.c: Likewise. * config/ia64/ia64.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/pa/pa.c: Likewise. * config/rs6000/rs6000-c.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/rx/rx.c: Likewise. * config/spu/spu-c.c: Likewise. * config/vms/vms.c: Likewise. * config/vxworks.c: Likewise. * config/epiphany/resolve-sw-modes.c: Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@193595 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/trans-mem.c')
-rw-r--r--gcc/trans-mem.c265
1 files changed, 132 insertions, 133 deletions
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index a7b4a9c0484..4edb98598ec 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -884,7 +884,7 @@ static htab_t tm_log;
/* Addresses to log with a save/restore sequence. These should be in
dominator order. */
-static VEC(tree,heap) *tm_log_save_addresses;
+static vec<tree> tm_log_save_addresses;
/* Map for an SSA_NAME originally pointing to a non aliased new piece
of memory (malloc, alloc, etc). */
@@ -947,7 +947,7 @@ static void
tm_log_free (void *p)
{
struct tm_log_entry *lp = (struct tm_log_entry *) p;
- VEC_free (gimple, heap, lp->stmts);
+ lp->stmts.release ();
free (lp);
}
@@ -957,7 +957,7 @@ tm_log_init (void)
{
tm_log = htab_create (10, tm_log_hash, tm_log_eq, tm_log_free);
tm_new_mem_hash = htab_create (5, struct_ptr_hash, struct_ptr_eq, free);
- tm_log_save_addresses = VEC_alloc (tree, heap, 5);
+ tm_log_save_addresses.create (5);
}
/* Free logging data structures. */
@@ -966,7 +966,7 @@ tm_log_delete (void)
{
htab_delete (tm_log);
htab_delete (tm_new_mem_hash);
- VEC_free (tree, heap, tm_log_save_addresses);
+ tm_log_save_addresses.release ();
}
/* Return true if MEM is a transaction invariant memory for the TM
@@ -1031,18 +1031,18 @@ tm_log_add (basic_block entry_block, tree addr, gimple stmt)
&& !TREE_ADDRESSABLE (type))
{
lp->save_var = create_tmp_reg (TREE_TYPE (lp->addr), "tm_save");
- lp->stmts = NULL;
+ lp->stmts.create (0);
lp->entry_block = entry_block;
/* Save addresses separately in dominator order so we don't
get confused by overlapping addresses in the save/restore
sequence. */
- VEC_safe_push (tree, heap, tm_log_save_addresses, lp->addr);
+ tm_log_save_addresses.safe_push (lp->addr);
}
else
{
/* Use the logging functions. */
- lp->stmts = VEC_alloc (gimple, heap, 5);
- VEC_quick_push (gimple, lp->stmts, stmt);
+ lp->stmts.create (5);
+ lp->stmts.quick_push (stmt);
lp->save_var = NULL;
}
}
@@ -1058,7 +1058,7 @@ tm_log_add (basic_block entry_block, tree addr, gimple stmt)
if (lp->save_var)
return;
- for (i = 0; VEC_iterate (gimple, lp->stmts, i, oldstmt); ++i)
+ for (i = 0; lp->stmts.iterate (i, &oldstmt); ++i)
{
if (stmt == oldstmt)
return;
@@ -1072,7 +1072,7 @@ tm_log_add (basic_block entry_block, tree addr, gimple stmt)
gimple_bb (oldstmt), gimple_bb (stmt)));
}
/* Store is on a different code path. */
- VEC_safe_push (gimple, heap, lp->stmts, stmt);
+ lp->stmts.safe_push (stmt);
}
}
@@ -1178,7 +1178,7 @@ tm_log_emit (void)
{
if (dump_file)
fprintf (dump_file, "DUMPING with logging functions\n");
- for (i = 0; VEC_iterate (gimple, lp->stmts, i, stmt); ++i)
+ for (i = 0; lp->stmts.iterate (i, &stmt); ++i)
tm_log_emit_stmt (lp->addr, stmt);
}
}
@@ -1195,9 +1195,9 @@ tm_log_emit_saves (basic_block entry_block, basic_block bb)
gimple stmt;
struct tm_log_entry l, *lp;
- for (i = 0; i < VEC_length (tree, tm_log_save_addresses); ++i)
+ for (i = 0; i < tm_log_save_addresses.length (); ++i)
{
- l.addr = VEC_index (tree, tm_log_save_addresses, i);
+ l.addr = tm_log_save_addresses[i];
lp = (struct tm_log_entry *) *htab_find_slot (tm_log, &l, NO_INSERT);
gcc_assert (lp->save_var != NULL);
@@ -1231,9 +1231,9 @@ tm_log_emit_restores (basic_block entry_block, basic_block bb)
gimple_stmt_iterator gsi;
gimple stmt;
- for (i = VEC_length (tree, tm_log_save_addresses) - 1; i >= 0; i--)
+ for (i = tm_log_save_addresses.length () - 1; i >= 0; i--)
{
- l.addr = VEC_index (tree, tm_log_save_addresses, i);
+ l.addr = tm_log_save_addresses[i];
lp = (struct tm_log_entry *) *htab_find_slot (tm_log, &l, NO_INSERT);
gcc_assert (lp->save_var != NULL);
@@ -1740,8 +1740,6 @@ struct tm_region
};
typedef struct tm_region *tm_region_p;
-DEF_VEC_P (tm_region_p);
-DEF_VEC_ALLOC_P (tm_region_p, heap);
/* True if there are pending edge statements to be committed for the
current function being scanned in the tmmark pass. */
@@ -1843,10 +1841,10 @@ tm_region_init (struct tm_region *region)
edge_iterator ei;
edge e;
basic_block bb;
- VEC(basic_block, heap) *queue = NULL;
+ vec<basic_block> queue = vec<basic_block>();
bitmap visited_blocks = BITMAP_ALLOC (NULL);
struct tm_region *old_region;
- VEC(tm_region_p, heap) *bb_regions = NULL;
+ vec<tm_region_p> bb_regions = vec<tm_region_p>();
all_tm_regions = region;
bb = single_succ (ENTRY_BLOCK_PTR);
@@ -1854,15 +1852,15 @@ tm_region_init (struct tm_region *region)
/* We could store this information in bb->aux, but we may get called
through get_all_tm_blocks() from another pass that may be already
using bb->aux. */
- VEC_safe_grow_cleared (tm_region_p, heap, bb_regions, last_basic_block);
+ bb_regions.safe_grow_cleared (last_basic_block);
- VEC_safe_push (basic_block, heap, queue, bb);
- VEC_replace (tm_region_p, bb_regions, bb->index, region);
+ queue.safe_push (bb);
+ bb_regions[bb->index] = region;
do
{
- bb = VEC_pop (basic_block, queue);
- region = VEC_index (tm_region_p, bb_regions, bb->index);
- VEC_replace (tm_region_p, bb_regions, bb->index, NULL);
+ bb = queue.pop ();
+ region = bb_regions[bb->index];
+ bb_regions[bb->index] = NULL;
/* Record exit and irrevocable blocks. */
region = tm_region_init_1 (region, bb);
@@ -1878,21 +1876,21 @@ tm_region_init (struct tm_region *region)
if (!bitmap_bit_p (visited_blocks, e->dest->index))
{
bitmap_set_bit (visited_blocks, e->dest->index);
- VEC_safe_push (basic_block, heap, queue, e->dest);
+ queue.safe_push (e->dest);
/* If the current block started a new region, make sure that only
the entry block of the new region is associated with this region.
Other successors are still part of the old region. */
if (old_region != region && e->dest != region->entry_block)
- VEC_replace (tm_region_p, bb_regions, e->dest->index, old_region);
+ bb_regions[e->dest->index] = old_region;
else
- VEC_replace (tm_region_p, bb_regions, e->dest->index, region);
+ bb_regions[e->dest->index] = region;
}
}
- while (!VEC_empty (basic_block, queue));
- VEC_free (basic_block, heap, queue);
+ while (!queue.is_empty ());
+ queue.release ();
BITMAP_FREE (visited_blocks);
- VEC_free (tm_region_p, heap, bb_regions);
+ bb_regions.release ();
}
/* The "gate" function for all transactional memory expansion and optimization
@@ -2097,7 +2095,7 @@ build_tm_store (location_t loc, tree lhs, tree rhs, gimple_stmt_iterator *gsi)
if (TREE_CODE (rhs) == CONSTRUCTOR)
{
/* Handle the easy initialization to zero. */
- if (CONSTRUCTOR_ELTS (rhs) == 0)
+ if (!CONSTRUCTOR_ELTS (rhs))
rhs = build_int_cst (simple_type, 0);
else
{
@@ -2398,26 +2396,26 @@ expand_block_tm (struct tm_region *region, basic_block bb)
STOP_AT_IRREVOCABLE_P is true if caller is uninterested in blocks
following a TM_IRREVOCABLE call. */
-static VEC (basic_block, heap) *
+static vec<basic_block>
get_tm_region_blocks (basic_block entry_block,
bitmap exit_blocks,
bitmap irr_blocks,
bitmap all_region_blocks,
bool stop_at_irrevocable_p)
{
- VEC(basic_block, heap) *bbs = NULL;
+ vec<basic_block> bbs = vec<basic_block>();
unsigned i;
edge e;
edge_iterator ei;
bitmap visited_blocks = BITMAP_ALLOC (NULL);
i = 0;
- VEC_safe_push (basic_block, heap, bbs, entry_block);
+ bbs.safe_push (entry_block);
bitmap_set_bit (visited_blocks, entry_block->index);
do
{
- basic_block bb = VEC_index (basic_block, bbs, i++);
+ basic_block bb = bbs[i++];
if (exit_blocks &&
bitmap_bit_p (exit_blocks, bb->index))
@@ -2432,10 +2430,10 @@ get_tm_region_blocks (basic_block entry_block,
if (!bitmap_bit_p (visited_blocks, e->dest->index))
{
bitmap_set_bit (visited_blocks, e->dest->index);
- VEC_safe_push (basic_block, heap, bbs, e->dest);
+ bbs.safe_push (e->dest);
}
}
- while (i < VEC_length (basic_block, bbs));
+ while (i < bbs.length ());
if (all_region_blocks)
bitmap_ior_into (all_region_blocks, visited_blocks);
@@ -2448,8 +2446,8 @@ get_tm_region_blocks (basic_block entry_block,
static void *
collect_bb2reg (struct tm_region *region, void *data)
{
- VEC(tm_region_p, heap) *bb2reg = (VEC(tm_region_p, heap) *) data;
- VEC (basic_block, heap) *queue;
+ vec<tm_region_p> *bb2reg = (vec<tm_region_p> *) data;
+ vec<basic_block> queue;
unsigned int i;
basic_block bb;
@@ -2461,10 +2459,10 @@ collect_bb2reg (struct tm_region *region, void *data)
// We expect expand_region to perform a post-order traversal of the region
// tree. Therefore the last region seen for any bb is the innermost.
- FOR_EACH_VEC_ELT (basic_block, queue, i, bb)
- VEC_replace (tm_region_p, bb2reg, bb->index, region);
+ FOR_EACH_VEC_ELT (queue, i, bb)
+ (*bb2reg)[bb->index] = region;
- VEC_free (basic_block, heap, queue);
+ queue.release ();
return NULL;
}
@@ -2490,15 +2488,15 @@ collect_bb2reg (struct tm_region *region, void *data)
// ??? There is currently a hack inside tree-ssa-pre.c to work around the
// only known instance of this block sharing.
-static VEC(tm_region_p, heap) *
+static vec<tm_region_p>
get_bb_regions_instrumented (void)
{
unsigned n = last_basic_block;
- VEC(tm_region_p, heap) *ret;
+ vec<tm_region_p> ret;
- ret = VEC_alloc (tm_region_p, heap, n);
- VEC_safe_grow_cleared (tm_region_p, heap, ret, n);
- expand_regions (all_tm_regions, collect_bb2reg, ret);
+ ret.create (n);
+ ret.safe_grow_cleared (n);
+ expand_regions (all_tm_regions, collect_bb2reg, &ret);
return ret;
}
@@ -2510,7 +2508,7 @@ void
compute_transaction_bits (void)
{
struct tm_region *region;
- VEC (basic_block, heap) *queue;
+ vec<basic_block> queue;
unsigned int i;
basic_block bb;
@@ -2528,9 +2526,9 @@ compute_transaction_bits (void)
region->irr_blocks,
NULL,
/*stop_at_irr_p=*/true);
- for (i = 0; VEC_iterate (basic_block, queue, i, bb); ++i)
+ for (i = 0; queue.iterate (i, &bb); ++i)
bb->flags |= BB_IN_TRANSACTION;
- VEC_free (basic_block, heap, queue);
+ queue.release ();
}
if (all_tm_regions)
@@ -2603,7 +2601,7 @@ expand_transaction (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
}
// Generate log saves.
- if (!VEC_empty (tree, tm_log_save_addresses))
+ if (!tm_log_save_addresses.is_empty ())
tm_log_emit_saves (region->entry_block, transaction_bb);
// In the beginning, we've no tests to perform on transaction restart.
@@ -2612,7 +2610,7 @@ expand_transaction (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
region->restart_block = region->entry_block;
// Generate log restores.
- if (!VEC_empty (tree, tm_log_save_addresses))
+ if (!tm_log_save_addresses.is_empty ())
{
basic_block test_bb = create_empty_bb (transaction_bb);
basic_block code_bb = create_empty_bb (test_bb);
@@ -2830,13 +2828,13 @@ execute_tm_mark (void)
tm_log_init ();
- VEC(tm_region_p, heap) *bb_regions = get_bb_regions_instrumented ();
+ vec<tm_region_p> bb_regions = get_bb_regions_instrumented ();
struct tm_region *r;
unsigned i;
// Expand memory operations into calls into the runtime.
// This collects log entries as well.
- FOR_EACH_VEC_ELT (tm_region_p, bb_regions, i, r)
+ FOR_EACH_VEC_ELT (bb_regions, i, r)
if (r != NULL)
expand_block_tm (r, BASIC_BLOCK (i));
@@ -3000,15 +2998,15 @@ expand_block_edges (struct tm_region *const region, basic_block bb)
static unsigned int
execute_tm_edges (void)
{
- VEC(tm_region_p, heap) *bb_regions = get_bb_regions_instrumented ();
+ vec<tm_region_p> bb_regions = get_bb_regions_instrumented ();
struct tm_region *r;
unsigned i;
- FOR_EACH_VEC_ELT (tm_region_p, bb_regions, i, r)
+ FOR_EACH_VEC_ELT (bb_regions, i, r)
if (r != NULL)
expand_block_edges (r, BASIC_BLOCK (i));
- VEC_free (tm_region_p, heap, bb_regions);
+ bb_regions.release ();
/* We've got to release the dominance info now, to indicate that it
must be rebuilt completely. Otherwise we'll crash trying to update
@@ -3265,12 +3263,12 @@ dump_tm_memopt_set (const char *set_name, bitmap bits)
/* Prettily dump all of the memopt sets in BLOCKS. */
static void
-dump_tm_memopt_sets (VEC (basic_block, heap) *blocks)
+dump_tm_memopt_sets (vec<basic_block> blocks)
{
size_t i;
basic_block bb;
- for (i = 0; VEC_iterate (basic_block, blocks, i, bb); ++i)
+ for (i = 0; blocks.iterate (i, &bb); ++i)
{
fprintf (dump_file, "------------BB %d---------\n", bb->index);
dump_tm_memopt_set ("STORE_LOCAL", STORE_LOCAL (bb));
@@ -3368,7 +3366,7 @@ tm_memopt_compute_antin (basic_block bb)
static void
tm_memopt_compute_available (struct tm_region *region,
- VEC (basic_block, heap) *blocks)
+ vec<basic_block> blocks)
{
edge e;
basic_block *worklist, *qin, *qout, *qend, bb;
@@ -3379,12 +3377,12 @@ tm_memopt_compute_available (struct tm_region *region,
/* Allocate a worklist array/queue. Entries are only added to the
list if they were not already on the list. So the size is
bounded by the number of basic blocks in the region. */
- qlen = VEC_length (basic_block, blocks) - 1;
+ qlen = blocks.length () - 1;
qin = qout = worklist =
XNEWVEC (basic_block, qlen);
/* Put every block in the region on the worklist. */
- for (i = 0; VEC_iterate (basic_block, blocks, i, bb); ++i)
+ for (i = 0; blocks.iterate (i, &bb); ++i)
{
/* Seed AVAIL_OUT with the LOCAL set. */
bitmap_ior_into (STORE_AVAIL_OUT (bb), STORE_LOCAL (bb));
@@ -3456,7 +3454,7 @@ tm_memopt_compute_available (struct tm_region *region,
static void
tm_memopt_compute_antic (struct tm_region *region,
- VEC (basic_block, heap) *blocks)
+ vec<basic_block> blocks)
{
edge e;
basic_block *worklist, *qin, *qout, *qend, bb;
@@ -3467,12 +3465,11 @@ tm_memopt_compute_antic (struct tm_region *region,
/* Allocate a worklist array/queue. Entries are only added to the
list if they were not already on the list. So the size is
bounded by the number of basic blocks in the region. */
- qin = qout = worklist =
- XNEWVEC (basic_block, VEC_length (basic_block, blocks));
+ qin = qout = worklist = XNEWVEC (basic_block, blocks.length ());
- for (qlen = 0, i = VEC_length (basic_block, blocks) - 1; i >= 0; --i)
+ for (qlen = 0, i = blocks.length () - 1; i >= 0; --i)
{
- bb = VEC_index (basic_block, blocks, i);
+ bb = blocks[i];
/* Seed ANTIC_OUT with the LOCAL set. */
bitmap_ior_into (STORE_ANTIC_OUT (bb), STORE_LOCAL (bb));
@@ -3586,13 +3583,13 @@ tm_memopt_transform_stmt (unsigned int offset,
basic blocks in BLOCKS. */
static void
-tm_memopt_transform_blocks (VEC (basic_block, heap) *blocks)
+tm_memopt_transform_blocks (vec<basic_block> blocks)
{
size_t i;
basic_block bb;
gimple_stmt_iterator gsi;
- for (i = 0; VEC_iterate (basic_block, blocks, i, bb); ++i)
+ for (i = 0; blocks.iterate (i, &bb); ++i)
{
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
@@ -3655,24 +3652,24 @@ tm_memopt_init_sets (void)
/* Free sets computed for each BB. */
static void
-tm_memopt_free_sets (VEC (basic_block, heap) *blocks)
+tm_memopt_free_sets (vec<basic_block> blocks)
{
size_t i;
basic_block bb;
- for (i = 0; VEC_iterate (basic_block, blocks, i, bb); ++i)
+ for (i = 0; blocks.iterate (i, &bb); ++i)
bb->aux = NULL;
}
/* Clear the visited bit for every basic block in BLOCKS. */
static void
-tm_memopt_clear_visited (VEC (basic_block, heap) *blocks)
+tm_memopt_clear_visited (vec<basic_block> blocks)
{
size_t i;
basic_block bb;
- for (i = 0; VEC_iterate (basic_block, blocks, i, bb); ++i)
+ for (i = 0; blocks.iterate (i, &bb); ++i)
BB_VISITED_P (bb) = false;
}
@@ -3684,7 +3681,7 @@ static unsigned int
execute_tm_memopt (void)
{
struct tm_region *region;
- VEC (basic_block, heap) *bbs;
+ vec<basic_block> bbs;
tm_memopt_value_id = 0;
tm_memopt_value_numbers = htab_create (10, tm_memop_hash, tm_memop_eq, free);
@@ -3705,7 +3702,7 @@ execute_tm_memopt (void)
false);
/* Collect all the memory operations. */
- for (i = 0; VEC_iterate (basic_block, bbs, i, bb); ++i)
+ for (i = 0; bbs.iterate (i, &bb); ++i)
{
bb->aux = tm_memopt_init_sets ();
tm_memopt_accumulate_memops (bb);
@@ -3719,7 +3716,7 @@ execute_tm_memopt (void)
tm_memopt_transform_blocks (bbs);
tm_memopt_free_sets (bbs);
- VEC_free (basic_block, heap, bbs);
+ bbs.release ();
bitmap_obstack_release (&tm_memopt_obstack);
htab_empty (tm_memopt_value_numbers);
}
@@ -3837,7 +3834,7 @@ struct tm_ipa_cg_data
bool want_irr_scan_normal;
};
-typedef VEC (cgraph_node_p, heap) *cgraph_node_queue;
+typedef vec<cgraph_node_ptr> cgraph_node_queue;
/* Return the ipa data associated with NODE, allocating zeroed memory
if necessary. TRAVERSE_ALIASES is true if we must traverse aliases
@@ -3874,7 +3871,7 @@ maybe_push_queue (struct cgraph_node *node,
if (!*in_queue_p)
{
*in_queue_p = true;
- VEC_safe_push (cgraph_node_p, heap, *queue_p, node);
+ queue_p->safe_push (node);
}
}
@@ -3887,15 +3884,14 @@ maybe_push_queue (struct cgraph_node *node,
static void
ipa_uninstrument_transaction (struct tm_region *region,
- VEC (basic_block, heap) *queue)
+ vec<basic_block> queue)
{
gimple transaction = region->transaction_stmt;
basic_block transaction_bb = gimple_bb (transaction);
- int n = VEC_length (basic_block, queue);
+ int n = queue.length ();
basic_block *new_bbs = XNEWVEC (basic_block, n);
- copy_bbs (VEC_address (basic_block, queue), n, new_bbs,
- NULL, 0, NULL, NULL, transaction_bb);
+ copy_bbs (queue.address (), n, new_bbs, NULL, 0, NULL, NULL, transaction_bb);
edge e = make_edge (transaction_bb, new_bbs[0], EDGE_TM_UNINSTRUMENTED);
add_phi_args_after_copy (new_bbs, n, e);
@@ -3961,7 +3957,7 @@ ipa_tm_scan_calls_transaction (struct tm_ipa_cg_data *d,
for (r = all_tm_regions; r; r = r->next)
{
- VEC (basic_block, heap) *bbs;
+ vec<basic_block> bbs;
basic_block bb;
unsigned i;
@@ -3971,10 +3967,10 @@ ipa_tm_scan_calls_transaction (struct tm_ipa_cg_data *d,
// Generate the uninstrumented code path for this transaction.
ipa_uninstrument_transaction (r, bbs);
- FOR_EACH_VEC_ELT (basic_block, bbs, i, bb)
+ FOR_EACH_VEC_ELT (bbs, i, bb)
ipa_tm_scan_calls_block (callees_p, bb, false);
- VEC_free (basic_block, heap, bbs);
+ bbs.release ();
}
// ??? copy_bbs should maintain cgraph edges for the blocks as it is
@@ -4138,7 +4134,7 @@ ipa_tm_scan_irr_block (basic_block bb)
scanning past OLD_IRR or EXIT_BLOCKS. */
static bool
-ipa_tm_scan_irr_blocks (VEC (basic_block, heap) **pqueue, bitmap new_irr,
+ipa_tm_scan_irr_blocks (vec<basic_block> *pqueue, bitmap new_irr,
bitmap old_irr, bitmap exit_blocks)
{
bool any_new_irr = false;
@@ -4148,7 +4144,7 @@ ipa_tm_scan_irr_blocks (VEC (basic_block, heap) **pqueue, bitmap new_irr,
do
{
- basic_block bb = VEC_pop (basic_block, *pqueue);
+ basic_block bb = pqueue->pop ();
/* Don't re-scan blocks we know already are irrevocable. */
if (old_irr && bitmap_bit_p (old_irr, bb->index))
@@ -4165,11 +4161,11 @@ ipa_tm_scan_irr_blocks (VEC (basic_block, heap) **pqueue, bitmap new_irr,
if (!bitmap_bit_p (visited_blocks, e->dest->index))
{
bitmap_set_bit (visited_blocks, e->dest->index);
- VEC_safe_push (basic_block, heap, *pqueue, e->dest);
+ pqueue->safe_push (e->dest);
}
}
}
- while (!VEC_empty (basic_block, *pqueue));
+ while (!pqueue->is_empty ());
BITMAP_FREE (visited_blocks);
@@ -4186,7 +4182,7 @@ static void
ipa_tm_propagate_irr (basic_block entry_block, bitmap new_irr,
bitmap old_irr, bitmap exit_blocks)
{
- VEC (basic_block, heap) *bbs;
+ vec<basic_block> bbs;
bitmap all_region_blocks;
/* If this block is in the old set, no need to rescan. */
@@ -4198,7 +4194,7 @@ ipa_tm_propagate_irr (basic_block entry_block, bitmap new_irr,
all_region_blocks, false);
do
{
- basic_block bb = VEC_pop (basic_block, bbs);
+ basic_block bb = bbs.pop ();
bool this_irr = bitmap_bit_p (new_irr, bb->index);
bool all_son_irr = false;
edge_iterator ei;
@@ -4245,10 +4241,10 @@ ipa_tm_propagate_irr (basic_block entry_block, bitmap new_irr,
}
}
}
- while (!VEC_empty (basic_block, bbs));
+ while (!bbs.is_empty ());
BITMAP_FREE (all_region_blocks);
- VEC_free (basic_block, heap, bbs);
+ bbs.release ();
}
static void
@@ -4297,7 +4293,7 @@ ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
{
struct tm_ipa_cg_data *d;
bitmap new_irr, old_irr;
- VEC (basic_block, heap) *queue;
+ vec<basic_block> queue;
bool ret = false;
/* Builtin operators (operator new, and such). */
@@ -4309,14 +4305,14 @@ ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
calculate_dominance_info (CDI_DOMINATORS);
d = get_cg_data (&node, true);
- queue = VEC_alloc (basic_block, heap, 10);
+ queue.create (10);
new_irr = BITMAP_ALLOC (&tm_obstack);
/* Scan each tm region, propagating irrevocable status through the tree. */
if (for_clone)
{
old_irr = d->irrevocable_blocks_clone;
- VEC_quick_push (basic_block, queue, single_succ (ENTRY_BLOCK_PTR));
+ queue.quick_push (single_succ (ENTRY_BLOCK_PTR));
if (ipa_tm_scan_irr_blocks (&queue, new_irr, old_irr, NULL))
{
ipa_tm_propagate_irr (single_succ (ENTRY_BLOCK_PTR), new_irr,
@@ -4331,7 +4327,7 @@ ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
old_irr = d->irrevocable_blocks_normal;
for (region = d->all_tm_regions; region; region = region->next)
{
- VEC_quick_push (basic_block, queue, region->entry_block);
+ queue.quick_push (region->entry_block);
if (ipa_tm_scan_irr_blocks (&queue, new_irr, old_irr,
region->exit_blocks))
ipa_tm_propagate_irr (region->entry_block, new_irr, old_irr,
@@ -4374,7 +4370,7 @@ ipa_tm_scan_irr_function (struct cgraph_node *node, bool for_clone)
else
BITMAP_FREE (new_irr);
- VEC_free (basic_block, heap, queue);
+ queue.release ();
pop_cfun ();
return ret;
@@ -4476,7 +4472,7 @@ ipa_tm_diagnose_transaction (struct cgraph_node *node,
}
else
{
- VEC (basic_block, heap) *bbs;
+ vec<basic_block> bbs;
gimple_stmt_iterator gsi;
basic_block bb;
size_t i;
@@ -4484,7 +4480,7 @@ ipa_tm_diagnose_transaction (struct cgraph_node *node,
bbs = get_tm_region_blocks (r->entry_block, r->exit_blocks,
r->irr_blocks, NULL, false);
- for (i = 0; VEC_iterate (basic_block, bbs, i, bb); ++i)
+ for (i = 0; bbs.iterate (i, &bb); ++i)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
@@ -4525,7 +4521,7 @@ ipa_tm_diagnose_transaction (struct cgraph_node *node,
"atomic transaction", fndecl);
}
- VEC_free (basic_block, heap, bbs);
+ bbs.release ();
}
}
@@ -4682,7 +4678,9 @@ ipa_tm_create_version (struct cgraph_node *old_node)
if (DECL_ONE_ONLY (new_decl))
DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl));
- new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL, NULL);
+ new_node = cgraph_copy_node_for_versioning (old_node, new_decl,
+ vec<cgraph_edge_p>(),
+ NULL);
new_node->symbol.externally_visible = old_node->symbol.externally_visible;
new_node->lowered = true;
new_node->tm_clone = 1;
@@ -4699,8 +4697,9 @@ ipa_tm_create_version (struct cgraph_node *old_node)
DECL_WEAK (new_decl) = 0;
}
- tree_function_versioning (old_decl, new_decl, NULL, false, NULL, false,
- NULL, NULL);
+ tree_function_versioning (old_decl, new_decl,
+ NULL, false, NULL,
+ false, NULL, NULL);
}
record_tm_clone_pair (old_decl, new_decl);
@@ -4970,13 +4969,13 @@ ipa_tm_transform_calls (struct cgraph_node *node, struct tm_region *region,
bool need_ssa_rename = false;
edge e;
edge_iterator ei;
- VEC(basic_block, heap) *queue = NULL;
+ vec<basic_block> queue = vec<basic_block>();
bitmap visited_blocks = BITMAP_ALLOC (NULL);
- VEC_safe_push (basic_block, heap, queue, bb);
+ queue.safe_push (bb);
do
{
- bb = VEC_pop (basic_block, queue);
+ bb = queue.pop ();
need_ssa_rename |=
ipa_tm_transform_calls_1 (node, region, bb, irr_blocks);
@@ -4991,12 +4990,12 @@ ipa_tm_transform_calls (struct cgraph_node *node, struct tm_region *region,
if (!bitmap_bit_p (visited_blocks, e->dest->index))
{
bitmap_set_bit (visited_blocks, e->dest->index);
- VEC_safe_push (basic_block, heap, queue, e->dest);
+ queue.safe_push (e->dest);
}
}
- while (!VEC_empty (basic_block, queue));
+ while (!queue.is_empty ());
- VEC_free (basic_block, heap, queue);
+ queue.release ();
BITMAP_FREE (visited_blocks);
return need_ssa_rename;
@@ -5073,9 +5072,9 @@ ipa_tm_transform_clone (struct cgraph_node *node)
static unsigned int
ipa_tm_execute (void)
{
- cgraph_node_queue tm_callees = NULL;
+ cgraph_node_queue tm_callees = cgraph_node_queue();
/* List of functions that will go irrevocable. */
- cgraph_node_queue irr_worklist = NULL;
+ cgraph_node_queue irr_worklist = cgraph_node_queue();
struct cgraph_node *node;
struct tm_ipa_cg_data *d;
@@ -5138,9 +5137,9 @@ ipa_tm_execute (void)
/* For every local function on the callee list, scan as if we will be
creating a transactional clone, queueing all new functions we find
along the way. */
- for (i = 0; i < VEC_length (cgraph_node_p, tm_callees); ++i)
+ for (i = 0; i < tm_callees.length (); ++i)
{
- node = VEC_index (cgraph_node_p, tm_callees, i);
+ node = tm_callees[i];
a = cgraph_function_body_availability (node);
d = get_cg_data (&node, true);
@@ -5180,19 +5179,19 @@ ipa_tm_execute (void)
}
/* Iterate scans until no more work to be done. Prefer not to use
- VEC_pop because the worklist tends to follow a breadth-first
+ vec::pop because the worklist tends to follow a breadth-first
search of the callgraph, which should allow convergance with a
minimum number of scans. But we also don't want the worklist
array to grow without bound, so we shift the array up periodically. */
- for (i = 0; i < VEC_length (cgraph_node_p, irr_worklist); ++i)
+ for (i = 0; i < irr_worklist.length (); ++i)
{
- if (i > 256 && i == VEC_length (cgraph_node_p, irr_worklist) / 8)
+ if (i > 256 && i == irr_worklist.length () / 8)
{
- VEC_block_remove (cgraph_node_p, irr_worklist, 0, i);
+ irr_worklist.block_remove (0, i);
i = 0;
}
- node = VEC_index (cgraph_node_p, irr_worklist, i);
+ node = irr_worklist[i];
d = get_cg_data (&node, true);
d->in_worklist = false;
@@ -5207,10 +5206,10 @@ ipa_tm_execute (void)
/* For every function on the callee list, collect the tm_may_enter_irr
bit on the node. */
- VEC_truncate (cgraph_node_p, irr_worklist, 0);
- for (i = 0; i < VEC_length (cgraph_node_p, tm_callees); ++i)
+ irr_worklist.truncate (0);
+ for (i = 0; i < tm_callees.length (); ++i)
{
- node = VEC_index (cgraph_node_p, tm_callees, i);
+ node = tm_callees[i];
if (ipa_tm_mayenterirr_function (node))
{
d = get_cg_data (&node, true);
@@ -5220,20 +5219,20 @@ ipa_tm_execute (void)
}
/* Propagate the tm_may_enter_irr bit to callers until stable. */
- for (i = 0; i < VEC_length (cgraph_node_p, irr_worklist); ++i)
+ for (i = 0; i < irr_worklist.length (); ++i)
{
struct cgraph_node *caller;
struct cgraph_edge *e;
struct ipa_ref *ref;
unsigned j;
- if (i > 256 && i == VEC_length (cgraph_node_p, irr_worklist) / 8)
+ if (i > 256 && i == irr_worklist.length () / 8)
{
- VEC_block_remove (cgraph_node_p, irr_worklist, 0, i);
+ irr_worklist.block_remove (0, i);
i = 0;
}
- node = VEC_index (cgraph_node_p, irr_worklist, i);
+ node = irr_worklist[i];
d = get_cg_data (&node, true);
d->in_worklist = false;
node->local.tm_may_enter_irr = true;
@@ -5280,11 +5279,11 @@ ipa_tm_execute (void)
/* Create clones. Do those that are not irrevocable and have a
positive call count. Do those publicly visible functions that
the user directed us to clone. */
- for (i = 0; i < VEC_length (cgraph_node_p, tm_callees); ++i)
+ for (i = 0; i < tm_callees.length (); ++i)
{
bool doit = false;
- node = VEC_index (cgraph_node_p, tm_callees, i);
+ node = tm_callees[i];
if (node->same_body_alias)
continue;
@@ -5304,9 +5303,9 @@ ipa_tm_execute (void)
}
/* Redirect calls to the new clones, and insert irrevocable marks. */
- for (i = 0; i < VEC_length (cgraph_node_p, tm_callees); ++i)
+ for (i = 0; i < tm_callees.length (); ++i)
{
- node = VEC_index (cgraph_node_p, tm_callees, i);
+ node = tm_callees[i];
if (node->analyzed)
{
d = get_cg_data (&node, true);
@@ -5324,8 +5323,8 @@ ipa_tm_execute (void)
}
/* Free and clear all data structures. */
- VEC_free (cgraph_node_p, heap, tm_callees);
- VEC_free (cgraph_node_p, heap, irr_worklist);
+ tm_callees.release ();
+ irr_worklist.release ();
bitmap_obstack_release (&tm_obstack);
free_original_copy_tables ();