[LTO][PATCH] Fix type comparion of unbounded arrays and assert in lto_file_decl_data_get_fn_decl
Diego Novillo
dnovillo@google.com
Fri Oct 31 01:02:00 GMT 2008
On Thu, Oct 30, 2008 at 18:25, Doug Kwan (關振德) <dougkwan@google.com> wrote:
> This patch fixes two issues found by our testing. The first one
> was found in comparing types of external unbounded arrays (.e.g extern
> int foo [];). Currently, the associated type of such an array has no
> TYPE_DOMAIN. That is different from a static array variable where gcc
> tries to complete the type and make a TYPE_DOMAIN with zero as lower
> bound and NULL_TREE as the upperbound. If anyone thinks that I should
> make the external array vars like the internal one, let me know and I
> can make that change. I prefer the current fix as it is simpler.
Agreed.
> 2008-10-30 Doug Kwan <dougkwan@google.com>
>
> * lto-symtab.c (lto_same_type_p): Handle the case in which both
> array types have NULL TYPE_DOMAIN.
> * lto-function-out.c (copy_function): Copy tree vectors in decl
> states verbatim.
OK. Thanks.
Diego.
>
>
> Index: gcc/gcc/lto-symtab.c
> ===================================================================
> --- gcc/gcc/lto-symtab.c (revision 141465)
> +++ gcc/gcc/lto-symtab.c (working copy)
> @@ -204,8 +204,10 @@ lto_same_type_p (tree type_1, tree type_
> {
> tree index_1 = TYPE_DOMAIN (type_1);
> tree index_2 = TYPE_DOMAIN (type_2);
> + /* For an incomplete external array, the type domain can be
> + NULL_TREE. Check this condition also. */
> if (!index_1 || !index_2)
> - return false;
> + return (!index_1 && !index_2);
> else
> {
> tree min_1 = TYPE_MIN_VALUE (index_1);
> Index: gcc/gcc/lto-function-out.c
> ===================================================================
> --- gcc/gcc/lto-function-out.c (revision 141465)
> +++ gcc/gcc/lto-function-out.c (working copy)
> @@ -2353,10 +2353,14 @@ copy_function (struct cgraph_node *node)
> size_t n = in_state->streams[i].size;
> tree *trees = in_state->streams[i].trees;
> struct lto_tree_ref_encoder *encoder = &(out_state->streams[i]);
> - unsigned int dummy = 0;
>
> + /* The out state must have the same indices and the in state.
> + So just copy the vector. All the encoders in the in state
> + must be empty where we reach here. */
> + gcc_assert (lto_tree_ref_encoder_size (encoder) == 0);
> for (j = 0; j < n; j++)
> - lto_output_decl_index (NULL, encoder, trees[j], &dummy);
> + VEC_safe_push (tree, heap, encoder->trees, trees[j]);
> + encoder->next_index = n;
> }
>
> lto_free_section_data (file_data, LTO_section_function_body, name,
>
More information about the Gcc-patches
mailing list