This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/80728] New: IPA-reference suppresses compiler memory barrier
- From: "amonakov at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 12 May 2017 19:00:28 +0000
- Subject: [Bug ipa/80728] New: IPA-reference suppresses compiler memory barrier
- Auto-submitted: auto-generated
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).