[Bug ipa/88936] [7/8/9 Regression] -fipa-pta breaks bash (incorrect optimisation of recursive static function)

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Feb 5 10:50:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88936

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 45605
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45605&action=edit
prototype conservative fix

So this is a very conservative fix computing what automatic variables "escape"
and duplicating those with (a single) shadow variable.  It FAILs at least
the following test (though IPA PTA has low testsuite coverage)

FAIL: gcc.dg/ipa/ipa-pta-3.c scan-tree-dump fre3 "Replaced \\*p_2\\(D\\) with
1"

The testcase tests optimization on

static int __attribute__((noinline,noclone))
foo (int *p, int *q)
{
  *p = 1;
  *q = 0;
  return *p;
}

extern void abort (void);

int main()
{
  int a, b;
  if (foo (&a, &b) != 1)
    abort ();
  return 0;
}

where you see we now compute a and b as escaping and thus add SHADOW to
the points-to sets of both p and q making them appear aliasing.  Missed
optimizations of the patch are
 a) main isn't reached recursively so we never need shadow vars for a or b
 b) we could have used separate shadow vars for a and b

The patch has the opportunity to provide the missing local escaped solution.

In practice the opportunity to cut non-recursively reached functions is
probably low - I've yet have to identify a conservative way to compute this.


More information about the Gcc-bugs mailing list