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]

Test, please ignore


I'm testing the patch queuing system

:ADDPATCH test area:

blah blah blah

2005-07-17  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/22483
	
	* tree-complex.c (create_components): Use
	safe_referenced_var_iterator and FOR_EACH_REFERENCED_VAR_SAFE.
	* tree-flow-inline.h (fill_referenced_var_vec): New function.
	* tree-flow.h (safe_referenced_var_iterator): New structure.
	(FOR_EACH_REFERENCED_VAR_SAFE): New macro.
	* tree-ssa-alias.c (setup_pointers_and_addressables): Use
	safe_referenced_var iterator.
	(add_type_alias): Ditto.

Index: tree-complex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-complex.c,v
retrieving revision 2.35
diff -u -p -r2.35 tree-complex.c
--- tree-complex.c	8 Jul 2005 18:05:03 -0000	2.35
+++ tree-complex.c	17 Jul 2005 18:09:43 -0000
@@ -386,7 +386,8 @@ create_components (void)
 {
   size_t n;
   tree var;
-  referenced_var_iterator rvi;
+  safe_referenced_var_iterator rvi;
+  VEC (tree, heap) *refvars;
 
   n = num_referenced_vars;
   if (n == 0)
@@ -395,7 +396,7 @@ create_components (void)
   complex_variable_components = htab_create (10,  int_tree_map_hash,
 					     int_tree_map_eq, free);
 
-  FOR_EACH_REFERENCED_VAR (var, rvi)
+  FOR_EACH_REFERENCED_VAR_SAFE (var, refvars, rvi)
     {
       tree r = NULL, i = NULL;
 
@@ -442,6 +443,7 @@ create_components (void)
       cvc_insert (2 * DECL_UID (var), r);
       cvc_insert (2 * DECL_UID (var) + 1, i);
     }
+  VEC_free (tree, heap, refvars);
 }
 
 /* Extract the real or imaginary part of a complex variable or constant.
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow-inline.h,v
retrieving revision 2.52
diff -u -p -r2.52 tree-flow-inline.h
--- tree-flow-inline.h	10 Jul 2005 00:27:50 -0000	2.52
+++ tree-flow-inline.h	17 Jul 2005 18:09:44 -0000
@@ -105,7 +105,19 @@ next_referenced_var (referenced_var_iter
     return NULL;
   return itm->to;
 } 
- 
+
+/* Fill up VEC with the variables in the referenced vars hashtable.  */
+
+static inline void
+fill_referenced_var_vec (VEC (tree, heap) **vec)
+{
+  referenced_var_iterator rvi;
+  tree var;
+  *vec = NULL;
+  FOR_EACH_REFERENCED_VAR (var, rvi)
+    VEC_safe_push (tree, heap, *vec, var);
+}
+
 /* Return the variable annotation for T, which must be a _DECL node.
    Return NULL if the variable annotation doesn't already exist.  */
 static inline var_ann_t
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.126
diff -u -p -r2.126 tree-flow.h
--- tree-flow.h	16 Jul 2005 18:56:52 -0000	2.126
+++ tree-flow.h	17 Jul 2005 18:09:44 -0000
@@ -389,11 +389,35 @@ typedef struct 
 } referenced_var_iterator;
 
 
+/* This macro loops over all the referenced vars, one at a time, putting the
+   current var in VAR.  Note:  You are not allowed to add referenced variables
+   to the hashtable while using this macro.  Doing so may cause it to behave
+   erratically.  */
+
 #define FOR_EACH_REFERENCED_VAR(VAR, ITER) \
   for ((VAR) = first_referenced_var (&(ITER)); \
        !end_referenced_vars_p (&(ITER)); \
        (VAR) = next_referenced_var (&(ITER))) 
 
+
+typedef struct
+{
+  int i;
+} safe_referenced_var_iterator;
+
+/* This macro loops over all the referenced vars, one at a time, putting the
+   current var in VAR.  You are allowed to add referenced variables during the
+   execution of this macro, however, the macro will not iterate over them.  It
+   requires a temporary vector of trees, VEC, whose lifetime is controlled by
+   the caller.  The purpose of the vector is to temporarily store the
+   referenced_variables hashtable so that adding referenced variables does not
+   affect the hashtable.  */
+
+#define FOR_EACH_REFERENCED_VAR_SAFE(VAR, VEC, ITER) \
+  for ((ITER).i = 0, fill_referenced_var_vec (&(VEC)); \
+       VEC_iterate (tree, (VEC), (ITER).i, (VAR)); \
+       (ITER).i++)
+
 /* Array of all variables referenced in the function.  */
 extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars;
 
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.104
diff -u -p -r2.104 tree-ssa-alias.c
--- tree-ssa-alias.c	16 Jul 2005 18:56:52 -0000	2.104
+++ tree-ssa-alias.c	17 Jul 2005 18:09:45 -0000
@@ -1168,6 +1168,8 @@ setup_pointers_and_addressables (struct 
   size_t n_vars, num_addressable_vars, num_pointers;
   referenced_var_iterator rvi;
   tree var;
+  VEC (tree, heap) *varvec = NULL;
+  safe_referenced_var_iterator srvi;
 
   /* Size up the arrays ADDRESSABLE_VARS and POINTERS.  */
   num_addressable_vars = num_pointers = 0;
@@ -1204,7 +1206,7 @@ setup_pointers_and_addressables (struct 
      unnecessarily.  */
   n_vars = num_referenced_vars;
 
-  FOR_EACH_REFERENCED_VAR (var, rvi)
+  FOR_EACH_REFERENCED_VAR_SAFE (var, varvec, srvi)
     {
       var_ann_t v_ann = var_ann (var);
       subvar_t svars;
@@ -1336,6 +1338,7 @@ setup_pointers_and_addressables (struct 
 	    }
 	}
     }
+  VEC_free (tree, heap, varvec);
 }
 
 
@@ -2218,14 +2221,14 @@ add_type_alias (tree ptr, tree var)
   tree tag;
   var_ann_t ann = var_ann (ptr);
   subvar_t svars;
-  
+  VEC (tree, heap) *varvec = NULL;  
 
   if (ann->type_mem_tag == NULL_TREE)
     {
       tree q = NULL_TREE;
       tree tag_type = TREE_TYPE (TREE_TYPE (ptr));
       HOST_WIDE_INT tag_set = get_alias_set (tag_type);
-      referenced_var_iterator rvi;
+      safe_referenced_var_iterator rvi;
 
       /* PTR doesn't have a type tag, create a new one and add VAR to
 	 the new tag's alias set.
@@ -2234,7 +2237,7 @@ add_type_alias (tree ptr, tree var)
 	 whether there is another pointer Q with the same alias set as
 	 PTR.  This could be sped up by having type tags associated
 	 with types.  */
-      FOR_EACH_REFERENCED_VAR (q, rvi)
+      FOR_EACH_REFERENCED_VAR_SAFE (q, varvec, rvi)
 	{
 	  if (POINTER_TYPE_P (TREE_TYPE (q))
 	      && tag_set == get_alias_set (TREE_TYPE (TREE_TYPE (q))))
@@ -2292,6 +2295,7 @@ found_tag:
       for (i = 0; i < VARRAY_ACTIVE_SIZE (aliases); i++)
 	mark_sym_for_renaming (VARRAY_TREE (aliases, i));
     }
+  VEC_free (tree, heap, varvec);
 }
 
 
@@ -2766,7 +2770,8 @@ static void
 create_structure_vars (void)
 {
   basic_block bb;
-  referenced_var_iterator rvi;
+  safe_referenced_var_iterator rvi;
+  VEC (tree, heap) *varvec = NULL;
   tree var;
 
   used_portions = htab_create (10, used_part_map_hash, used_part_map_eq, 
@@ -2782,7 +2787,7 @@ create_structure_vars (void)
 					NULL);
 	}
     }
-  FOR_EACH_REFERENCED_VAR (var, rvi)
+  FOR_EACH_REFERENCED_VAR_SAFE (var, varvec, rvi)
     {
       /* The C++ FE creates vars without DECL_SIZE set, for some reason.  */
       if (var 	  
@@ -2793,6 +2798,7 @@ create_structure_vars (void)
 	create_overlap_variables_for (var);
     }
   htab_delete (used_portions);
+  VEC_free (tree, heap, varvec);
 
 }
 

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