https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124261
Bug ID: 124261
Summary: Memory read disambiguated by clang but not by gcc
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
Target Milestone: ---
struct a {int a, b,c,d,e,g;};
struct a ret();
int
test (int o)
{
struct a aa,cc;
struct a *bb = o ? &aa : &cc;
int *p = o ? &aa.b : &cc.b;
int *q = o ? &aa.a : &cc.a;
*bb = ret ();
*p = 12345;
*q = 0;
return *p;
}
This optimizes to
callq ret@PLT
movq 24(%rsp), %rax
movq %rax, 16(%rbx)
movups 8(%rsp), %xmm0
movups %xmm0, (%rbx)
movabsq $53021371269120, %rax # imm = 0x303900000000
movq %rax, (%rbx)
movl $12345, %eax # imm = 0x3039
addq $80, %rsp
so return of 12345 is visible. While GCC can not track this
call ret
movl $12345, (%rbx)
movl $0, 0(%rbp)
movl (%rbx), %eax
addq $72, %rsp