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][4.1] Fix PR26258


This fixes PR26258, a missing special case for computing PTA information.

Bootstrapped and tested on ia64-unknown-linux-gnu for 4.1 branch.

Ok for 4.1 branch?  (I have a similar patch for mainline, but DannyB is
supposed to come up with a more suitable patch there)

Thanks,
Richard.

:ADDPATCH alias:

2006-02-13  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-structalias.c (find_func_aliases): Handle aggregates
	in PHI argument processing.

	* gcc.dg/tree-ssa/alias-13.c: New testcase.

Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c	(revision 110912)
--- tree-ssa-structalias.c	(working copy)
*************** find_func_aliases (tree t, struct alias_
*** 2883,2890 ****
  	  lhs = get_constraint_for (PHI_RESULT (t), NULL);
  	  for (i = 0; i < PHI_NUM_ARGS (t); i++)
  	    {
! 	      rhs = get_constraint_for (PHI_ARG_DEF (t, i), NULL);
  	      process_constraint (new_constraint (lhs, rhs));
  	    }
  	}
      }
--- 2883,2907 ----
  	  lhs = get_constraint_for (PHI_RESULT (t), NULL);
  	  for (i = 0; i < PHI_NUM_ARGS (t); i++)
  	    {
! 	      bool need_anyoffset = false;
! 	      tree anyoffsetrhs = PHI_ARG_DEF (t, i);
! 
! 	      rhs = get_constraint_for (PHI_ARG_DEF (t, i), &need_anyoffset);
  	      process_constraint (new_constraint (lhs, rhs));
+ 
+ 	      STRIP_NOPS (anyoffsetrhs);
+ 	      /* When taking the address of an aggregate
+ 	         type, from the LHS we can access any field
+ 	         of the RHS.  */
+ 	      if (need_anyoffset || (rhs.type == ADDRESSOF
+ 		  && !(get_varinfo (rhs.var)->is_special_var)
+ 		  && AGGREGATE_TYPE_P (TREE_TYPE (TREE_TYPE (anyoffsetrhs)))))
+ 		{
+ 		  rhs.var = anyoffset_id;
+ 		  rhs.type = ADDRESSOF;
+ 		  rhs.offset = 0;
+ 		  process_constraint (new_constraint (lhs, rhs));
+ 		}
  	    }
  	}
      }
Index: testsuite/gcc.dg/alias-13.c
===================================================================
*** testsuite/gcc.dg/alias-13.c	(revision 0)
--- testsuite/gcc.dg/alias-13.c	(revision 0)
***************
*** 0 ****
--- 1,29 ----
+ /* { dg-do run } */
+ /* { dg-options "-O2" } */
+ 
+ extern void abort(void);
+ 
+ typedef struct Foo { int a; int b; }  Foo;
+ 
+ Foo foo(Foo first, Foo last, _Bool ret_first)
+ {
+   Foo t;
+   Foo *t1 = (ret_first ? &first : &last);
+   first.a = 2;
+   last.b = 3;
+   t.a = t1->a;
+   t.b = t1->b;
+   t.a += first.a;
+   t.b += last.b;
+   return t;
+ }
+ 
+ int main()
+ {
+   Foo first = (Foo){1, 2};
+   Foo last = (Foo){3, 4};
+   Foo ret = foo(first, last, 0);
+   if (ret.b != 6)
+     abort ();
+   return 0;
+ }


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