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]

Re: --disable-checking bootstrap failure


On Mon, 2004-09-13 at 15:52, Jeffrey A Law wrote:

> Alternately, if you can send me a .i file, I might be able to
> take a looksie tomorrow.
> 
That's OK.  DOM wasn't at fault.

DOM was being tricked by faulty aliasing information.  Taking the
address of &PTR->FIELD is not handled with any degree of gracefulness. 
I'm bootstrapping this fix.  Will commit if all goes well.


Diego.


2004-09-13  Diego Novillo  <dnovillo@redhat.com>

	* tree-ssa-alias.c (setup_pointers_and_addressables): Add type
	tags to ai->addressable_vars if they are of a non-aggregate
	type.

Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.33
diff -d -c -p -u -r2.33 tree-ssa-alias.c
--- tree-ssa-alias.c	11 Sep 2004 18:57:03 -0000	2.33
+++ tree-ssa-alias.c	13 Sep 2004 19:29:45 -0000
@@ -1244,7 +1244,7 @@ setup_pointers_and_addressables (struct 
      because some TREE_ADDRESSABLE variables will be marked
      non-addressable below and only pointers with unique type tags are
      going to be added to POINTERS.  */
-  ai->addressable_vars = xcalloc (num_addressable_vars,
+  ai->addressable_vars = xcalloc (num_addressable_vars + num_pointers,
 				  sizeof (struct alias_map_d *));
   ai->pointers = xcalloc (num_pointers, sizeof (struct alias_map_d *));
   ai->num_addressable_vars = 0;
@@ -1262,8 +1262,9 @@ setup_pointers_and_addressables (struct 
 
       /* Name memory tags already have flow-sensitive aliasing
 	 information, so they need not be processed by
-	 compute_may_aliases.  Similarly, type memory tags are already
-	 accounted for when we process their associated pointer.  */
+	 compute_flow_insensitive_aliasing.  Similarly, type memory
+	 tags are already accounted for when we process their
+	 associated pointer.  */
       if (v_ann->mem_tag_kind != NOT_A_TAG)
 	continue;
 
@@ -1351,6 +1352,36 @@ setup_pointers_and_addressables (struct 
 
 	      VARRAY_UINT (ai->num_references, t_ann->uid)
 		+= VARRAY_UINT (ai->num_references, v_ann->uid);
+
+	      /* FIXME.  Compensate for the lack of field-sensitive
+		 aliasing information.  Since this analysis is based
+		 exclusively on symbols, it fails to handle cases
+		 where a pointer takes the address of a structure
+		 field.  Consider testsuite/gcc.dg/tree-ssa/20040319-1.c:
+
+			struct bar { int count;  int *arr;};
+
+			void foo (struct bar *b)
+			{
+			  b->count = 0;
+			  *(b->arr) = 2;
+			  if (b->count == 0)
+			    abort ();
+			}
+
+		 b->count and *(b->arr) could be aliased if b->arr ==
+		 &b->count.  But since there is no symbol that aliases
+		 with both b->arr and b->count, we miss the
+		 relationship.
+
+		 So, if the pointed-to type is a structure, add TAG to
+		 AI->ADDRESSABLE_VARS to be handled by
+		 compute_flow_insensitive_aliasing.  We only need to
+		 do this for aggregate types because pointer of scalar
+		 types will either share the same type tag or have a
+		 symbol in common.  */
+	      if (AGGREGATE_TYPE_P (TREE_TYPE (tag)))
+		create_alias_map_for (tag, ai);
 	    }
 	  else
 	    {
@@ -1367,41 +1398,6 @@ setup_pointers_and_addressables (struct 
 	    }
 	}
     }
-
-  /* If we found no addressable variables, but we have more than one
-     pointer, we will need to check for conflicts between the
-     pointers.  Otherwise, we would miss alias relations as in
-     testsuite/gcc.dg/tree-ssa/20040319-1.c:
-
-		struct bar { int count;  int *arr;};
-
-		void foo (struct bar *b)
-		{
-		  b->count = 0;
-		  *(b->arr) = 2;
-		  if (b->count == 0)
-		    abort ();
-		}
-
-     b->count and *(b->arr) could be aliased if b->arr == &b->count.
-     To do this, we add all the memory tags for the pointers in
-     AI->POINTERS to AI->ADDRESSABLE_VARS, so that
-     compute_flow_insensitive_aliasing will naturally compare every
-     pointer to every type tag.  */
-  if (ai->num_addressable_vars == 0
-      && ai->num_pointers > 1)
-    {
-      free (ai->addressable_vars);
-      ai->addressable_vars = xcalloc (ai->num_pointers,
-				      sizeof (struct alias_map_d *));
-      ai->num_addressable_vars = 0;
-      for (i = 0; i < ai->num_pointers; i++)
-	{
-	  struct alias_map_d *p = ai->pointers[i];
-	  tree tag = var_ann (p->var)->type_mem_tag;
-	  create_alias_map_for (tag, ai);
-	}
-    }
 }


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