diff options
author | Diego Novillo <dnovillo@google.com> | 2012-11-18 02:54:30 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2012-11-18 02:54:30 +0000 |
commit | 85943a92f41f04a401d537cbf56857d68ec51033 (patch) | |
tree | 1b9f930d315fa3e0a5ed7fa6e27ec5bd0a3436a4 /gcc/lto | |
parent | 5b4a7ac01f066ea476ad7b58e0aa7cf08c526dac (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/lto')
-rw-r--r-- | gcc/lto/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/lto/lto-lang.c | 8 | ||||
-rw-r--r-- | gcc/lto/lto-partition.c | 19 | ||||
-rw-r--r-- | gcc/lto/lto-partition.h | 4 | ||||
-rw-r--r-- | gcc/lto/lto.c | 108 |
5 files changed, 72 insertions, 76 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 19b9c1914d5..841d2500561 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,12 @@ +2012-11-16 Diego Novillo <dnovillo@google.com> + + Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec) + + * lto-lang.c: Use new vec API in vec.h. + * lto-partition.c: Likewise. + * lto-partition.h: Likewise. + * lto.c: Likewise. + 2012-10-31 Lawrence Crowl <crowl@google.com> * lto.c (lto_wpa_write_files): Change symtab checking to a checked diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index edfab74de0a..04664371e20 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -1061,11 +1061,11 @@ lto_getdecls (void) static void lto_write_globals (void) { - tree *vec = VEC_address (tree, lto_global_var_decls); - int len = VEC_length (tree, lto_global_var_decls); + tree *vec = lto_global_var_decls->address (); + int len = lto_global_var_decls->length (); wrapup_global_declarations (vec, len); emit_debug_global_declarations (vec, len); - VEC_free (tree, gc, lto_global_var_decls); + vec_free (lto_global_var_decls); } static tree @@ -1235,7 +1235,7 @@ lto_init (void) lto_register_canonical_types (global_trees[i]); /* Initialize LTO-specific data structures. */ - lto_global_var_decls = VEC_alloc (tree, gc, 256); + vec_alloc (lto_global_var_decls, 256); in_lto_p = true; return true; diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index a642a6c5f17..363d2ffbee5 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -44,7 +44,7 @@ enum symbol_class SYMBOL_DUPLICATE }; -VEC(ltrans_partition, heap) *ltrans_partitions; +vec<ltrans_partition> ltrans_partitions; static void add_symbol_to_partition (ltrans_partition part, symtab_node node); @@ -102,7 +102,7 @@ new_partition (const char *name) part->encoder = lto_symtab_encoder_new (false); part->name = name; part->insns = 0; - VEC_safe_push (ltrans_partition, heap, ltrans_partitions, part); + ltrans_partitions.safe_push (part); return part; } @@ -113,14 +113,14 @@ free_ltrans_partitions (void) { unsigned int idx; ltrans_partition part; - for (idx = 0; VEC_iterate (ltrans_partition, ltrans_partitions, idx, part); idx++) + for (idx = 0; ltrans_partitions.iterate (idx, &part); idx++) { if (part->initializers_visited) pointer_set_destroy (part->initializers_visited); /* Symtab encoder is freed after streaming. */ free (part); } - VEC_free (ltrans_partition, heap, ltrans_partitions); + ltrans_partitions.release (); } /* Return true if symbol is already in some partition. */ @@ -344,9 +344,8 @@ lto_1_to_1_map (void) npartitions++; } } - else if (!file_data - && VEC_length (ltrans_partition, ltrans_partitions)) - partition = VEC_index (ltrans_partition, ltrans_partitions, 0); + else if (!file_data && ltrans_partitions.length ()) + partition = ltrans_partitions[0]; else { partition = new_partition (""); @@ -790,11 +789,11 @@ lto_promote_cross_file_statics (void) gcc_assert (flag_wpa); /* First compute boundaries. */ - n_sets = VEC_length (ltrans_partition, ltrans_partitions); + n_sets = ltrans_partitions.length (); for (i = 0; i < n_sets; i++) { ltrans_partition part - = VEC_index (ltrans_partition, ltrans_partitions, i); + = ltrans_partitions[i]; part->encoder = compute_ltrans_boundary (part->encoder); } @@ -804,7 +803,7 @@ lto_promote_cross_file_statics (void) lto_symtab_encoder_iterator lsei; lto_symtab_encoder_t encoder; ltrans_partition part - = VEC_index (ltrans_partition, ltrans_partitions, i); + = ltrans_partitions[i]; encoder = part->encoder; for (lsei = lsei_start (encoder); !lsei_end_p (lsei); diff --git a/gcc/lto/lto-partition.h b/gcc/lto/lto-partition.h index 5bf4055269f..86b21a0d347 100644 --- a/gcc/lto/lto-partition.h +++ b/gcc/lto/lto-partition.h @@ -29,10 +29,8 @@ struct ltrans_partition_def }; typedef struct ltrans_partition_def *ltrans_partition; -DEF_VEC_P(ltrans_partition); -DEF_VEC_ALLOC_P(ltrans_partition,heap); -extern VEC(ltrans_partition, heap) *ltrans_partitions; +extern vec<ltrans_partition> ltrans_partitions; void lto_1_to_1_map (void); void lto_max_map (void); diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 857e8f6032b..da55b7efbbe 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -305,8 +305,6 @@ struct type_pair_d signed char same_p; }; typedef struct type_pair_d *type_pair_t; -DEF_VEC_P(type_pair_t); -DEF_VEC_ALLOC_P(type_pair_t,heap); #define GIMPLE_TYPE_PAIR_SIZE 16381 struct type_pair_d *type_pair_cache; @@ -432,7 +430,7 @@ compare_type_names_p (tree t1, tree t2) static bool gimple_types_compatible_p_1 (tree, tree, type_pair_t, - VEC(type_pair_t, heap) **, + vec<type_pair_t> *, struct pointer_map_t *, struct obstack *); /* DFS visit the edge from the callers type pair with state *STATE to @@ -444,7 +442,7 @@ gimple_types_compatible_p_1 (tree, tree, type_pair_t, static bool gtc_visit (tree t1, tree t2, struct sccs *state, - VEC(type_pair_t, heap) **sccstack, + vec<type_pair_t> *sccstack, struct pointer_map_t *sccstate, struct obstack *sccstate_obstack) { @@ -558,7 +556,7 @@ gtc_visit (tree t1, tree t2, static bool gimple_types_compatible_p_1 (tree t1, tree t2, type_pair_t p, - VEC(type_pair_t, heap) **sccstack, + vec<type_pair_t> *sccstack, struct pointer_map_t *sccstate, struct obstack *sccstate_obstack) { @@ -569,7 +567,7 @@ gimple_types_compatible_p_1 (tree t1, tree t2, type_pair_t p, state = XOBNEW (sccstate_obstack, struct sccs); *pointer_map_insert (sccstate, p) = state; - VEC_safe_push (type_pair_t, heap, *sccstack, p); + sccstack->safe_push (p); state->dfsnum = gtc_next_dfs_num++; state->low = state->dfsnum; state->on_sccstack = true; @@ -857,7 +855,7 @@ pop: do { struct sccs *cstate; - x = VEC_pop (type_pair_t, *sccstack); + x = sccstack->pop (); cstate = (struct sccs *)*pointer_map_contains (sccstate, x); cstate->on_sccstack = false; x->same_p = state->u.same_p; @@ -875,7 +873,7 @@ pop: static bool gimple_types_compatible_p (tree t1, tree t2) { - VEC(type_pair_t, heap) *sccstack = NULL; + vec<type_pair_t> sccstack = vec<type_pair_t>(); struct pointer_map_t *sccstate; struct obstack sccstate_obstack; type_pair_t p = NULL; @@ -970,7 +968,7 @@ gimple_types_compatible_p (tree t1, tree t2) gcc_obstack_init (&sccstate_obstack); res = gimple_types_compatible_p_1 (t1, t2, p, &sccstack, sccstate, &sccstate_obstack); - VEC_free (type_pair_t, heap, sccstack); + sccstack.release (); pointer_map_destroy (sccstate); obstack_free (&sccstate_obstack, NULL); @@ -978,7 +976,7 @@ gimple_types_compatible_p (tree t1, tree t2) } static hashval_t -iterative_hash_gimple_type (tree, hashval_t, VEC(tree, heap) **, +iterative_hash_gimple_type (tree, hashval_t, vec<tree> *, struct pointer_map_t *, struct obstack *); /* DFS visit the edge from the callers type with state *STATE to T. @@ -988,7 +986,7 @@ iterative_hash_gimple_type (tree, hashval_t, VEC(tree, heap) **, static hashval_t visit (tree t, struct sccs *state, hashval_t v, - VEC (tree, heap) **sccstack, + vec<tree> *sccstack, struct pointer_map_t *sccstate, struct obstack *sccstate_obstack) { @@ -1081,7 +1079,7 @@ type_hash_pair_compare (const void *p1_, const void *p2_) static hashval_t iterative_hash_gimple_type (tree type, hashval_t val, - VEC(tree, heap) **sccstack, + vec<tree> *sccstack, struct pointer_map_t *sccstate, struct obstack *sccstate_obstack) { @@ -1094,7 +1092,7 @@ iterative_hash_gimple_type (tree type, hashval_t val, state = XOBNEW (sccstate_obstack, struct sccs); *pointer_map_insert (sccstate, type) = state; - VEC_safe_push (tree, heap, *sccstack, type); + sccstack->safe_push (type); state->dfsnum = next_dfs_num++; state->low = state->dfsnum; state->on_sccstack = true; @@ -1216,7 +1214,7 @@ iterative_hash_gimple_type (tree type, hashval_t val, struct tree_int_map *m; /* Pop off the SCC and set its hash values. */ - x = VEC_pop (tree, *sccstack); + x = sccstack->pop (); /* Optimize SCC size one. */ if (x == type) { @@ -1234,10 +1232,10 @@ iterative_hash_gimple_type (tree type, hashval_t val, unsigned first, i, size, j; struct type_hash_pair *pairs; /* Pop off the SCC and build an array of type, hash pairs. */ - first = VEC_length (tree, *sccstack) - 1; - while (VEC_index (tree, *sccstack, first) != type) + first = sccstack->length () - 1; + while ((*sccstack)[first] != type) --first; - size = VEC_length (tree, *sccstack) - first + 1; + size = sccstack->length () - first + 1; pairs = XALLOCAVEC (struct type_hash_pair, size); i = 0; cstate = (struct sccs *)*pointer_map_contains (sccstate, x); @@ -1246,7 +1244,7 @@ iterative_hash_gimple_type (tree type, hashval_t val, pairs[i].hash = cstate->u.hash; do { - x = VEC_pop (tree, *sccstack); + x = sccstack->pop (); cstate = (struct sccs *)*pointer_map_contains (sccstate, x); cstate->on_sccstack = false; ++i; @@ -1300,7 +1298,7 @@ static hashval_t gimple_type_hash (const void *p) { const_tree t = (const_tree) p; - VEC(tree, heap) *sccstack = NULL; + vec<tree> sccstack = vec<tree>(); struct pointer_map_t *sccstate; struct obstack sccstate_obstack; hashval_t val; @@ -1318,7 +1316,7 @@ gimple_type_hash (const void *p) gcc_obstack_init (&sccstate_obstack); val = iterative_hash_gimple_type (CONST_CAST_TREE (t), 0, &sccstack, sccstate, &sccstate_obstack); - VEC_free (tree, heap, sccstack); + sccstack.release (); pointer_map_destroy (sccstate); obstack_free (&sccstate_obstack, NULL); @@ -1581,13 +1579,13 @@ lto_ft_binfo (tree t) LTO_FIXUP_TREE (BINFO_OFFSET (t)); LTO_FIXUP_TREE (BINFO_VIRTUALS (t)); LTO_FIXUP_TREE (BINFO_VPTR_FIELD (t)); - n = VEC_length (tree, BINFO_BASE_ACCESSES (t)); + n = vec_safe_length (BINFO_BASE_ACCESSES (t)); for (i = 0; i < n; i++) { saved_base = base = BINFO_BASE_ACCESS (t, i); LTO_FIXUP_TREE (base); if (base != saved_base) - VEC_replace (tree, BINFO_BASE_ACCESSES (t), i, base); + (*BINFO_BASE_ACCESSES (t))[i] = base; } LTO_FIXUP_TREE (BINFO_INHERITANCE_CHAIN (t)); LTO_FIXUP_TREE (BINFO_SUBVTT_INDEX (t)); @@ -1598,7 +1596,7 @@ lto_ft_binfo (tree t) saved_base = base = BINFO_BASE_BINFO (t, i); LTO_FIXUP_TREE (base); if (base != saved_base) - VEC_replace (tree, BINFO_BASE_BINFOS (t), i, base); + (*BINFO_BASE_BINFOS (t))[i] = base; } } @@ -1612,9 +1610,7 @@ lto_ft_constructor (tree t) lto_ft_typed (t); - for (idx = 0; - VEC_iterate(constructor_elt, CONSTRUCTOR_ELTS (t), idx, ce); - idx++) + for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (t), idx, &ce); idx++) { LTO_FIXUP_TREE (ce->index); LTO_FIXUP_TREE (ce->value); @@ -1713,18 +1709,15 @@ lto_fixup_types (tree t) static enum ld_plugin_symbol_resolution get_resolution (struct data_in *data_in, unsigned index) { - if (data_in->globals_resolution) + if (data_in->globals_resolution.exists ()) { ld_plugin_symbol_resolution_t ret; /* We can have references to not emitted functions in DECL_FUNCTION_PERSONALITY at least. So we can and have to indeed return LDPR_UNKNOWN in some cases. */ - if (VEC_length (ld_plugin_symbol_resolution_t, - data_in->globals_resolution) <= index) + if (data_in->globals_resolution.length () <= index) return LDPR_UNKNOWN; - ret = VEC_index (ld_plugin_symbol_resolution_t, - data_in->globals_resolution, - index); + ret = data_in->globals_resolution[index]; return ret; } else @@ -1773,7 +1766,7 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl) ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label)); rest_of_decl_compilation (decl, 1, 0); - VEC_safe_push (tree, gc, lto_global_var_decls, decl); + vec_safe_push (lto_global_var_decls, decl); } /* If this variable has already been declared, queue the @@ -1855,7 +1848,7 @@ static void uniquify_nodes (struct data_in *data_in, unsigned from) { struct streamer_tree_cache_d *cache = data_in->reader_cache; - unsigned len = VEC_length (tree, cache->nodes); + unsigned len = cache->nodes.length (); unsigned i; /* Go backwards because children streamed for the first time come @@ -1866,7 +1859,7 @@ uniquify_nodes (struct data_in *data_in, unsigned from) them and computing hashes. */ for (i = len; i-- > from;) { - tree t = VEC_index (tree, cache->nodes, i); + tree t = cache->nodes[i]; if (t && TYPE_P (t)) { tree newt = gimple_register_type (t); @@ -1881,7 +1874,7 @@ uniquify_nodes (struct data_in *data_in, unsigned from) /* Second fixup all trees in the new cache entries. */ for (i = len; i-- > from;) { - tree t = VEC_index (tree, cache->nodes, i); + tree t = cache->nodes[i]; tree oldt = t; if (!t) continue; @@ -2042,7 +2035,7 @@ uniquify_nodes (struct data_in *data_in, unsigned from) make sure it is done last. */ for (i = len; i-- > from;) { - tree t = VEC_index (tree, cache->nodes, i); + tree t = cache->nodes[i]; if (t == NULL_TREE) continue; @@ -2065,7 +2058,7 @@ uniquify_nodes (struct data_in *data_in, unsigned from) static void lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, - VEC(ld_plugin_symbol_resolution_t,heap) *resolutions) + vec<ld_plugin_symbol_resolution_t> resolutions) { const struct lto_decl_header *header = (const struct lto_decl_header *) data; const int decl_offset = sizeof (struct lto_decl_header); @@ -2090,7 +2083,7 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, while (ib_main.p < ib_main.len) { tree t; - unsigned from = VEC_length (tree, data_in->reader_cache->nodes); + unsigned from = data_in->reader_cache->nodes.length (); t = stream_read_tree (&ib_main, data_in); gcc_assert (t && ib_main.p <= ib_main.len); uniquify_nodes (data_in, from); @@ -2242,7 +2235,7 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file) format that is only unpacked later when the subfile is processed. */ rp.res = r; rp.index = index; - VEC_safe_push (res_pair, heap, file_data->respairs, rp); + file_data->respairs.safe_push (rp); if (file_data->max_index < index) file_data->max_index = index; } @@ -2324,18 +2317,17 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file) { const char *data; size_t len; - VEC(ld_plugin_symbol_resolution_t,heap) *resolutions = NULL; + vec<ld_plugin_symbol_resolution_t> + resolutions = vec<ld_plugin_symbol_resolution_t>(); int i; res_pair *rp; /* Create vector for fast access of resolution. We do this lazily to save memory. */ - VEC_safe_grow_cleared (ld_plugin_symbol_resolution_t, heap, - resolutions, - file_data->max_index + 1); - for (i = 0; VEC_iterate (res_pair, file_data->respairs, i, rp); i++) - VEC_replace (ld_plugin_symbol_resolution_t, resolutions, rp->index, rp->res); - VEC_free (res_pair, heap, file_data->respairs); + resolutions.safe_grow_cleared (file_data->max_index + 1); + for (i = 0; file_data->respairs.iterate (i, &rp); i++) + resolutions[rp->index] = rp->res; + file_data->respairs.release (); file_data->renaming_hash_table = lto_create_renaming_table (); file_data->file_name = file->filename; @@ -2353,7 +2345,7 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file) /* Finalize FILE_DATA in FILE and increase COUNT. */ static int -lto_create_files_from_ids (lto_file *file, struct lto_file_decl_data *file_data, +lto_create_files_from_ids (lto_file *file, struct lto_file_decl_data *file_data, int *count) { lto_file_finalize (file_data, file); @@ -2608,7 +2600,7 @@ lto_wpa_write_files (void) timevar_push (TV_WHOPR_WPA); - FOR_EACH_VEC_ELT (ltrans_partition, ltrans_partitions, i, part) + FOR_EACH_VEC_ELT (ltrans_partitions, i, part) lto_stats.num_output_symtab_nodes += lto_symtab_encoder_size (part->encoder); /* Find out statics that need to be promoted @@ -2630,17 +2622,18 @@ lto_wpa_write_files (void) temp_filename[blen - sizeof (".out") + 1] = '\0'; blen = strlen (temp_filename); - n_sets = VEC_length (ltrans_partition, ltrans_partitions); + n_sets = ltrans_partitions.length (); /* Sort partitions by size so small ones are compiled last. FIXME: Even when not reordering we may want to output one list for parallel make and other for final link command. */ - VEC_qsort (ltrans_partition, ltrans_partitions, - flag_toplevel_reorder ? cmp_partitions_size : cmp_partitions_order); + ltrans_partitions.qsort (flag_toplevel_reorder + ? cmp_partitions_size + : cmp_partitions_order); for (i = 0; i < n_sets; i++) { size_t len; - ltrans_partition part = VEC_index (ltrans_partition, ltrans_partitions, i); + ltrans_partition part = ltrans_partitions[i]; /* Write all the nodes in SET. */ sprintf (temp_filename + blen, "%u.o", i); @@ -3091,9 +3084,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) this field into ltrans compilation. */ if (flag_ltrans) FOR_EACH_DEFINED_FUNCTION (node) - VEC_safe_push (ipa_opt_pass, heap, - node->ipa_transforms_to_apply, - (ipa_opt_pass)&pass_ipa_inline); + node->ipa_transforms_to_apply.safe_push ((ipa_opt_pass)&pass_ipa_inline); timevar_pop (TV_IPA_LTO_CGRAPH_MERGE); @@ -3148,7 +3139,7 @@ materialize_cgraph (void) set_cfun (NULL); /* Inform the middle end about the global variables we have seen. */ - FOR_EACH_VEC_ELT (tree, lto_global_var_decls, i, decl) + FOR_EACH_VEC_ELT (*lto_global_var_decls, i, decl) rest_of_decl_compilation (decl, 1, 0); if (!quiet_flag) @@ -3253,8 +3244,7 @@ do_whole_program_analysis (void) FOR_EACH_SYMBOL (node) node->symbol.aux = NULL; - lto_stats.num_cgraph_partitions += VEC_length (ltrans_partition, - ltrans_partitions); + lto_stats.num_cgraph_partitions += ltrans_partitions.length (); timevar_pop (TV_WHOPR_PARTITIONING); timevar_stop (TV_PHASE_OPT_GEN); |