[Bug ipa/80728] New: IPA-reference suppresses compiler memory barrier
amonakov at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri May 12 19:23:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80728
Bug ID: 80728
Summary: IPA-reference suppresses compiler memory barrier
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: amonakov at gcc dot gnu.org
Target Milestone: ---
Consider:
static int i;
static int b;
void sighandler(void)
{
b = i = 1;
}
__attribute__((noinline))
static int x(void)
{
asm volatile("":::"memory");
return b;
}
int f(void)
{
i = 0;
return x() ? i : 0;
}
This is compiled as expected with either -Dnoinline= , or with
-fno-ipa-reference, but otherwise IPA-reference suppresses the effect of
compiler memory barrier in 'x', causing 'f' to be optimized to 'return 0'.
A similar issue exists for atomic accesses (i.e. if x contained one rather than
the volatile asm).
More information about the Gcc-bugs
mailing list