This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[LTO][PATCH] Fix type comparion of unbounded arrays and assert in lto_file_decl_data_get_fn_decl


    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.

   The second problem was casued by a bug in copying the DECLs when
WPA copied a function.  In some cases, the existing code changed the
ordering of DECLs in the decl_states.  I replaced the existing code
with a verbatim copying of the tree vectors to make sure that it stays
the same after copying.  However, I still need to look at the reason
why DECL merging caused the change in numbering, that should not
happen in the first place but it is a seperate issue.


2008-10-30  Doug Kwan  <>

	* 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.

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);
 	      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,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]