This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/45235] const volatile read moved out of order
- From: "bigotp at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Aug 2010 22:54:55 -0000
- Subject: [Bug rtl-optimization/45235] const volatile read moved out of order
- References: <bug-45235-6848@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from bigotp at acm dot org 2010-08-11 22:54 -------
I don't see that the const qualifier should be relevant: doesn't it simply
indicate that the code is not permitted to write through that lvalue? (FWIW,
the real code uses a memory mapped address and the const qualifier was placed
on the address declaration by the chip manufacturer. I assume that a write to
the location may be interpreted as a command to the hardware to self-destruct.)
Given that, the existing behavior appears to be a clear violation of the
requirement that volatile accesses not be re-ordered across sequence points.
In concept, I like rguenth's solution (which I haven't tested), as it fits with
the documented semantics of MEM_READONLY_P indicating "not modified during the
lifetime of the program", something that certainly can't be said of any
readable volatile object. That the RTL flag is stored in a field named
"unchanging" is a lot more clear than "READONLY". I think that approach
eliminates the need to muck with any of those other places where the same
problem might be occurring.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45235