This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/80728] 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: Mon, 15 May 2017 09:15:39 +0000
- Subject: [Bug ipa/80728] IPA-reference suppresses compiler memory barrier
- Auto-submitted: auto-generated
- References: <bug-80728-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80728
--- Comment #2 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Nowadays C has atomics and fences in the language standard, so it doesn't
matter if x() had
asm volatile("":::"memory");
or
__atomic_{signal,thread}_fence(__ATOMIC_ACQ_REL);
or
return __atomic_load_n(&b, __ATOMIC_SEQ_CST);
In all three cases the compiler needs to place a memory barrier internally, and
in the latter two it's impossible to argue that the source code is missing a
clobber.
I think it's correct that "memory" clobber cannot touch non-addressable auto
vars, but extending that to static variables seems wrong. I'm not aware of any
instance (apart from this bug) where gcc does that.