summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-structalias.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-18 02:54:30 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-18 02:54:30 +0000
commitf1f41a6cdc47d5123dd30ab110cc35c90f8189cb (patch)
tree1b9f930d315fa3e0a5ed7fa6e27ec5bd0a3436a4 /gcc/tree-ssa-structalias.c
parent85ed3b5a235c79e565d04354e67c979abdc66057 (diff)
downloadgcc-f1f41a6cdc47d5123dd30ab110cc35c90f8189cb.tar.gz
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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193595 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r--gcc/tree-ssa-structalias.c593
1 files changed, 292 insertions, 301 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index e3fdeb6972c..787115ff340 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -218,8 +218,6 @@ static void unify_nodes (constraint_graph_t, unsigned int, unsigned int, bool);
struct constraint;
typedef struct constraint *constraint_t;
-DEF_VEC_P(constraint_t);
-DEF_VEC_ALLOC_P(constraint_t,heap);
#define EXECUTE_IF_IN_NONNULL_BITMAP(a, b, c, d) \
if (a) \
@@ -306,20 +304,18 @@ static inline bool type_can_have_subvars (const_tree);
/* Pool of variable info structures. */
static alloc_pool variable_info_pool;
-DEF_VEC_P(varinfo_t);
-DEF_VEC_ALLOC_P(varinfo_t, heap);
/* Table of variable info structures for constraint variables.
Indexed directly by variable info id. */
-static VEC(varinfo_t,heap) *varmap;
+static vec<varinfo_t> varmap;
/* Return the varmap element N */
static inline varinfo_t
get_varinfo (unsigned int n)
{
- return VEC_index (varinfo_t, varmap, n);
+ return varmap[n];
}
/* Static IDs for the special variables. */
@@ -334,7 +330,7 @@ enum { nothing_id = 0, anything_id = 1, readonly_id = 2,
static varinfo_t
new_var_info (tree t, const char *name)
{
- unsigned index = VEC_length (varinfo_t, varmap);
+ unsigned index = varmap.length ();
varinfo_t ret = (varinfo_t) pool_alloc (variable_info_pool);
ret->id = index;
@@ -362,7 +358,7 @@ new_var_info (tree t, const char *name)
stats.total_vars++;
- VEC_safe_push (varinfo_t, heap, varmap, ret);
+ varmap.safe_push (ret);
return ret;
}
@@ -471,12 +467,10 @@ struct constraint_expr
#define UNKNOWN_OFFSET ((HOST_WIDE_INT)-1 << (HOST_BITS_PER_WIDE_INT-1))
typedef struct constraint_expr ce_s;
-DEF_VEC_O(ce_s);
-DEF_VEC_ALLOC_O(ce_s, heap);
-static void get_constraint_for_1 (tree, VEC(ce_s, heap) **, bool, bool);
-static void get_constraint_for (tree, VEC(ce_s, heap) **);
-static void get_constraint_for_rhs (tree, VEC(ce_s, heap) **);
-static void do_deref (VEC (ce_s, heap) **);
+static void get_constraint_for_1 (tree, vec<ce_s> *, bool, bool);
+static void get_constraint_for (tree, vec<ce_s> *);
+static void get_constraint_for_rhs (tree, vec<ce_s> *);
+static void do_deref (vec<ce_s> *);
/* Our set constraints are made up of two constraint expressions, one
LHS, and one RHS.
@@ -492,7 +486,7 @@ struct constraint
/* List of constraints that we use to build the constraint graph from. */
-static VEC(constraint_t,heap) *constraints;
+static vec<constraint_t> constraints;
static alloc_pool constraint_pool;
/* The constraint graph is represented as an array of bitmaps
@@ -566,7 +560,7 @@ struct constraint_graph
/* Vector of complex constraints for each graph node. Complex
constraints are those involving dereferences or offsets that are
not 0. */
- VEC(constraint_t,heap) **complex;
+ vec<constraint_t> *complex;
};
static constraint_graph_t graph;
@@ -575,7 +569,7 @@ static constraint_graph_t graph;
cycle finding, we create nodes to represent dereferences and
address taken constraints. These represent where these start and
end. */
-#define FIRST_REF_NODE (VEC_length (varinfo_t, varmap))
+#define FIRST_REF_NODE (varmap).length ()
#define LAST_REF_NODE (FIRST_REF_NODE + (FIRST_REF_NODE - 1))
/* Return the representative node for NODE, if NODE has been unioned
@@ -670,7 +664,7 @@ dump_constraints (FILE *file, int from)
{
int i;
constraint_t c;
- for (i = from; VEC_iterate (constraint_t, constraints, i, c); i++)
+ for (i = from; constraints.iterate (i, &c); i++)
if (c)
{
dump_constraint (file, c);
@@ -714,12 +708,12 @@ dump_constraint_graph (FILE *file)
fprintf (file, "\"%s\"", get_varinfo (i)->name);
else
fprintf (file, "\"*%s\"", get_varinfo (i - FIRST_REF_NODE)->name);
- if (graph->complex[i])
+ if (graph->complex[i].exists ())
{
unsigned j;
constraint_t c;
fprintf (file, " [label=\"\\N\\n");
- for (j = 0; VEC_iterate (constraint_t, graph->complex[i], j, c); ++j)
+ for (j = 0; graph->complex[i].iterate (j, &c); ++j)
{
dump_constraint (file, c);
fprintf (file, "\\l");
@@ -849,19 +843,19 @@ constraint_equal (struct constraint a, struct constraint b)
/* Find a constraint LOOKFOR in the sorted constraint vector VEC */
static constraint_t
-constraint_vec_find (VEC(constraint_t,heap) *vec,
+constraint_vec_find (vec<constraint_t> vec,
struct constraint lookfor)
{
unsigned int place;
constraint_t found;
- if (vec == NULL)
+ if (!vec.exists ())
return NULL;
- place = VEC_lower_bound (constraint_t, vec, &lookfor, constraint_less);
- if (place >= VEC_length (constraint_t, vec))
+ place = vec.lower_bound (&lookfor, constraint_less);
+ if (place >= vec.length ())
return NULL;
- found = VEC_index (constraint_t, vec, place);
+ found = vec[place];
if (!constraint_equal (*found, lookfor))
return NULL;
return found;
@@ -870,19 +864,18 @@ constraint_vec_find (VEC(constraint_t,heap) *vec,
/* Union two constraint vectors, TO and FROM. Put the result in TO. */
static void
-constraint_set_union (VEC(constraint_t,heap) **to,
- VEC(constraint_t,heap) **from)
+constraint_set_union (vec<constraint_t> *to,
+ vec<constraint_t> *from)
{
int i;
constraint_t c;
- FOR_EACH_VEC_ELT (constraint_t, *from, i, c)
+ FOR_EACH_VEC_ELT (*from, i, c)
{
if (constraint_vec_find (*to, *c) == NULL)
{
- unsigned int place = VEC_lower_bound (constraint_t, *to, c,
- constraint_less);
- VEC_safe_insert (constraint_t, heap, *to, place, c);
+ unsigned int place = to->lower_bound (c, constraint_less);
+ to->safe_insert (place, c);
}
}
}
@@ -1009,14 +1002,13 @@ static void
insert_into_complex (constraint_graph_t graph,
unsigned int var, constraint_t c)
{
- VEC (constraint_t, heap) *complex = graph->complex[var];
- unsigned int place = VEC_lower_bound (constraint_t, complex, c,
- constraint_less);
+ vec<constraint_t> complex = graph->complex[var];
+ unsigned int place = complex.lower_bound (c, constraint_less);
/* Only insert constraints that do not already exist. */
- if (place >= VEC_length (constraint_t, complex)
- || !constraint_equal (*c, *VEC_index (constraint_t, complex, place)))
- VEC_safe_insert (constraint_t, heap, graph->complex[var], place, c);
+ if (place >= complex.length ()
+ || !constraint_equal (*c, *complex[place]))
+ graph->complex[var].safe_insert (place, c);
}
@@ -1033,7 +1025,7 @@ merge_node_constraints (constraint_graph_t graph, unsigned int to,
gcc_assert (find (from) == to);
/* Move all complex constraints from src node into to node */
- FOR_EACH_VEC_ELT (constraint_t, graph->complex[from], i, c)
+ FOR_EACH_VEC_ELT (graph->complex[from], i, c)
{
/* In complex constraints for node src, we may have either
a = *src, and *src = a, or an offseted constraint which are
@@ -1047,8 +1039,7 @@ merge_node_constraints (constraint_graph_t graph, unsigned int to,
c->rhs.var = to;
}
constraint_set_union (&graph->complex[to], &graph->complex[from]);
- VEC_free (constraint_t, heap, graph->complex[from]);
- graph->complex[from] = NULL;
+ graph->complex[from].release ();
}
@@ -1173,7 +1164,10 @@ init_graph (unsigned int size)
graph->succs = XCNEWVEC (bitmap, graph->size);
graph->indirect_cycles = XNEWVEC (int, graph->size);
graph->rep = XNEWVEC (unsigned int, graph->size);
- graph->complex = XCNEWVEC (VEC(constraint_t, heap) *, size);
+ /* ??? Macros do not support template types with multiple arguments,
+ so we use a typedef to work around it. */
+ typedef vec<constraint_t> vec_constraint_t_heap;
+ graph->complex = XCNEWVEC (vec_constraint_t_heap, size);
graph->pe = XCNEWVEC (unsigned int, graph->size);
graph->pe_rep = XNEWVEC (int, graph->size);
@@ -1214,10 +1208,10 @@ build_pred_graph (void)
for (j = 0; j < graph->size; j++)
graph->eq_rep[j] = -1;
- for (j = 0; j < VEC_length (varinfo_t, varmap); j++)
+ for (j = 0; j < varmap.length (); j++)
graph->indirect_cycles[j] = -1;
- FOR_EACH_VEC_ELT (constraint_t, constraints, i, c)
+ FOR_EACH_VEC_ELT (constraints, i, c)
{
struct constraint_expr lhs = c->lhs;
struct constraint_expr rhs = c->rhs;
@@ -1296,7 +1290,7 @@ build_succ_graph (void)
unsigned i, t;
constraint_t c;
- FOR_EACH_VEC_ELT (constraint_t, constraints, i, c)
+ FOR_EACH_VEC_ELT (constraints, i, c)
{
struct constraint_expr lhs;
struct constraint_expr rhs;
@@ -1361,7 +1355,7 @@ struct scc_info
unsigned int *dfs;
unsigned int *node_mapping;
int current_index;
- VEC(unsigned,heap) *scc_stack;
+ vec<unsigned> scc_stack;
};
@@ -1414,8 +1408,8 @@ scc_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
/* See if any components have been identified. */
if (si->dfs[n] == my_dfs)
{
- if (VEC_length (unsigned, si->scc_stack) > 0
- && si->dfs[VEC_last (unsigned, si->scc_stack)] >= my_dfs)
+ if (si->scc_stack.length () > 0
+ && si->dfs[si->scc_stack.last ()] >= my_dfs)
{
bitmap scc = BITMAP_ALLOC (NULL);
unsigned int lowest_node;
@@ -1423,10 +1417,10 @@ scc_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
bitmap_set_bit (scc, n);
- while (VEC_length (unsigned, si->scc_stack) != 0
- && si->dfs[VEC_last (unsigned, si->scc_stack)] >= my_dfs)
+ while (si->scc_stack.length () != 0
+ && si->dfs[si->scc_stack.last ()] >= my_dfs)
{
- unsigned int w = VEC_pop (unsigned, si->scc_stack);
+ unsigned int w = si->scc_stack.pop ();
bitmap_set_bit (scc, w);
}
@@ -1453,7 +1447,7 @@ scc_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
bitmap_set_bit (si->deleted, n);
}
else
- VEC_safe_push (unsigned, heap, si->scc_stack, n);
+ si->scc_stack.safe_push (n);
}
/* Unify node FROM into node TO, updating the changed count if
@@ -1521,7 +1515,7 @@ struct topo_info
sbitmap visited;
/* Array that stores the topological order of the graph, *in
reverse*. */
- VEC(unsigned,heap) *topo_order;
+ vec<unsigned> topo_order;
};
@@ -1534,7 +1528,7 @@ init_topo_info (void)
struct topo_info *ti = XNEW (struct topo_info);
ti->visited = sbitmap_alloc (size);
bitmap_clear (ti->visited);
- ti->topo_order = VEC_alloc (unsigned, heap, 1);
+ ti->topo_order.create (1);
return ti;
}
@@ -1545,7 +1539,7 @@ static void
free_topo_info (struct topo_info *ti)
{
sbitmap_free (ti->visited);
- VEC_free (unsigned, heap, ti->topo_order);
+ ti->topo_order.release ();
free (ti);
}
@@ -1568,7 +1562,7 @@ topo_visit (constraint_graph_t graph, struct topo_info *ti,
topo_visit (graph, ti, j);
}
- VEC_safe_push (unsigned, heap, ti->topo_order, n);
+ ti->topo_order.safe_push (n);
}
/* Process a constraint C that represents x = *(y + off), using DELTA as the
@@ -1820,7 +1814,7 @@ init_scc_info (size_t size)
for (i = 0; i < size; i++)
si->node_mapping[i] = i;
- si->scc_stack = VEC_alloc (unsigned, heap, 1);
+ si->scc_stack.create (1);
return si;
}
@@ -1833,7 +1827,7 @@ free_scc_info (struct scc_info *si)
sbitmap_free (si->deleted);
free (si->node_mapping);
free (si->dfs);
- VEC_free (unsigned, heap, si->scc_stack);
+ si->scc_stack.release ();
free (si);
}
@@ -2061,10 +2055,10 @@ condense_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
/* See if any components have been identified. */
if (si->dfs[n] == my_dfs)
{
- while (VEC_length (unsigned, si->scc_stack) != 0
- && si->dfs[VEC_last (unsigned, si->scc_stack)] >= my_dfs)
+ while (si->scc_stack.length () != 0
+ && si->dfs[si->scc_stack.last ()] >= my_dfs)
{
- unsigned int w = VEC_pop (unsigned, si->scc_stack);
+ unsigned int w = si->scc_stack.pop ();
si->node_mapping[w] = n;
if (!bitmap_bit_p (graph->direct_nodes, w))
@@ -2095,7 +2089,7 @@ condense_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
bitmap_set_bit (si->deleted, n);
}
else
- VEC_safe_push (unsigned, heap, si->scc_stack, n);
+ si->scc_stack.safe_push (n);
}
/* Label pointer equivalences. */
@@ -2342,7 +2336,7 @@ move_complex_constraints (constraint_graph_t graph)
int i;
constraint_t c;
- FOR_EACH_VEC_ELT (constraint_t, constraints, i, c)
+ FOR_EACH_VEC_ELT (constraints, i, c)
{
if (c)
{
@@ -2383,7 +2377,7 @@ rewrite_constraints (constraint_graph_t graph,
for (j = 0; j < graph->size; j++)
gcc_assert (find (j) == j);
- FOR_EACH_VEC_ELT (constraint_t, constraints, i, c)
+ FOR_EACH_VEC_ELT (constraints, i, c)
{
struct constraint_expr lhs = c->lhs;
struct constraint_expr rhs = c->rhs;
@@ -2410,7 +2404,7 @@ rewrite_constraints (constraint_graph_t graph,
dump_constraint (dump_file, c);
fprintf (dump_file, "\n");
}
- VEC_replace (constraint_t, constraints, i, NULL);
+ constraints[i] = NULL;
continue;
}
@@ -2425,7 +2419,7 @@ rewrite_constraints (constraint_graph_t graph,
dump_constraint (dump_file, c);
fprintf (dump_file, "\n");
}
- VEC_replace (constraint_t, constraints, i, NULL);
+ constraints[i] = NULL;
continue;
}
@@ -2447,7 +2441,7 @@ eliminate_indirect_cycles (unsigned int node)
&& !bitmap_empty_p (get_varinfo (node)->solution))
{
unsigned int i;
- VEC(unsigned,heap) *queue = NULL;
+ vec<unsigned> queue = vec<unsigned>();
int queuepos;
unsigned int to = find (graph->indirect_cycles[node]);
bitmap_iterator bi;
@@ -2461,17 +2455,17 @@ eliminate_indirect_cycles (unsigned int node)
if (find (i) == i && i != to)
{
if (unite (to, i))
- VEC_safe_push (unsigned, heap, queue, i);
+ queue.safe_push (i);
}
}
for (queuepos = 0;
- VEC_iterate (unsigned, queue, queuepos, i);
+ queue.iterate (queuepos, &i);
queuepos++)
{
unify_nodes (graph, to, i, true);
}
- VEC_free (unsigned, heap, queue);
+ queue.release ();
return true;
}
return false;
@@ -2499,7 +2493,7 @@ solve_graph (constraint_graph_t graph)
varinfo_t ivi = get_varinfo (i);
if (find (i) == i && !bitmap_empty_p (ivi->solution)
&& ((graph->succs[i] && !bitmap_empty_p (graph->succs[i]))
- || VEC_length (constraint_t, graph->complex[i]) > 0))
+ || graph->complex[i].length () > 0))
bitmap_set_bit (changed, i);
}
@@ -2516,10 +2510,10 @@ solve_graph (constraint_graph_t graph)
compute_topo_order (graph, ti);
- while (VEC_length (unsigned, ti->topo_order) != 0)
+ while (ti->topo_order.length () != 0)
{
- i = VEC_pop (unsigned, ti->topo_order);
+ i = ti->topo_order.pop ();
/* If this variable is not a representative, skip it. */
if (find (i) != i)
@@ -2537,7 +2531,7 @@ solve_graph (constraint_graph_t graph)
unsigned int j;
constraint_t c;
bitmap solution;
- VEC(constraint_t,heap) *complex = graph->complex[i];
+ vec<constraint_t> complex = graph->complex[i];
varinfo_t vi = get_varinfo (i);
bool solution_empty;
@@ -2562,7 +2556,7 @@ solve_graph (constraint_graph_t graph)
solution_empty = bitmap_empty_p (solution);
/* Process the complex constraints */
- FOR_EACH_VEC_ELT (constraint_t, complex, j, c)
+ FOR_EACH_VEC_ELT (complex, j, c)
{
/* XXX: This is going to unsort the constraints in
some cases, which will occasionally add duplicate
@@ -2741,7 +2735,7 @@ new_scalar_tmp_constraint_exp (const char *name)
If address_p is true, the result will be taken its address of. */
static void
-get_constraint_for_ssa_var (tree t, VEC(ce_s, heap) **results, bool address_p)
+get_constraint_for_ssa_var (tree t, vec<ce_s> *results, bool address_p)
{
struct constraint_expr cexpr;
varinfo_t vi;
@@ -2793,12 +2787,12 @@ get_constraint_for_ssa_var (tree t, VEC(ce_s, heap) **results, bool address_p)
for (; vi; vi = vi->next)
{
cexpr.var = vi->id;
- VEC_safe_push (ce_s, heap, *results, cexpr);
+ results->safe_push (cexpr);
}
return;
}
- VEC_safe_push (ce_s, heap, *results, cexpr);
+ results->safe_push (cexpr);
}
/* Process constraint T, performing various simplifications and then
@@ -2810,8 +2804,8 @@ process_constraint (constraint_t t)
struct constraint_expr rhs = t->rhs;
struct constraint_expr lhs = t->lhs;
- gcc_assert (rhs.var < VEC_length (varinfo_t, varmap));
- gcc_assert (lhs.var < VEC_length (varinfo_t, varmap));
+ gcc_assert (rhs.var < varmap.length ());
+ gcc_assert (lhs.var < varmap.length ());
/* If we didn't get any useful constraint from the lhs we get
&ANYTHING as fallback from get_constraint_for. Deal with
@@ -2853,7 +2847,7 @@ process_constraint (constraint_t t)
else
{
gcc_assert (rhs.type != ADDRESSOF || rhs.offset == 0);
- VEC_safe_push (constraint_t, heap, constraints, t);
+ constraints.safe_push (t);
}
}
@@ -2878,7 +2872,7 @@ bitpos_of_field (const tree fdecl)
static void
get_constraint_for_ptr_offset (tree ptr, tree offset,
- VEC (ce_s, heap) **results)
+ vec<ce_s> *results)
{
struct constraint_expr c;
unsigned int j, n;
@@ -2921,12 +2915,12 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
return;
/* As we are eventually appending to the solution do not use
- VEC_iterate here. */
- n = VEC_length (ce_s, *results);
+ vec::iterate here. */
+ n = results->length ();
for (j = 0; j < n; j++)
{
varinfo_t curr;
- c = VEC_index (ce_s, *results, j);
+ c = (*results)[j];
curr = get_varinfo (c.var);
if (c.type == ADDRESSOF
@@ -2945,7 +2939,7 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
c2.type = ADDRESSOF;
c2.offset = 0;
if (c2.var != c.var)
- VEC_safe_push (ce_s, heap, *results, c2);
+ results->safe_push (c2);
temp = temp->next;
}
while (temp);
@@ -2980,7 +2974,7 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
c2.var = temp->next->id;
c2.type = ADDRESSOF;
c2.offset = 0;
- VEC_safe_push (ce_s, heap, *results, c2);
+ results->safe_push (c2);
}
c.var = temp->id;
c.offset = 0;
@@ -2988,7 +2982,7 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
else
c.offset = rhsoffset;
- VEC_replace (ce_s, *results, j, c);
+ (*results)[j] = c;
}
}
@@ -2999,7 +2993,7 @@ get_constraint_for_ptr_offset (tree ptr, tree offset,
as the lhs. */
static void
-get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
+get_constraint_for_component_ref (tree t, vec<ce_s> *results,
bool address_p, bool lhs_p)
{
tree orig_t = t;
@@ -3007,7 +3001,6 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
HOST_WIDE_INT bitmaxsize = -1;
HOST_WIDE_INT bitpos;
tree forzero;
- struct constraint_expr *result;
/* Some people like to do cute things like take the address of
&0->a.b */
@@ -3024,7 +3017,7 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
temp.offset = 0;
temp.var = integer_id;
temp.type = SCALAR;
- VEC_safe_push (ce_s, heap, *results, temp);
+ results->safe_push (temp);
return;
}
@@ -3046,7 +3039,7 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
temp.offset = 0;
temp.var = anything_id;
temp.type = ADDRESSOF;
- VEC_safe_push (ce_s, heap, *results, temp);
+ results->safe_push (temp);
return;
}
}
@@ -3056,30 +3049,30 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
/* Pretend to take the address of the base, we'll take care of
adding the required subset of sub-fields below. */
get_constraint_for_1 (t, results, true, lhs_p);
- gcc_assert (VEC_length (ce_s, *results) == 1);
- result = &VEC_last (ce_s, *results);
+ gcc_assert (results->length () == 1);
+ struct constraint_expr &result = results->last ();
- if (result->type == SCALAR
- && get_varinfo (result->var)->is_full_var)
+ if (result.type == SCALAR
+ && get_varinfo (result.var)->is_full_var)
/* For single-field vars do not bother about the offset. */
- result->offset = 0;
- else if (result->type == SCALAR)
+ result.offset = 0;
+ else if (result.type == SCALAR)
{
/* In languages like C, you can access one past the end of an
array. You aren't allowed to dereference it, so we can
ignore this constraint. When we handle pointer subtraction,
we may have to do something cute here. */
- if ((unsigned HOST_WIDE_INT)bitpos < get_varinfo (result->var)->fullsize
+ if ((unsigned HOST_WIDE_INT)bitpos < get_varinfo (result.var)->fullsize
&& bitmaxsize != 0)
{
/* It's also not true that the constraint will actually start at the
right offset, it may start in some padding. We only care about
setting the constraint to the first actual field it touches, so
walk to find it. */
- struct constraint_expr cexpr = *result;
+ struct constraint_expr cexpr = result;
varinfo_t curr;
- VEC_pop (ce_s, *results);
+ results->pop ();
cexpr.offset = 0;
for (curr = get_varinfo (cexpr.var); curr; curr = curr->next)
{
@@ -3087,7 +3080,7 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
bitpos, bitmaxsize))
{
cexpr.var = curr->id;
- VEC_safe_push (ce_s, heap, *results, cexpr);
+ results->safe_push (cexpr);
if (address_p)
break;
}
@@ -3095,16 +3088,15 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
/* If we are going to take the address of this field then
to be able to compute reachability correctly add at least
the last field of the variable. */
- if (address_p
- && VEC_length (ce_s, *results) == 0)
+ if (address_p && results->length () == 0)
{
curr = get_varinfo (cexpr.var);
while (curr->next != NULL)
curr = curr->next;
cexpr.var = curr->id;
- VEC_safe_push (ce_s, heap, *results, cexpr);
+ results->safe_push (cexpr);
}
- else if (VEC_length (ce_s, *results) == 0)
+ else if (results->length () == 0)
/* Assert that we found *some* field there. The user couldn't be
accessing *only* padding. */
/* Still the user could access one past the end of an array
@@ -3115,7 +3107,7 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
cexpr.type = SCALAR;
cexpr.var = anything_id;
cexpr.offset = 0;
- VEC_safe_push (ce_s, heap, *results, cexpr);
+ results->safe_push (cexpr);
}
}
else if (bitmaxsize == 0)
@@ -3128,7 +3120,7 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Access to past the end of variable, ignoring\n");
}
- else if (result->type == DEREF)
+ else if (result.type == DEREF)
{
/* If we do not know exactly where the access goes say so. Note
that only for non-structure accesses we know that we access
@@ -3136,18 +3128,18 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
if (bitpos == -1
|| bitsize != bitmaxsize
|| AGGREGATE_TYPE_P (TREE_TYPE (orig_t))
- || result->offset == UNKNOWN_OFFSET)
- result->offset = UNKNOWN_OFFSET;
+ || result.offset == UNKNOWN_OFFSET)
+ result.offset = UNKNOWN_OFFSET;
else
- result->offset += bitpos;
+ result.offset += bitpos;
}
- else if (result->type == ADDRESSOF)
+ else if (result.type == ADDRESSOF)
{
/* We can end up here for component references on a
VIEW_CONVERT_EXPR <>(&foobar). */
- result->type = SCALAR;
- result->var = anything_id;
- result->offset = 0;
+ result.type = SCALAR;
+ result.var = anything_id;
+ result.offset = 0;
}
else
gcc_unreachable ();
@@ -3161,12 +3153,12 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
This is needed so that we can handle dereferencing DEREF constraints. */
static void
-do_deref (VEC (ce_s, heap) **constraints)
+do_deref (vec<ce_s> *constraints)
{
struct constraint_expr *c;
unsigned int i = 0;
- FOR_EACH_VEC_ELT (ce_s, *constraints, i, c)
+ FOR_EACH_VEC_ELT (*constraints, i, c)
{
if (c->type == SCALAR)
c->type = DEREF;
@@ -3188,14 +3180,14 @@ do_deref (VEC (ce_s, heap) **constraints)
address of it. */
static void
-get_constraint_for_address_of (tree t, VEC (ce_s, heap) **results)
+get_constraint_for_address_of (tree t, vec<ce_s> *results)
{
struct constraint_expr *c;
unsigned int i;
get_constraint_for_1 (t, results, true, true);
- FOR_EACH_VEC_ELT (ce_s, *results, i, c)
+ FOR_EACH_VEC_ELT (*results, i, c)
{
if (c->type == DEREF)
c->type = SCALAR;
@@ -3207,7 +3199,7 @@ get_constraint_for_address_of (tree t, VEC (ce_s, heap) **results)
/* Given a tree T, return the constraint expression for it. */
static void
-get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
+get_constraint_for_1 (tree t, vec<ce_s> *results, bool address_p,
bool lhs_p)
{
struct constraint_expr temp;
@@ -3239,7 +3231,7 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
temp.var = nonlocal_id;
temp.type = ADDRESSOF;
temp.offset = 0;
- VEC_safe_push (ce_s, heap, *results, temp);
+ results->safe_push (temp);
return;
}
@@ -3249,7 +3241,7 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
temp.var = readonly_id;
temp.type = SCALAR;
temp.offset = 0;
- VEC_safe_push (ce_s, heap, *results, temp);
+ results->safe_push (temp);
return;
}
@@ -3283,13 +3275,13 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
if (address_p)
return;
- cs = VEC_last (ce_s, *results);
+ cs = results->last ();
if (cs.type == DEREF
&& type_can_have_subvars (TREE_TYPE (t)))
{
/* For dereferences this means we have to defer it
to solving time. */
- VEC_last (ce_s, *results).offset = UNKNOWN_OFFSET;
+ results->last ().offset = UNKNOWN_OFFSET;
return;
}
if (cs.type != SCALAR)
@@ -3310,7 +3302,7 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
if (curr->offset - vi->offset < size)
{
cs.var = curr->id;
- VEC_safe_push (ce_s, heap, *results, cs);
+ results->safe_push (cs);
}
else
break;
@@ -3345,17 +3337,17 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
{
unsigned int i;
tree val;
- VEC (ce_s, heap) *tmp = NULL;
+ vec<ce_s> tmp = vec<ce_s>();
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), i, val)
{
struct constraint_expr *rhsp;
unsigned j;
get_constraint_for_1 (val, &tmp, address_p, lhs_p);
- FOR_EACH_VEC_ELT (ce_s, tmp, j, rhsp)
- VEC_safe_push (ce_s, heap, *results, *rhsp);
- VEC_truncate (ce_s, tmp, 0);
+ FOR_EACH_VEC_ELT (tmp, j, rhsp)
+ results->safe_push (*rhsp);
+ tmp.truncate (0);
}
- VEC_free (ce_s, heap, tmp);
+ tmp.release ();
/* We do not know whether the constructor was complete,
so technically we have to add &NOTHING or &ANYTHING
like we do for an empty constructor as well. */
@@ -3376,7 +3368,7 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
temp.type = ADDRESSOF;
temp.var = nonlocal_id;
temp.offset = 0;
- VEC_safe_push (ce_s, heap, *results, temp);
+ results->safe_push (temp);
return;
}
default:;
@@ -3386,15 +3378,15 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
temp.type = ADDRESSOF;
temp.var = anything_id;
temp.offset = 0;
- VEC_safe_push (ce_s, heap, *results, temp);
+ results->safe_push (temp);
}
/* Given a gimple tree T, return the constraint expression vector for it. */
static void
-get_constraint_for (tree t, VEC (ce_s, heap) **results)
+get_constraint_for (tree t, vec<ce_s> *results)
{
- gcc_assert (VEC_length (ce_s, *results) == 0);
+ gcc_assert (results->length () == 0);
get_constraint_for_1 (t, results, false, true);
}
@@ -3403,9 +3395,9 @@ get_constraint_for (tree t, VEC (ce_s, heap) **results)
to be used as the rhs of a constraint. */
static void
-get_constraint_for_rhs (tree t, VEC (ce_s, heap) **results)
+get_constraint_for_rhs (tree t, vec<ce_s> *results)
{
- gcc_assert (VEC_length (ce_s, *results) == 0);
+ gcc_assert (results->length () == 0);
get_constraint_for_1 (t, results, false, false);
}
@@ -3415,25 +3407,25 @@ get_constraint_for_rhs (tree t, VEC (ce_s, heap) **results)
entries in *LHSC. */
static void
-process_all_all_constraints (VEC (ce_s, heap) *lhsc, VEC (ce_s, heap) *rhsc)
+process_all_all_constraints (vec<ce_s> lhsc,
+ vec<ce_s> rhsc)
{
struct constraint_expr *lhsp, *rhsp;
unsigned i, j;
- if (VEC_length (ce_s, lhsc) <= 1
- || VEC_length (ce_s, rhsc) <= 1)
+ if (lhsc.length () <= 1 || rhsc.length () <= 1)
{
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
- FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
+ FOR_EACH_VEC_ELT (lhsc, i, lhsp)
+ FOR_EACH_VEC_ELT (rhsc, j, rhsp)
process_constraint (new_constraint (*lhsp, *rhsp));
}
else
{
struct constraint_expr tmp;
tmp = new_scalar_tmp_constraint_exp ("allalltmp");
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (tmp, *rhsp));
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, i, lhsp)
process_constraint (new_constraint (*lhsp, tmp));
}
}
@@ -3445,25 +3437,26 @@ static void
do_structure_copy (tree lhsop, tree rhsop)
{
struct constraint_expr *lhsp, *rhsp;
- VEC (ce_s, heap) *lhsc = NULL, *rhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
+ vec<ce_s> rhsc = vec<ce_s>();
unsigned j;
get_constraint_for (lhsop, &lhsc);
get_constraint_for_rhs (rhsop, &rhsc);
- lhsp = &VEC_index (ce_s, lhsc, 0);
- rhsp = &VEC_index (ce_s, rhsc, 0);
+ lhsp = &lhsc[0];
+ rhsp = &rhsc[0];
if (lhsp->type == DEREF
|| (lhsp->type == ADDRESSOF && lhsp->var == anything_id)
|| rhsp->type == DEREF)
{
if (lhsp->type == DEREF)
{
- gcc_assert (VEC_length (ce_s, lhsc) == 1);
+ gcc_assert (lhsc.length () == 1);
lhsp->offset = UNKNOWN_OFFSET;
}
if (rhsp->type == DEREF)
{
- gcc_assert (VEC_length (ce_s, rhsc) == 1);
+ gcc_assert (rhsc.length () == 1);
rhsp->offset = UNKNOWN_OFFSET;
}
process_all_all_constraints (lhsc, rhsc);
@@ -3477,10 +3470,10 @@ do_structure_copy (tree lhsop, tree rhsop)
unsigned k = 0;
get_ref_base_and_extent (lhsop, &lhsoffset, &lhssize, &lhsmaxsize);
get_ref_base_and_extent (rhsop, &rhsoffset, &rhssize, &rhsmaxsize);
- for (j = 0; VEC_iterate (ce_s, lhsc, j, lhsp);)
+ for (j = 0; lhsc.iterate (j, &lhsp);)
{
varinfo_t lhsv, rhsv;
- rhsp = &VEC_index (ce_s, rhsc, k);
+ rhsp = &rhsc[k];
lhsv = get_varinfo (lhsp->var);
rhsv = get_varinfo (rhsp->var);
if (lhsv->may_have_pointers
@@ -3495,7 +3488,7 @@ do_structure_copy (tree lhsop, tree rhsop)
> rhsv->offset + lhsoffset + rhsv->size)))
{
++k;
- if (k >= VEC_length (ce_s, rhsc))
+ if (k >= rhsc.length ())
break;
}
else
@@ -3505,14 +3498,14 @@ do_structure_copy (tree lhsop, tree rhsop)
else
gcc_unreachable ();
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
}
/* Create constraints ID = { rhsc }. */
static void
-make_constraints_to (unsigned id, VEC(ce_s, heap) *rhsc)
+make_constraints_to (unsigned id, vec<ce_s> rhsc)
{
struct constraint_expr *c;
struct constraint_expr includes;
@@ -3522,7 +3515,7 @@ make_constraints_to (unsigned id, VEC(ce_s, heap) *rhsc)
includes.offset = 0;
includes.type = SCALAR;
- FOR_EACH_VEC_ELT (ce_s, rhsc, j, c)
+ FOR_EACH_VEC_ELT (rhsc, j, c)
process_constraint (new_constraint (includes, *c));
}
@@ -3531,10 +3524,10 @@ make_constraints_to (unsigned id, VEC(ce_s, heap) *rhsc)
static void
make_constraint_to (unsigned id, tree op)
{
- VEC(ce_s, heap) *rhsc = NULL;
+ vec<ce_s> rhsc = vec<ce_s>();
get_constraint_for_rhs (op, &rhsc);
make_constraints_to (id, rhsc);
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
/* Create a constraint ID = &FROM. */
@@ -3725,7 +3718,7 @@ get_function_part_constraint (varinfo_t fi, unsigned part)
RHS. */
static void
-handle_rhs_call (gimple stmt, VEC(ce_s, heap) **results)
+handle_rhs_call (gimple stmt, vec<ce_s> *results)
{
struct constraint_expr rhsc;
unsigned i;
@@ -3793,7 +3786,7 @@ handle_rhs_call (gimple stmt, VEC(ce_s, heap) **results)
rhsc.var = get_call_use_vi (stmt)->id;
rhsc.offset = 0;
rhsc.type = SCALAR;
- VEC_safe_push (ce_s, heap, *results, rhsc);
+ results->safe_push (rhsc);
}
/* The static chain escapes as well. */
@@ -3805,22 +3798,22 @@ handle_rhs_call (gimple stmt, VEC(ce_s, heap) **results)
&& gimple_call_lhs (stmt) != NULL_TREE
&& TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt))))
{
- VEC(ce_s, heap) *tmpc = NULL;
+ vec<ce_s> tmpc = vec<ce_s>();
struct constraint_expr lhsc, *c;
get_constraint_for_address_of (gimple_call_lhs (stmt), &tmpc);
lhsc.var = escaped_id;
lhsc.offset = 0;
lhsc.type = SCALAR;
- FOR_EACH_VEC_ELT (ce_s, tmpc, i, c)
+ FOR_EACH_VEC_ELT (tmpc, i, c)
process_constraint (new_constraint (lhsc, *c));
- VEC_free(ce_s, heap, tmpc);
+ tmpc.release ();
}
/* Regular functions return nonlocal memory. */
rhsc.var = nonlocal_id;
rhsc.offset = 0;
rhsc.type = SCALAR;
- VEC_safe_push (ce_s, heap, *results, rhsc);
+ results->safe_push (rhsc);
}
/* For non-IPA mode, generate constraints necessary for a call
@@ -3828,10 +3821,10 @@ handle_rhs_call (gimple stmt, VEC(ce_s, heap) **results)
the LHS point to global and escaped variables. */
static void
-handle_lhs_call (gimple stmt, tree lhs, int flags, VEC(ce_s, heap) *rhsc,
+handle_lhs_call (gimple stmt, tree lhs, int flags, vec<ce_s> rhsc,
tree fndecl)
{
- VEC(ce_s, heap) *lhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
get_constraint_for (lhs, &lhsc);
/* If the store is to a global decl make sure to
@@ -3845,7 +3838,7 @@ handle_lhs_call (gimple stmt, tree lhs, int flags, VEC(ce_s, heap) *rhsc,
tmpc.var = escaped_id;
tmpc.offset = 0;
tmpc.type = SCALAR;
- VEC_safe_push (ce_s, heap, lhsc, tmpc);
+ lhsc.safe_push (tmpc);
}
/* If the call returns an argument unmodified override the rhs
@@ -3855,17 +3848,17 @@ handle_lhs_call (gimple stmt, tree lhs, int flags, VEC(ce_s, heap) *rhsc,
&& (flags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (stmt))
{
tree arg;
- rhsc = NULL;
+ rhsc.create (0);
arg = gimple_call_arg (stmt, flags & ERF_RETURN_ARG_MASK);
get_constraint_for (arg, &rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
else if (flags & ERF_NOALIAS)
{
varinfo_t vi;
struct constraint_expr tmpc;
- rhsc = NULL;
+ rhsc.create (0);
vi = make_heapvar ("HEAP");
/* We delay marking allocated storage global until we know if
it escapes. */
@@ -3880,21 +3873,21 @@ handle_lhs_call (gimple stmt, tree lhs, int flags, VEC(ce_s, heap) *rhsc,
tmpc.var = vi->id;
tmpc.offset = 0;
tmpc.type = ADDRESSOF;
- VEC_safe_push (ce_s, heap, rhsc, tmpc);
+ rhsc.safe_push (tmpc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
else
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
+ lhsc.release ();
}
/* For non-IPA mode, generate constraints necessary for a call of a
const function that returns a pointer in the statement STMT. */
static void
-handle_const_call (gimple stmt, VEC(ce_s, heap) **results)
+handle_const_call (gimple stmt, vec<ce_s> *results)
{
struct constraint_expr rhsc;
unsigned int k;
@@ -3909,34 +3902,34 @@ handle_const_call (gimple stmt, VEC(ce_s, heap) **results)
rhsc.var = uses->id;
rhsc.offset = 0;
rhsc.type = SCALAR;
- VEC_safe_push (ce_s, heap, *results, rhsc);
+ results->safe_push (rhsc);
}
/* May return arguments. */
for (k = 0; k < gimple_call_num_args (stmt); ++k)
{
tree arg = gimple_call_arg (stmt, k);
- VEC(ce_s, heap) *argc = NULL;
+ vec<ce_s> argc = vec<ce_s>();
unsigned i;
struct constraint_expr *argp;
get_constraint_for_rhs (arg, &argc);
- FOR_EACH_VEC_ELT (ce_s, argc, i, argp)
- VEC_safe_push (ce_s, heap, *results, *argp);
- VEC_free(ce_s, heap, argc);
+ FOR_EACH_VEC_ELT (argc, i, argp)
+ results->safe_push (*argp);
+ argc.release ();
}
/* May return addresses of globals. */
rhsc.var = nonlocal_id;
rhsc.offset = 0;
rhsc.type = ADDRESSOF;
- VEC_safe_push (ce_s, heap, *results, rhsc);
+ results->safe_push (rhsc);
}
/* For non-IPA mode, generate constraints necessary for a call to a
pure function in statement STMT. */
static void
-handle_pure_call (gimple stmt, VEC(ce_s, heap) **results)
+handle_pure_call (gimple stmt, vec<ce_s> *results)
{
struct constraint_expr rhsc;
unsigned i;
@@ -3971,12 +3964,12 @@ handle_pure_call (gimple stmt, VEC(ce_s, heap) **results)
rhsc.var = uses->id;
rhsc.offset = 0;
rhsc.type = SCALAR;
- VEC_safe_push (ce_s, heap, *results, rhsc);
+ results->safe_push (rhsc);
}
rhsc.var = nonlocal_id;
rhsc.offset = 0;
rhsc.type = SCALAR;
- VEC_safe_push (ce_s, heap, *results, rhsc);
+ results->safe_push (rhsc);
}
@@ -4017,8 +4010,8 @@ static bool
find_func_aliases_for_builtin_call (gimple t)
{
tree fndecl = gimple_call_fndecl (t);
- VEC(ce_s, heap) *lhsc = NULL;
- VEC(ce_s, heap) *rhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
+ vec<ce_s> rhsc = vec<ce_s>();
varinfo_t fi;
if (fndecl != NULL_TREE
@@ -4072,16 +4065,16 @@ find_func_aliases_for_builtin_call (gimple t)
else
get_constraint_for (dest, &rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
}
get_constraint_for_ptr_offset (dest, NULL_TREE, &lhsc);
get_constraint_for_ptr_offset (src, NULL_TREE, &rhsc);
do_deref (&lhsc);
do_deref (&rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
return true;
}
case BUILT_IN_MEMSET:
@@ -4098,8 +4091,8 @@ find_func_aliases_for_builtin_call (gimple t)
get_constraint_for (res, &lhsc);
get_constraint_for (dest, &rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
}
get_constraint_for_ptr_offset (dest, NULL_TREE, &lhsc);
do_deref (&lhsc);
@@ -4115,9 +4108,9 @@ find_func_aliases_for_builtin_call (gimple t)
ac.var = integer_id;
}
ac.offset = 0;
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, i, lhsp)
process_constraint (new_constraint (*lhsp, ac));
- VEC_free (ce_s, heap, lhsc);
+ lhsc.release ();
return true;
}
case BUILT_IN_ASSUME_ALIGNED:
@@ -4129,8 +4122,8 @@ find_func_aliases_for_builtin_call (gimple t)
get_constraint_for (res, &lhsc);
get_constraint_for (dest, &rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
}
return true;
}
@@ -4162,7 +4155,7 @@ find_func_aliases_for_builtin_call (gimple t)
if (gimple_call_lhs (t))
{
handle_lhs_call (t, gimple_call_lhs (t), gimple_call_flags (t),
- NULL, fndecl);
+ vec<ce_s>(), fndecl);
get_constraint_for_ptr_offset (gimple_call_lhs (t),
NULL_TREE, &lhsc);
get_constraint_for_ptr_offset (gimple_call_arg (t, 0),
@@ -4170,8 +4163,8 @@ find_func_aliases_for_builtin_call (gimple t)
do_deref (&lhsc);
do_deref (&rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
return true;
}
break;
@@ -4193,9 +4186,9 @@ find_func_aliases_for_builtin_call (gimple t)
{
lhs = get_function_part_constraint (nfi, fi_static_chain);
get_constraint_for (frame, &rhsc);
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
/* Make the frame point to the function for
the trampoline adjustment call. */
@@ -4203,8 +4196,8 @@ find_func_aliases_for_builtin_call (gimple t)
do_deref (&lhsc);
get_constraint_for (nfunc, &rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, rhsc);
- VEC_free (ce_s, heap, lhsc);
+ rhsc.release ();
+ lhsc.release ();
return true;
}
@@ -4223,8 +4216,8 @@ find_func_aliases_for_builtin_call (gimple t)
get_constraint_for (tramp, &rhsc);
do_deref (&rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, rhsc);
- VEC_free (ce_s, heap, lhsc);
+ rhsc.release ();
+ lhsc.release ();
}
return true;
}
@@ -4246,8 +4239,8 @@ find_func_aliases_for_builtin_call (gimple t)
do_deref (&lhsc);
get_constraint_for (src, &rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
return true;
}
CASE_BUILT_IN_TM_LOAD (1):
@@ -4268,8 +4261,8 @@ find_func_aliases_for_builtin_call (gimple t)
get_constraint_for (addr, &rhsc);
do_deref (&rhsc);
process_all_all_constraints (lhsc, rhsc);
- VEC_free (ce_s, heap, lhsc);
- VEC_free (ce_s, heap, rhsc);
+ lhsc.release ();
+ rhsc.release ();
return true;
}
/* Variadic argument handling needs to be handled in IPA
@@ -4296,9 +4289,9 @@ find_func_aliases_for_builtin_call (gimple t)
rhs.type = ADDRESSOF;
rhs.offset = 0;
}
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, i, lhsp)
process_constraint (new_constraint (*lhsp, rhs));
- VEC_free (ce_s, heap, lhsc);
+ lhsc.release ();
/* va_list is clobbered. */
make_constraint_to (get_call_clobber_vi (t)->id, valist);
return true;
@@ -4341,8 +4334,8 @@ static void
find_func_aliases_for_call (gimple t)
{
tree fndecl = gimple_call_fndecl (t);
- VEC(ce_s, heap) *lhsc = NULL;
- VEC(ce_s, heap) *rhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
+ vec<ce_s> rhsc = vec<ce_s>();
varinfo_t fi;
if (fndecl != NULL_TREE
@@ -4354,7 +4347,7 @@ find_func_aliases_for_call (gimple t)
if (!in_ipa_mode
|| (fndecl && !fi->is_fn_info))
{
- VEC(ce_s, heap) *rhsc = NULL;
+ vec<ce_s> rhsc = vec<ce_s>();
int flags = gimple_call_flags (t);
/* Const functions can return their arguments and addresses
@@ -4373,7 +4366,7 @@ find_func_aliases_for_call (gimple t)
handle_rhs_call (t, &rhsc);
if (gimple_call_lhs (t))
handle_lhs_call (t, gimple_call_lhs (t), flags, rhsc, fndecl);
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
else
{
@@ -4390,11 +4383,11 @@ find_func_aliases_for_call (gimple t)
get_constraint_for_rhs (arg, &rhsc);
lhs = get_function_part_constraint (fi, fi_parm_base + j);
- while (VEC_length (ce_s, rhsc) != 0)
+ while (rhsc.length () != 0)
{
- rhsp = &VEC_last (ce_s, rhsc);
+ rhsp = &rhsc.last ();
process_constraint (new_constraint (lhs, *rhsp));
- VEC_pop (ce_s, rhsc);
+ rhsc.pop ();
}
}
@@ -4411,13 +4404,13 @@ find_func_aliases_for_call (gimple t)
&& DECL_RESULT (fndecl)
&& DECL_BY_REFERENCE (DECL_RESULT (fndecl)))
{
- VEC(ce_s, heap) *tem = NULL;
- VEC_safe_push (ce_s, heap, tem, rhs);
+ vec<ce_s> tem = vec<ce_s>();
+ tem.safe_push (rhs);
do_deref (&tem);
- rhs = VEC_index (ce_s, tem, 0);
- VEC_free(ce_s, heap, tem);
+ rhs = tem[0];
+ tem.release ();
}
- FOR_EACH_VEC_ELT (ce_s, lhsc, j, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, j, lhsp)
process_constraint (new_constraint (*lhsp, rhs));
}
@@ -4432,9 +4425,9 @@ find_func_aliases_for_call (gimple t)
get_constraint_for_address_of (lhsop, &rhsc);
lhs = get_function_part_constraint (fi, fi_result);
- FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, j, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
/* If we use a static chain, pass it along. */
@@ -4445,7 +4438,7 @@ find_func_aliases_for_call (gimple t)
get_constraint_for (gimple_call_chain (t), &rhsc);
lhs = get_function_part_constraint (fi, fi_static_chain);
- FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, j, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
}
}
@@ -4460,8 +4453,8 @@ static void
find_func_aliases (gimple origt)
{
gimple t = origt;
- VEC(ce_s, heap) *lhsc = NULL;
- VEC(ce_s, heap) *rhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
+ vec<ce_s> rhsc = vec<ce_s>();
struct constraint_expr *c;
varinfo_t fi;
@@ -4481,14 +4474,14 @@ find_func_aliases (gimple origt)
STRIP_NOPS (strippedrhs);
get_constraint_for_rhs (gimple_phi_arg_def (t, i), &rhsc);
- FOR_EACH_VEC_ELT (ce_s, lhsc, j, c)
+ FOR_EACH_VEC_ELT (lhsc, j, c)
{
struct constraint_expr *c2;
- while (VEC_length (ce_s, rhsc) > 0)
+ while (rhsc.length () > 0)
{
- c2 = &VEC_last (ce_s, rhsc);
+ c2 = &rhsc.last ();
process_constraint (new_constraint (*c, *c2));
- VEC_pop (ce_s, rhsc);
+ rhsc.pop ();
}
}
}
@@ -4543,14 +4536,14 @@ find_func_aliases (gimple origt)
else if (code == COND_EXPR)
{
/* The result is a merge of both COND_EXPR arms. */
- VEC (ce_s, heap) *tmp = NULL;
+ vec<ce_s> tmp = vec<ce_s>();
struct constraint_expr *rhsp;
unsigned i;
get_constraint_for_rhs (gimple_assign_rhs2 (t), &rhsc);
get_constraint_for_rhs (gimple_assign_rhs3 (t), &tmp);
- FOR_EACH_VEC_ELT (ce_s, tmp, i, rhsp)
- VEC_safe_push (ce_s, heap, rhsc, *rhsp);
- VEC_free (ce_s, heap, tmp);
+ FOR_EACH_VEC_ELT (tmp, i, rhsp)
+ rhsc.safe_push (*rhsp);
+ tmp.release ();
}
else if (truth_value_p (code))
/* Truth value results are not pointer (parts). Or at least
@@ -4559,18 +4552,18 @@ find_func_aliases (gimple origt)
else
{
/* All other operations are merges. */
- VEC (ce_s, heap) *tmp = NULL;
+ vec<ce_s> tmp = vec<ce_s>();
struct constraint_expr *rhsp;
unsigned i, j;
get_constraint_for_rhs (gimple_assign_rhs1 (t), &rhsc);
for (i = 2; i < gimple_num_ops (t); ++i)
{
get_constraint_for_rhs (gimple_op (t, i), &tmp);
- FOR_EACH_VEC_ELT (ce_s, tmp, j, rhsp)
- VEC_safe_push (ce_s, heap, rhsc, *rhsp);
- VEC_truncate (ce_s, tmp, 0);
+ FOR_EACH_VEC_ELT (tmp, j, rhsp)
+ rhsc.safe_push (*rhsp);
+ tmp.truncate (0);
}
- VEC_free (ce_s, heap, tmp);
+ tmp.release ();
}
process_all_all_constraints (lhsc, rhsc);
}
@@ -4599,7 +4592,7 @@ find_func_aliases (gimple origt)
lhs = get_function_part_constraint (fi, fi_result);
get_constraint_for_rhs (gimple_return_retval (t), &rhsc);
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
}
}
@@ -4632,16 +4625,16 @@ find_func_aliases (gimple origt)
any global memory. */
if (op)
{
- VEC(ce_s, heap) *lhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
struct constraint_expr rhsc, *lhsp;
unsigned j;
get_constraint_for (op, &lhsc);
rhsc.var = nonlocal_id;
rhsc.offset = 0;
rhsc.type = SCALAR;
- FOR_EACH_VEC_ELT (ce_s, lhsc, j, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, j, lhsp)
process_constraint (new_constraint (*lhsp, rhsc));
- VEC_free (ce_s, heap, lhsc);
+ lhsc.release ();
}
}
for (i = 0; i < gimple_asm_ninputs (t); ++i)
@@ -4665,8 +4658,8 @@ find_func_aliases (gimple origt)
}
}
- VEC_free (ce_s, heap, rhsc);
- VEC_free (ce_s, heap, lhsc);
+ rhsc.release ();
+ lhsc.release ();
}
@@ -4676,14 +4669,14 @@ find_func_aliases (gimple origt)
static void
process_ipa_clobber (varinfo_t fi, tree ptr)
{
- VEC(ce_s, heap) *ptrc = NULL;
+ vec<ce_s> ptrc = vec<ce_s>();
struct constraint_expr *c, lhs;
unsigned i;
get_constraint_for_rhs (ptr, &ptrc);
lhs = get_function_part_constraint (fi, fi_clobbers);
- FOR_EACH_VEC_ELT (ce_s, ptrc, i, c)
+ FOR_EACH_VEC_ELT (ptrc, i, c)
process_constraint (new_constraint (lhs, *c));
- VEC_free (ce_s, heap, ptrc);
+ ptrc.release ();
}
/* Walk statement T setting up clobber and use constraints according to the
@@ -4694,8 +4687,8 @@ static void
find_func_clobbers (gimple origt)
{
gimple t = origt;
- VEC(ce_s, heap) *lhsc = NULL;
- VEC(ce_s, heap) *rhsc = NULL;
+ vec<ce_s> lhsc = vec<ce_s>();
+ vec<ce_s> rhsc = vec<ce_s>();
varinfo_t fi;
/* Add constraints for clobbered/used in IPA mode.
@@ -4732,9 +4725,9 @@ find_func_clobbers (gimple origt)
unsigned i;
lhsc = get_function_part_constraint (fi, fi_clobbers);
get_constraint_for_address_of (lhs, &rhsc);
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhsc, *rhsp));
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
}
@@ -4760,9 +4753,9 @@ find_func_clobbers (gimple origt)
unsigned i;
lhs = get_function_part_constraint (fi, fi_uses);
get_constraint_for_address_of (rhs, &rhsc);
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
}
@@ -4809,14 +4802,14 @@ find_func_clobbers (gimple origt)
struct constraint_expr *rhsp, *lhsp;
get_constraint_for_ptr_offset (dest, NULL_TREE, &lhsc);
lhs = get_function_part_constraint (fi, fi_clobbers);
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, i, lhsp)
process_constraint (new_constraint (lhs, *lhsp));
- VEC_free (ce_s, heap, lhsc);
+ lhsc.release ();
get_constraint_for_ptr_offset (src, NULL_TREE, &rhsc);
lhs = get_function_part_constraint (fi, fi_uses);
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
return;
}
/* The following function clobbers memory pointed to by
@@ -4829,9 +4822,9 @@ find_func_clobbers (gimple origt)
ce_s *lhsp;
get_constraint_for_ptr_offset (dest, NULL_TREE, &lhsc);
lhs = get_function_part_constraint (fi, fi_clobbers);
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
+ FOR_EACH_VEC_ELT (lhsc, i, lhsp)
process_constraint (new_constraint (lhs, *lhsp));
- VEC_free (ce_s, heap, lhsc);
+ lhsc.release ();
return;
}
/* The following functions clobber their second and third
@@ -4899,9 +4892,9 @@ find_func_clobbers (gimple origt)
continue;
get_constraint_for_address_of (arg, &rhsc);
- FOR_EACH_VEC_ELT (ce_s, rhsc, j, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, j, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
/* Build constraints for propagating clobbers/uses along the
@@ -4962,7 +4955,7 @@ find_func_clobbers (gimple origt)
anything_id);
}
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
@@ -5048,8 +5041,6 @@ struct fieldoff
};
typedef struct fieldoff fieldoff_s;
-DEF_VEC_O(fieldoff_s);
-DEF_VEC_ALLOC_O(fieldoff_s,heap);
/* qsort comparison function for two fieldoff's PA and PB */
@@ -5076,9 +5067,9 @@ fieldoff_compare (const void *pa, const void *pb)
/* Sort a fieldstack according to the field offset and sizes. */
static void
-sort_fieldstack (VEC(fieldoff_s,heap) *fieldstack)
+sort_fieldstack (vec<fieldoff_s> fieldstack)
{
- VEC_qsort (fieldoff_s, fieldstack, fieldoff_compare);
+ fieldstack.qsort (fieldoff_compare);
}
/* Return true if T is a type that can have subvars. */
@@ -5144,7 +5135,7 @@ field_must_have_pointers (tree t)
recursed for. */
static bool
-push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
+push_fields_onto_fieldstack (tree type, vec<fieldoff_s> *fieldstack,
HOST_WIDE_INT offset)
{
tree field;
@@ -5154,9 +5145,9 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
return false;
/* If the vector of fields is growing too big, bail out early.
- Callers check for VEC_length <= MAX_FIELDS_FOR_FIELD_SENSITIVE, make
+ Callers check for vec::length <= MAX_FIELDS_FOR_FIELD_SENSITIVE, make
sure this fails. */
- if (VEC_length (fieldoff_s, *fieldstack) > MAX_FIELDS_FOR_FIELD_SENSITIVE)
+ if (fieldstack->length () > MAX_FIELDS_FOR_FIELD_SENSITIVE)
return false;
for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
@@ -5184,15 +5175,15 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
bool has_unknown_size = false;
bool must_have_pointers_p;
- if (!VEC_empty (fieldoff_s, *fieldstack))
- pair = &VEC_last (fieldoff_s, *fieldstack);
+ if (!fieldstack->is_empty ())
+ pair = &fieldstack->last ();
/* If there isn't anything at offset zero, create sth. */
if (!pair
&& offset + foff != 0)
{
fieldoff_s e = {0, offset + foff, false, false, false, false};
- pair = VEC_safe_push (fieldoff_s, heap, *fieldstack, e);
+ pair = fieldstack->safe_push (e);
}
if (!DECL_SIZE (field)
@@ -5225,7 +5216,7 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
= (!has_unknown_size
&& POINTER_TYPE_P (TREE_TYPE (field))
&& TYPE_RESTRICT (TREE_TYPE (field)));
- VEC_safe_push (fieldoff_s, heap, *fieldstack, e);
+ fieldstack->safe_push (e);
}
}
@@ -5442,13 +5433,13 @@ create_function_info_for (tree decl, const char *name)
FIELDSTACK is assumed to be sorted by offset. */
static bool
-check_for_overlaps (VEC (fieldoff_s,heap) *fieldstack)
+check_for_overlaps (vec<fieldoff_s> fieldstack)
{
fieldoff_s *fo = NULL;
unsigned int i;
HOST_WIDE_INT lastoffset = -1;
- FOR_EACH_VEC_ELT (fieldoff_s, fieldstack, i, fo)
+ FOR_EACH_VEC_ELT (fieldstack, i, fo)
{
if (fo->offset == lastoffset)
return true;
@@ -5467,7 +5458,7 @@ create_variable_info_for_1 (tree decl, const char *name)
varinfo_t vi, newvi;
tree decl_type = TREE_TYPE (decl);
tree declsize = DECL_P (decl) ? DECL_SIZE (decl) : TYPE_SIZE (decl_type);
- VEC (fieldoff_s,heap) *fieldstack = NULL;
+ vec<fieldoff_s> fieldstack = vec<fieldoff_s>();
fieldoff_s *fo;
unsigned int i;
@@ -5499,7 +5490,7 @@ create_variable_info_for_1 (tree decl, const char *name)
push_fields_onto_fieldstack (decl_type, &fieldstack, 0);
- for (i = 0; !notokay && VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
+ for (i = 0; !notokay && fieldstack.iterate (i, &fo); i++)
if (fo->has_unknown_size
|| fo->offset < 0)
{
@@ -5522,13 +5513,13 @@ create_variable_info_for_1 (tree decl, const char *name)
}
if (notokay)
- VEC_free (fieldoff_s, heap, fieldstack);
+ fieldstack.release ();
}
/* If we didn't end up collecting sub-variables create a full
variable for the decl. */
- if (VEC_length (fieldoff_s, fieldstack) <= 1
- || VEC_length (fieldoff_s, fieldstack) > MAX_FIELDS_FOR_FIELD_SENSITIVE)
+ if (fieldstack.length () <= 1
+ || fieldstack.length () > MAX_FIELDS_FOR_FIELD_SENSITIVE)
{
vi = new_var_info (decl, name);
vi->offset = 0;
@@ -5536,14 +5527,14 @@ create_variable_info_for_1 (tree decl, const char *name)
vi->fullsize = TREE_INT_CST_LOW (declsize);
vi->size = vi->fullsize;
vi->is_full_var = true;
- VEC_free (fieldoff_s, heap, fieldstack);
+ fieldstack.release ();
return vi;
}
vi = new_var_info (decl, name);
vi->fullsize = TREE_INT_CST_LOW (declsize);
for (i = 0, newvi = vi;
- VEC_iterate (fieldoff_s, fieldstack, i, fo);
+ fieldstack.iterate (i, &fo);
++i, newvi = newvi->next)
{
const char *newname = "NULL";
@@ -5562,11 +5553,11 @@ create_variable_info_for_1 (tree decl, const char *name)
newvi->fullsize = vi->fullsize;
newvi->may_have_pointers = fo->may_have_pointers;
newvi->only_restrict_pointers = fo->only_restrict_pointers;
- if (i + 1 < VEC_length (fieldoff_s, fieldstack))
+ if (i + 1 < fieldstack.length ())
newvi->next = new_var_info (decl, name);
}
- VEC_free (fieldoff_s, heap, fieldstack);
+ fieldstack.release ();
return vi;
}
@@ -5618,14 +5609,14 @@ create_variable_info_for (tree decl, const char *name)
if (DECL_INITIAL (decl)
&& vnode->analyzed)
{
- VEC (ce_s, heap) *rhsc = NULL;
+ vec<ce_s> rhsc = vec<ce_s>();
struct constraint_expr lhs, *rhsp;
unsigned i;
get_constraint_for_rhs (DECL_INITIAL (decl), &rhsc);
lhs.var = vi->id;
lhs.offset = 0;
lhs.type = SCALAR;
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
/* If this is a variable that escapes from the unit
the initializer escapes as well. */
@@ -5634,10 +5625,10 @@ create_variable_info_for (tree decl, const char *name)
lhs.var = escaped_id;
lhs.offset = 0;
lhs.type = SCALAR;
- FOR_EACH_VEC_ELT (ce_s, rhsc, i, rhsp)
+ FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (lhs, *rhsp));
}
- VEC_free (ce_s, heap, rhsc);
+ rhsc.release ();
}
}
}
@@ -6259,7 +6250,7 @@ dump_sa_points_to_info (FILE *outfile)
stats.num_implicit_edges);
}
- for (i = 0; i < VEC_length (varinfo_t, varmap); i++)
+ for (i = 0; i < varmap.length (); i++)
{
varinfo_t vi = get_varinfo (i);
if (!vi->may_have_pointers)
@@ -6329,7 +6320,7 @@ init_base_vars (void)
/* This specifically does not use process_constraint because
process_constraint ignores all anything = anything constraints, since all
but this one are redundant. */
- VEC_safe_push (constraint_t, heap, constraints, new_constraint (lhs, rhs));
+ constraints.safe_push (new_constraint (lhs, rhs));
/* Create the READONLY variable, used to represent that a variable
points to readonly memory. */
@@ -6465,8 +6456,8 @@ init_alias_vars (void)
sizeof (struct constraint), 30);
variable_info_pool = create_alloc_pool ("Variable info pool",
sizeof (struct variable_info), 30);
- constraints = VEC_alloc (constraint_t, heap, 8);
- varmap = VEC_alloc (varinfo_t, heap, 8);
+ constraints.create (8);
+ varmap.create (8);
vi_for_tree = pointer_map_create ();
call_stmt_vars = pointer_map_create ();
@@ -6504,7 +6495,7 @@ remove_preds_and_fake_succs (constraint_graph_t graph)
/* Now reallocate the size of the successor list as, and blow away
the predecessor bitmaps. */
- graph->size = VEC_length (varinfo_t, varmap);
+ graph->size = varmap.length ();
graph->succs = XRESIZEVEC (bitmap, graph->succs, graph->size);
free (graph->implicit_preds);
@@ -6526,7 +6517,7 @@ solve_constraints (void)
"\nCollapsing static cycles and doing variable "
"substitution\n");
- init_graph (VEC_length (varinfo_t, varmap) * 2);
+ init_graph (varmap.length () * 2);
if (dump_file)
fprintf (dump_file, "Building predecessor graph\n");
@@ -6643,7 +6634,7 @@ compute_points_to_sets (void)
cfun->gimple_df->escaped.escaped = 0;
/* Mark escaped HEAP variables as global. */
- FOR_EACH_VEC_ELT (varinfo_t, varmap, i, vi)
+ FOR_EACH_VEC_ELT (varmap, i, vi)
if (vi->is_heap_var
&& !vi->is_global_var)
DECL_EXTERNAL (vi->decl) = vi->is_global_var
@@ -6733,10 +6724,10 @@ delete_points_to_sets (void)
pointer_map_destroy (vi_for_tree);
pointer_map_destroy (call_stmt_vars);
bitmap_obstack_release (&pta_obstack);
- VEC_free (constraint_t, heap, constraints);
+ constraints.release ();
for (i = 0; i < graph->size; i++)
- VEC_free (constraint_t, heap, graph->complex[i]);
+ graph->complex[i].release ();
free (graph->complex);
free (graph->rep);
@@ -6746,7 +6737,7 @@ delete_points_to_sets (void)
free (graph->indirect_cycles);
free (graph);
- VEC_free (varinfo_t, heap, varmap);
+ varmap.release ();
free_alloc_pool (variable_info_pool);
free_alloc_pool (constraint_pool);
@@ -6921,7 +6912,7 @@ ipa_pta_execute (void)
dump_constraints (dump_file, 0);
fprintf (dump_file, "\n");
}
- from = VEC_length (constraint_t, constraints);
+ from = constraints.length ();
FOR_EACH_DEFINED_FUNCTION (node)
{
@@ -7009,7 +7000,7 @@ ipa_pta_execute (void)
dump_constraints (dump_file, from);
fprintf (dump_file, "\n");
}
- from = VEC_length (constraint_t, constraints);
+ from = constraints.length ();
}
/* From the constraints compute the points-to sets. */
@@ -7044,7 +7035,7 @@ ipa_pta_execute (void)
fn = DECL_STRUCT_FUNCTION (node->symbol.decl);
/* Compute the points-to sets for pointer SSA_NAMEs. */
- FOR_EACH_VEC_ELT (tree, fn->gimple_df->ssa_names, i, ptr)
+ FOR_EACH_VEC_ELT (*fn->gimple_df->ssa_names, i, ptr)
{
if (ptr
&& POINTER_TYPE_P (TREE_TYPE (ptr)))