This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug lto/61969] [4.8/4.9/5 Regression] wrong code by LTO on i?86-linux-gnu (affecting trunk, 4.9.x, and 4.8.x)
- From: "andi-gcc at firstfloor dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 28 Sep 2014 06:23:02 +0000
- Subject: [Bug lto/61969] [4.8/4.9/5 Regression] wrong code by LTO on i?86-linux-gnu (affecting trunk, 4.9.x, and 4.8.x)
- Auto-submitted: auto-generated
- References: <bug-61969-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61969
--- Comment #4 from Andi Kleen <andi-gcc at firstfloor dot org> ---
The problem is when returning a struct from func_52:
const struct S0 func_52 (uint32_t p_53)
{
const struct S0 l_55 = { 4, 40290, 10, 4 };
return l_55;
}
The main code stores the struct value from the stack into the global variable
and eventually prints it
80482f4: 83 ec 38 sub $0x38,%esp
80482f7: 0f b6 15 4c da 04 08 movzbl 0x804da4c,%edx
80482fe: 8b 1d 20 d1 04 08 mov 0x804d120,%ebx
8048304: 0f b6 35 70 da 04 08 movzbl 0x804da70,%esi
804830b: e8 b0 0c 00 00 call 8048fc0 <func_52>
8048310: 0f b7 45 d2 movzwl -0x2e(%ebp),%eax
8048314: ba 01 00 00 00 mov $0x1,%edx
8048319: c7 05 20 d1 04 08 48 movl $0x804da48,0x804d120
8048320: da 04 08
8048323: 66 a3 5c da 04 08 mov %ax,0x804da5c
But func_52 has been completely optimized away and puts nothing onto the stack:
08048fc0 <func_52>:
8048fc0: f3 c3 repz ret
8048fc2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
8048fc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
So the value is random stack garbage.