On Tue, Apr 29, 2014 at 1:08 PM, <[email protected]> wrote:
> From: Trevor Saunders <[email protected]>
>
> Hi,
>
> the template allocation functions won't work with things that are
> actually variably sized, so its simpler to stop relying on gengtype for them
> first. However it turns out most of the usage of variably sized things in
> gengtype is to deal with gengtype badness instead of actually variably sized
> things so the next patch will remove a bit of the mess in this one.
>
> bootstrapped + regtested on x86_64-unknown-linux-gnu, ok?
>
> Trev
>
> gcc/ChangeLog:
>
> 2014-04-23 Trevor Saunders <[email protected]>
>
> * gengtype.c (write_typed_alloc_def): Don't write anything if the type
> is variably sized.
> * ggc.h: Adjust.
> * tree-ssa-operands.c (ssa_operand_alloc): Likewise.
> * tree.c (build_string): Likewise.
> (build_omp_clause): Likewise.
> * varasm.c (create_block_symbol): Likewise.
>
> gcc/c/ChangeLog:
>
> 2014-04-23 Trevor Saunders <[email protected]>
>
> * c-decl.c (finish_struct): Adjust.
> (finish_enum): Likewise.
>
> gcc/java/ChangeLog:
>
> 2014-04-23 Trevor Saunders <[email protected]>
>
> * class.c (add_method_1): Adjust.
> * constants.c (set_constant_entry): Likewise.
> * decl.c (java_dup_lang_specific_decl): Likewise.
> * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Likewise.
> (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Likewise.
> * jcf-reader.c (jcf_parse_constant_pool): Adjust.
>
> gcc/objc/ChangeLog:
>
> 2014-04-23 Trevor Saunders <[email protected]>
>
> * objc-act.h: Adjust.
>
> gcc/cp/ChangeLog:
>
> 2014-04-23 Trevor Saunders <[email protected]>
>
> * class.c (sorted_fields_type_new): Adjust.
> * cp-tree.h (more_aggr_init_expr_args_p): Likewise.
> * lex.c (retrofit_lang_decl): Likewise.
> (cxx_dup_lang_specific_decl): Likewise.
> (copy_lang_type): Likewise.
> (cxx_make_type): Likewise.
>
> gcc/fortran/ChangeLog:
>
> 2014-04-23 Trevor Saunders <[email protected]>
>
> * trans-decl.c (gfc_allocate_lang_decl): Adjust.
> * trans-types.c (gfc_get_nodesc_array_type): Likewise.
> (gfc_get_array_type_bounds): Likewise.
> (gfc_nonrestricted_type): Likewise.
> ---
> gcc/c/c-decl.c | 8 +++++---
> gcc/cp/class.c | 2 +-
> gcc/cp/cp-tree.h | 3 ++-
> gcc/cp/lex.c | 9 +++++----
> gcc/fortran/trans-decl.c | 5 +++--
> gcc/fortran/trans-types.c | 13 ++++++++-----
> gcc/gengtype.c | 3 +++
> gcc/ggc.h | 2 +-
> gcc/java/class.c | 3 ++-
> gcc/java/constants.c | 6 +++---
> gcc/java/decl.c | 2 +-
> gcc/java/java-tree.h | 6 ++++--
> gcc/java/jcf-reader.c | 3 ++-
> gcc/objc/objc-act.h | 3 ++-
> gcc/tree-ssa-operands.c | 4 ++--
> gcc/tree.c | 4 ++--
> gcc/varasm.c | 2 +-
> 17 files changed, 47 insertions(+), 31 deletions(-)
>
> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
> index e30876c..e8b8166 100644
> --- a/gcc/c/c-decl.c
> +++ b/gcc/c/c-decl.c
> @@ -7423,8 +7423,9 @@ finish_struct (location_t loc, tree t, tree fieldlist,
> tree attributes,
> ensure that this lives as long as the rest of the struct decl.
> All decls in an inline function need to be saved. */
>
> - space = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> - space2 = ggc_alloc_sorted_fields_type
> + space = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
> + space2 = (sorted_fields_type *) ggc_internal_alloc
> (sizeof (struct sorted_fields_type) + len * sizeof (tree));
ISTR we went to typed allocs as part of a transition which not
fully materialized? I actually dislike that we get back the
ugly casts here - so, can we keep the allocators or use
a macro similar to the XNEW family?
>
> len = 0;
> @@ -7704,7 +7705,8 @@ finish_enum (tree enumtype, tree values, tree
> attributes)
>
> /* Record the min/max values so that we can warn about bit-field
> enumerations that are too small for the values. */
> - lt = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> + lt = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
> lt->enum_min = minnode;
> lt->enum_max = maxnode;
> TYPE_LANG_SPECIFIC (enumtype) = lt;
> diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> index 334bfd5..86058b5 100644
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -6490,7 +6490,7 @@ static struct sorted_fields_type *
> sorted_fields_type_new (int n)
> {
> struct sorted_fields_type *sft;
> - sft = ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type)
> + sft = (sorted_fields_type *) ggc_internal_alloc (sizeof
> (sorted_fields_type)
> + n * sizeof (tree));
> sft->len = n;
>
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index f459e55..9fbc7f8 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -3586,7 +3586,8 @@ more_aggr_init_expr_args_p (const
> aggr_init_expr_arg_iterator *iter)
> do { \
> if (TYPE_LANG_SPECIFIC (NODE) == NULL) \
> {
> \
> - TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type \
> + TYPE_LANG_SPECIFIC (NODE) \
> + = (struct lang_type *) ggc_internal_cleared_alloc \
> (sizeof (struct lang_type_ptrmem)); \
> TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.h.is_lang_type_class = 0; \
> }
> \
> diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
> index 3fe275e..46c28ae 100644
> --- a/gcc/cp/lex.c
> +++ b/gcc/cp/lex.c
> @@ -555,7 +555,7 @@ retrofit_lang_decl (tree t)
> else
> gcc_unreachable ();
>
> - ld = ggc_alloc_cleared_lang_decl (size);
> + ld = (struct lang_decl *) ggc_internal_cleared_alloc (size);
>
> ld->u.base.selector = sel;
>
> @@ -597,7 +597,7 @@ cxx_dup_lang_specific_decl (tree node)
> else
> gcc_unreachable ();
>
> - ld = ggc_alloc_lang_decl (size);
> + ld = (struct lang_decl *) ggc_internal_alloc (size);
> memcpy (ld, DECL_LANG_SPECIFIC (node), size);
> DECL_LANG_SPECIFIC (node) = ld;
>
> @@ -635,7 +635,7 @@ copy_lang_type (tree node)
> size = sizeof (struct lang_type);
> else
> size = sizeof (struct lang_type_ptrmem);
> - lt = ggc_alloc_lang_type (size);
> + lt = (struct lang_type *) ggc_internal_alloc (size);
> memcpy (lt, TYPE_LANG_SPECIFIC (node), size);
> TYPE_LANG_SPECIFIC (node) = lt;
>
> @@ -668,7 +668,8 @@ cxx_make_type (enum tree_code code)
> || code == BOUND_TEMPLATE_TEMPLATE_PARM)
> {
> struct lang_type *pi
> - = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> + = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
>
> TYPE_LANG_SPECIFIC (t) = pi;
> pi->u.c.h.is_lang_type_class = 1;
> diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
> index cf7b661..beb99a6 100644
> --- a/gcc/fortran/trans-decl.c
> +++ b/gcc/fortran/trans-decl.c
> @@ -615,8 +615,9 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
> void
> gfc_allocate_lang_decl (tree decl)
> {
> - DECL_LANG_SPECIFIC (decl) = ggc_alloc_cleared_lang_decl(sizeof
> - (struct lang_decl));
> + DECL_LANG_SPECIFIC (decl)
> + = (struct lang_decl *) ggc_internal_cleared_alloc (sizeof
> + (struct lang_decl));
> }
>
> /* Remember a symbol to generate initialization/cleanup code at function
> diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
> index 243feb7..84503ce 100644
> --- a/gcc/fortran/trans-types.c
> +++ b/gcc/fortran/trans-types.c
> @@ -1512,7 +1512,8 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec *
> as, gfc_packed packed,
>
> GFC_ARRAY_TYPE_P (type) = 1;
> TYPE_LANG_SPECIFIC (type)
> - = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> + = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
>
> known_stride = (packed != PACKED_NO);
> known_offset = 1;
> @@ -1815,7 +1816,8 @@ gfc_get_array_type_bounds (tree etype, int dimen, int
> codimen, tree * lbound,
>
> GFC_DESCRIPTOR_TYPE_P (fat_type) = 1;
> TYPE_LANG_SPECIFIC (fat_type)
> - = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> + = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
>
> GFC_TYPE_ARRAY_RANK (fat_type) = dimen;
> GFC_TYPE_ARRAY_CORANK (fat_type) = codimen;
> @@ -1990,7 +1992,8 @@ gfc_nonrestricted_type (tree t)
>
> if (!TYPE_LANG_SPECIFIC (t))
> TYPE_LANG_SPECIFIC (t)
> - = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> + = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
> /* If we're dealing with this very node already further up
> the call chain (recursion via pointers and struct members)
> we haven't yet determined if we really need a new type node.
> @@ -2042,8 +2045,8 @@ gfc_nonrestricted_type (tree t)
> if (dataptr_type != GFC_TYPE_ARRAY_DATAPTR_TYPE (t))
> {
> TYPE_LANG_SPECIFIC (ret)
> - = ggc_alloc_cleared_lang_type (sizeof (struct
> - lang_type));
> + = (struct lang_type *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_type));
> *TYPE_LANG_SPECIFIC (ret) = *TYPE_LANG_SPECIFIC (t);
> GFC_TYPE_ARRAY_DATAPTR_TYPE (ret) = dataptr_type;
> }
> diff --git a/gcc/gengtype.c b/gcc/gengtype.c
> index e8fcd9f..b3c966c 100644
> --- a/gcc/gengtype.c
> +++ b/gcc/gengtype.c
> @@ -4967,6 +4967,9 @@ write_typed_alloc_def (outf_p f,
> enum alloc_quantity quantity)
> {
> bool two_args = variable_size && (quantity == vector);
> + if (variable_size)
> + return;
> +
It appears that two_args will be unused after this change, but as said,
I'd like to keep the typed allocators.
What is the actual problem you are solving?
Thanks,
Richard.
> gcc_assert (f != NULL);
> const char *type_name_as_id = filter_type_name (type_name);
> oprintf (f, "#define ggc_alloc_%s%s", allocator_type, type_name_as_id);
> diff --git a/gcc/ggc.h b/gcc/ggc.h
> index 0af69f5..736305d 100644
> --- a/gcc/ggc.h
> +++ b/gcc/ggc.h
> @@ -230,7 +230,7 @@ extern void stringpool_statistics (void);
> extern void init_ggc_heuristics (void);
>
> #define ggc_alloc_rtvec_sized(NELT) \
> - ggc_alloc_rtvec_def (sizeof (struct rtvec_def) \
> + (rtvec_def *) ggc_internal_alloc (sizeof (struct rtvec_def) \
> + ((NELT) - 1) * sizeof (rtx)) \
>
> /* Memory statistics passing versions of some allocators. Too few of them to
> diff --git a/gcc/java/class.c b/gcc/java/class.c
> index bbe7c86..94c2568 100644
> --- a/gcc/java/class.c
> +++ b/gcc/java/class.c
> @@ -765,7 +765,8 @@ add_method_1 (tree this_class, int access_flags, tree
> name, tree function_type)
> DECL_CONTEXT (fndecl) = this_class;
>
> DECL_LANG_SPECIFIC (fndecl)
> - = ggc_alloc_cleared_lang_decl(sizeof (struct lang_decl));
> + = (struct lang_decl *) ggc_internal_cleared_alloc
> + (sizeof (struct lang_decl));
> DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC;
>
> /* Initialize the static initializer test table. */
> diff --git a/gcc/java/constants.c b/gcc/java/constants.c
> index c0295e9..51449ef 100644
> --- a/gcc/java/constants.c
> +++ b/gcc/java/constants.c
> @@ -48,9 +48,9 @@ set_constant_entry (CPool *cpool, int index, int tag, jword
> value)
> cpool->capacity = 100;
> cpool->tags = (uint8 *) ggc_internal_cleared_alloc (sizeof (uint8)
> * cpool->capacity);
> - cpool->data = ggc_alloc_cleared_vec_cpool_entry (sizeof
> - (union cpool_entry),
> - cpool->capacity);
> + cpool->data = (cpool_entry *) ggc_internal_cleared_alloc (sizeof
> + (union cpool_entry)
> + * cpool->capacity);
> cpool->count = 1;
> }
> if (index >= cpool->capacity)
> diff --git a/gcc/java/decl.c b/gcc/java/decl.c
> index 53d6f89..9f2f0ca 100644
> --- a/gcc/java/decl.c
> +++ b/gcc/java/decl.c
> @@ -1646,7 +1646,7 @@ java_dup_lang_specific_decl (tree node)
> return;
>
> lang_decl_size = sizeof (struct lang_decl);
> - x = ggc_alloc_lang_decl (lang_decl_size);
> + x = (struct lang_decl *) ggc_internal_alloc (lang_decl_size);
> memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size);
> DECL_LANG_SPECIFIC (node) = x;
> }
> diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
> index 806d2d7..43a8258 100644
> --- a/gcc/java/java-tree.h
> +++ b/gcc/java/java-tree.h
> @@ -700,7 +700,8 @@ union GTY((desc ("TREE_CODE (&%h.generic) ==
> IDENTIFIER_NODE"),
> if (DECL_LANG_SPECIFIC (T) == NULL) \
> { \
> DECL_LANG_SPECIFIC ((T)) \
> - = ggc_alloc_cleared_lang_decl (sizeof (struct lang_decl)); \
> + = (struct lang_decl *) ggc_internal_cleared_alloc \
> + (sizeof (struct lang_decl)); \
> DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR; \
> }
>
> @@ -826,7 +827,8 @@ struct GTY((variable_size)) lang_decl {
> #define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \
> if (TYPE_LANG_SPECIFIC ((T)) == NULL) \
> TYPE_LANG_SPECIFIC ((T)) \
> - = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
> + = (struct lang_type *) ggc_internal_cleared_alloc \
> +(sizeof (struct lang_type)); \
>
> #define TYPE_DUMMY(T) (TYPE_LANG_SPECIFIC(T)->dummy_class)
>
> diff --git a/gcc/java/jcf-reader.c b/gcc/java/jcf-reader.c
> index 10def13..f25bbab 100644
> --- a/gcc/java/jcf-reader.c
> +++ b/gcc/java/jcf-reader.c
> @@ -341,7 +341,8 @@ jcf_parse_constant_pool (JCF* jcf)
> int i, n;
> JPOOL_SIZE (jcf) = (JCF_FILL (jcf, 2), JCF_readu2 (jcf));
> jcf->cpool.tags = (uint8 *) ggc_alloc_atomic (JPOOL_SIZE (jcf));
> - jcf->cpool.data = ggc_alloc_cpool_entry (sizeof (jword) * JPOOL_SIZE
> (jcf));
> + jcf->cpool.data = (cpool_entry *) ggc_internal_cleared_alloc
> + (sizeof (jword) * JPOOL_SIZE (jcf));
> jcf->cpool.tags[0] = 0;
> #ifdef HANDLE_START_CONSTANT_POOL
> HANDLE_START_CONSTANT_POOL (JPOOL_SIZE (jcf));
> diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h
> index 0c7fa04..a050727 100644
> --- a/gcc/objc/objc-act.h
> +++ b/gcc/objc/objc-act.h
> @@ -193,7 +193,8 @@ typedef enum objc_property_assign_semantics {
> #define ALLOC_OBJC_TYPE_LANG_SPECIFIC(NODE) \
> do { \
> TYPE_LANG_SPECIFIC (NODE) \
> - = ggc_alloc_cleared_lang_type (sizeof (struct lang_type)); \
> + = (struct lang_type *) ggc_internal_cleared_alloc \
> + (sizeof (struct lang_type)); \
> } while (0)
>
> #define TYPE_HAS_OBJC_INFO(TYPE) \
> diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
> index 03d3e4d..492eee7 100644
> --- a/gcc/tree-ssa-operands.c
> +++ b/gcc/tree-ssa-operands.c
> @@ -276,8 +276,8 @@ ssa_operand_alloc (struct function *fn, unsigned size)
> }
>
>
> - ptr = ggc_alloc_ssa_operand_memory_d (sizeof (void *)
> - + gimple_ssa_operands (fn)->ssa_operand_mem_size);
> + ptr = (ssa_operand_memory_d *) ggc_internal_alloc
> + (sizeof (void *) + gimple_ssa_operands (fn)->ssa_operand_mem_size);
>
> ptr->next = gimple_ssa_operands (fn)->operand_memory;
> gimple_ssa_operands (fn)->operand_memory = ptr;
> diff --git a/gcc/tree.c b/gcc/tree.c
> index aa74fd0..365faf2 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -1656,7 +1656,7 @@ build_string (int len, const char *str)
>
> record_node_allocation_statistics (STRING_CST, length);
>
> - s = ggc_alloc_tree_node (length);
> + s = (tree) ggc_internal_alloc (length);
>
> memset (s, 0, sizeof (struct tree_typed));
> TREE_SET_CODE (s, STRING_CST);
> @@ -10368,7 +10368,7 @@ build_omp_clause (location_t loc, enum
> omp_clause_code code)
>
> record_node_allocation_statistics (OMP_CLAUSE, size);
>
> - t = ggc_alloc_tree_node (size);
> + t = (tree) ggc_internal_alloc (size);
> memset (t, 0, size);
> TREE_SET_CODE (t, OMP_CLAUSE);
> OMP_CLAUSE_SET_CODE (t, code);
> diff --git a/gcc/varasm.c b/gcc/varasm.c
> index 8e8c5f6..3b42faa 100644
> --- a/gcc/varasm.c
> +++ b/gcc/varasm.c
> @@ -381,7 +381,7 @@ create_block_symbol (const char *label, struct
> object_block *block,
>
> /* Create the extended SYMBOL_REF. */
> size = RTX_HDR_SIZE + sizeof (struct block_symbol);
> - symbol = ggc_alloc_rtx_def (size);
> + symbol = (rtx) ggc_internal_alloc (size);
>
> /* Initialize the normal SYMBOL_REF fields. */
> memset (symbol, 0, size);
> --
> 2.0.0.rc0
>