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]

PATCH to compute_flow_insensitive_aliasing for c++/27768


The bug here was that there were some may_aliases in one alias set that never made it into the bitmap representation, so when that set was merged into another in group_aliases they were lost and so the store to w.p looked dead.

Fixed by explicitly copying the may_aliases from the annotations into the bitmap rather than expecting them to be recreated.

Tested x86_64-pc-linux-gnu, applied to trunk.
2006-06-28  Jason Merrill  <jason@redhat.com>

	PR c++/27768
	* tree-ssa-alias.c (compute_flow_insensitive_aliasing): Add
	may_aliases already in the tag's annotations to the bitmap.

Index: tree-ssa-alias.c
===================================================================
*** tree-ssa-alias.c	(revision 115018)
--- tree-ssa-alias.c	(working copy)
*************** compute_flow_insensitive_aliasing (struc
*** 1162,1167 ****
--- 1162,1168 ----
        struct alias_map_d *p_map = ai->pointers[i];
        tree tag = var_ann (p_map->var)->symbol_mem_tag;
        var_ann_t tag_ann = var_ann (tag);
+       tree var;
  
        /* Call-clobbering information is not finalized yet at this point.  */
        if (PTR_IS_REF_ALL (p_map->var))
*************** compute_flow_insensitive_aliasing (struc
*** 1170,1180 ****
        p_map->total_alias_vops = 0;
        p_map->may_aliases = BITMAP_ALLOC (&alias_obstack);
  
        for (j = 0; j < ai->num_addressable_vars; j++)
  	{
  	  struct alias_map_d *v_map;
  	  var_ann_t v_ann;
- 	  tree var;
  	  bool tag_stored_p, var_stored_p;
  	  
  	  v_map = ai->addressable_vars[j];
--- 1171,1185 ----
        p_map->total_alias_vops = 0;
        p_map->may_aliases = BITMAP_ALLOC (&alias_obstack);
  
+       /* Add any pre-existing may_aliases to the bitmap used to represent
+ 	 TAG's alias set in case we need to group aliases.  */
+       for (j = 0; VEC_iterate (tree, tag_ann->may_aliases, j, var); ++j)
+ 	bitmap_set_bit (p_map->may_aliases, DECL_UID (var));
+ 
        for (j = 0; j < ai->num_addressable_vars; j++)
  	{
  	  struct alias_map_d *v_map;
  	  var_ann_t v_ann;
  	  bool tag_stored_p, var_stored_p;
  	  
  	  v_map = ai->addressable_vars[j];
Index: testsuite/g++.dg/opt/alias4.C
===================================================================
*** testsuite/g++.dg/opt/alias4.C	(revision 0)
--- testsuite/g++.dg/opt/alias4.C	(revision 0)
***************
*** 0 ****
--- 1,56 ----
+ // PR c++/27768
+ // Alias grouping was losing some may_aliases, causing us to think
+ // the store to w.p was dead.
+ 
+ // { dg-do run }
+ // { dg-options "-O2" }
+ 
+ int N = 1;
+ 
+ struct VA
+ {
+   int *p, *q, *r;
+ 
+   VA() : p(), q() {}
+   VA(const VA&) : p(), q() {}
+   ~VA() { if (p) --N; }
+ };
+ 
+ inline void foo(VA, VA, VA) {}
+ 
+ struct VB
+ {
+   VA va;
+ 
+   VB() {}
+ 
+   VB(const VB&)
+   {
+     va.p = new int(va.q - va.p);
+     va.r = va.p + (va.q - va.p);
+     foo(va, va, va);
+   }
+ };
+ 
+ struct VC : VB { char c; };
+ struct V : VC {};
+ 
+ struct WA
+ {
+   struct X {};
+   X **p, **q, **r;
+ 
+   WA() : p() {}
+   ~WA() { if (p) --N; }
+ };
+ 
+ struct W : WA {};
+ 
+ int main()
+ {
+   {
+     V v, u(v);
+     W w;
+   }
+   return N;
+ }

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