------- Comment #4 from rguenth at gcc dot gnu dot org  2008-05-30 10:58 -------
Umm.  It's worse.

With -O2 -fno-tree-sra:

extern void abort (void);
struct Foo {
    int *p;
} x;
struct Foo __attribute__((noinline))
bar(int *p)
{
  struct Foo f;
  f.p = p;
  return f;
}
void __attribute__((noinline))
foo()
{
  *x.p = 0;
}
int main()
{
  int b;
  b = 1;
  struct Foo g = bar (&b);
  x = g;
  foo();
  if (b != 0)
    abort ();
  return 0;
}


the escape through the global x doesn't work either.  SRA "fixes" this by

  # g_7 = VDEF <g_6(D)>
  g = bar (&b);
  # VUSE <g_7>
  g$p_2 = g.p; 
  # x_9 = VDEF <x_8(D)>
  x.p = g$p_2;

where we (after partial fixes) compute the points-to set of g$p_2 correctly
and thus mark that pointer as escaping to a global in the next stmt.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36373

Reply via email to