The hack in may_alias_p we used to have was papering over the real problem and causing problems (PR 22591). The real fix is to notice in the aliaser that a default definition for a PARM_DECL cannot possibly point to a local variable. Test XFAIL'd for now. Fix scheduled for 4.2.
Confirmed.
Isn't this a simple fix to may_alias_p saying that PARM_DECLs cannot alias local variables? unless I am missing something obvious.
Subject: Re: aliasing information in gcc.dg/tree-ssa/20030807-7.c should be fixed properly On Wed, Jul 27, 2005 at 08:34:10PM -0000, pinskia at gcc dot gnu dot org wrote: > Isn't this a simple fix to may_alias_p saying that PARM_DECLs > cannot alias local variables? > It isn't. Only a default_def of a PARM_DECL is guaranteed not to point into any local. may_alias_p is flow-insensitive, so it can only return answers that apply to *all* the SSA names for a DECL.
I must be missing something ovbious since that did not fix it.
*** Bug 25558 has been marked as a duplicate of this bug. ***
Here is a reduced testcase, which I found independently: void link_error(void); int *t; int g(int *a) { t = a; *a = 2; } void f(int *a) { int b; b = 1; g(&b); b = 2; *a = 1; <--- a cannot point to b here. if (b == 2) link_error(); } int main(void) { int t; f(&t); return 0; }
*** Bug 26609 has been marked as a duplicate of this bug. ***
*** Bug 35359 has been marked as a duplicate of this bug. ***
We could simply prune locals from points-to solutions for default defs.
*a = 1; <--- a cannot point to b here. if (b == 2) b != 2 you mean. This works for me with 4.0.4 even. Likely optimized on RTL level? Adjusted testcase: extern void link_error (void); extern void abort (void); int *t; int __attribute__((noinline)) g(int *a) { t = a; *a = 2; } void __attribute__((noinline)) f(int *a) { int b; b = 1; g(&b); b = 2; *a = 1; if (b != 2) link_error(); } int main(void) { int t; f(&t); if (t != 1) abort (); return 0; } On trunk we now have f (int * a) { int b; <bb 2>: b = 1; g (&b); *a = 1; return; }
Subject: Bug 23086 Author: rguenth Date: Fri Apr 3 12:38:08 2009 New Revision: 145499 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145499 Log: 2009-04-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/2480 PR tree-optimization/23086 * gcc.dg/tree-ssa/pr2480.c: New testcase. * gcc.dg/tree-ssa/pr23086.c: Likewise. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr23086.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr2480.c Modified: trunk/gcc/testsuite/ChangeLog