This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[tree-ssa] Fix PR 14662


I finally could reproduce the bootstrap problem reported in PR 14662. 
We were writing beyond the end of a malloc'd array.  That'll teach me to
use varrays when they may change size.

Joost, could you update your tree and try bootstrapping again on the
same machine?

Bootstrapped and tested x86, x86-64 and ia64.


Diego.

	* tree-ssa-alias.c (struct alias_info): Change type of field
	'num_references' to varray_type.  Update all users.


Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-alias.c,v
retrieving revision 1.1.2.15
diff -d -c -p -d -u -p -r1.1.2.15 tree-ssa-alias.c
--- tree-ssa-alias.c	20 Mar 2004 03:59:45 -0000	1.1.2.15
+++ tree-ssa-alias.c	25 Mar 2004 15:46:32 -0000
@@ -98,7 +98,7 @@ struct alias_info
   /* Array of counters to keep track of how many times each pointer has
      been dereferenced in the program.  This is used by the alias grouping
      heuristic in compute_flow_insensitive_aliasing.  */
-  size_t *num_references;
+  varray_type num_references;
 
   /* Total number of virtual operands that will be needed to represent
      all the aliases of all the pointers found in the program.  */
@@ -369,13 +369,9 @@ init_alias_info (void)
 
   ai = xcalloc (1, sizeof (struct alias_info));
   ai->ssa_names_visited = BITMAP_XMALLOC ();
-  VARRAY_TREE_INIT (ai->processed_ptrs, 20, "processed_ptrs");
+  VARRAY_TREE_INIT (ai->processed_ptrs, 50, "processed_ptrs");
   ai->addresses_needed = BITMAP_XMALLOC ();
-  /* FIXME.  We probably want a hash table here.  This array has to
-     be big enough to hold the existing variables and the memory tags
-     created during alias analysis.  Since we can't create more than 2 tags
-     per pointer, 3 times the number of referenced vars is enough.  */
-  ai->num_references = xcalloc (3 * num_referenced_vars, sizeof (size_t));
+  VARRAY_UINT_INIT (ai->num_references, num_referenced_vars, "num_references");
   ai->written_vars = BITMAP_XMALLOC ();
   ai->dereferenced_ptrs_store = BITMAP_XMALLOC ();
   ai->dereferenced_ptrs_load = BITMAP_XMALLOC ();
@@ -409,7 +405,7 @@ delete_alias_info (struct alias_info *ai
     }
   free (ai->pointers);
 
-  free (ai->num_references);
+  ai->num_references = NULL;
   BITMAP_FREE (ai->written_vars);
   BITMAP_FREE (ai->dereferenced_ptrs_store);
   BITMAP_FREE (ai->dereferenced_ptrs_load);
@@ -587,8 +583,15 @@ compute_points_to_and_addr_escape (struc
 	      ssa_name_ann_t ptr_ann;
 	      bool is_store;
 
+	      /* If the operand's variable may be aliased, keep track
+		 of how many times we've referenced it.  This is used
+		 for alias grouping in compute_flow_sensitive_aliasing.
+		 Note that we don't need to grow AI->NUM_REFERENCES
+		 because we are processing regular variables, not
+		 memory tags (the array's initial size is set to
+		 NUM_REFERENCED_VARS).  */
 	      if (may_be_aliased (SSA_NAME_VAR (op)))
-		ai->num_references[v_ann->uid]++;
+		(VARRAY_UINT (ai->num_references, v_ann->uid))++;
 
 	      if (!POINTER_TYPE_P (TREE_TYPE (op)))
 		continue;
@@ -610,8 +613,10 @@ compute_points_to_and_addr_escape (struc
 		    ptr_ann->name_mem_tag = get_nmt_for (op);
 
 		  /* Keep track of how many time we've dereferenced each
-		     pointer.  */
-		  ai->num_references[v_ann->uid]++;
+		     pointer.  Again, we don't need to grow
+		     AI->NUM_REFERENCES because we're processing
+		     existing program variables.  */
+		  (VARRAY_UINT (ai->num_references, v_ann->uid))++;
 
 		  /* If this is a store operation, mark OP as being
 		     dereferenced to store, otherwise mark it as being
@@ -648,7 +653,7 @@ compute_points_to_and_addr_escape (struc
 	      var_ann_t ann = var_ann (var);
 	      bitmap_set_bit (ai->written_vars, ann->uid);
 	      if (may_be_aliased (var))
-		ai->num_references[ann->uid]++;
+		(VARRAY_UINT (ai->num_references, ann->uid))++;
 	    }
 
 	  /* Mark variables in VDEF operands as being written to.  */
@@ -804,8 +809,10 @@ compute_flow_insensitive_aliasing (struc
 	     
 	  if (may_alias_p (p_map->var, p_map->set, var, v_map->set))
 	    {
-	      size_t num_tag_refs = ai->num_references[tag_ann->uid];
-	      size_t num_var_refs = ai->num_references[v_ann->uid];
+	      size_t num_tag_refs, num_var_refs;
+
+	      num_tag_refs = VARRAY_UINT (ai->num_references, tag_ann->uid);
+	      num_var_refs = VARRAY_UINT (ai->num_references, v_ann->uid);
 
 	      /* Add VAR to TAG's may-aliases set.  */
 	      add_may_alias (tag, var);
@@ -870,7 +877,7 @@ group_aliases_into (tree tag, sbitmap ta
 {
   size_t i;
   var_ann_t tag_ann = var_ann (tag);
-  size_t num_tag_refs = ai->num_references[tag_ann->uid];
+  size_t num_tag_refs = VARRAY_UINT (ai->num_references, tag_ann->uid);
 
   EXECUTE_IF_SET_IN_SBITMAP (tag_aliases, 0, i,
     {
@@ -1214,8 +1221,14 @@ setup_pointers_and_addressables (struct 
 
 	  /* All the dereferences of pointer VAR count as references of
 	     TAG.  Since TAG can be associated with several pointers, add
-	     the dereferences of VAR to the TAG.  */
-	  ai->num_references[t_ann->uid] += ai->num_references[v_ann->uid];
+	     the dereferences of VAR to the TAG.  We may need to grow
+	     AI->NUM_REFERENCES because we have been adding name and
+	     type tags.  */
+	  if (t_ann->uid >= VARRAY_SIZE (ai->num_references))
+	    VARRAY_GROW (ai->num_references, t_ann->uid + 10);
+
+	  VARRAY_UINT (ai->num_references, t_ann->uid)
+	      += VARRAY_UINT (ai->num_references, v_ann->uid);
 	}
     }


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