This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/36373] [4.2/4.3/4.4 Regression] Wrong code with struct return
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 May 2008 10:58:14 -0000
- Subject: [Bug tree-optimization/36373] [4.2/4.3/4.4 Regression] Wrong code with struct return
- References: <bug-36373-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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