linux says it is a bug
Richard Biener
richard.guenther@gmail.com
Tue Mar 4 09:10:00 GMT 2014
On Tue, Mar 4, 2014 at 7:40 AM, lin zuojian <manjian2006@gmail.com> wrote:
> Hi,
> in include/linux/compiler-gcc.h :
>
> /* Optimization barrier */
> /* The "volatile" is due to gcc bugs */
> #define barrier() __asm__ __volatile__("": : :"memory")
>
> The comment of Linux says this is a gcc bug.But will any sane compiler
> disable optimization without "volatile" key word?
Depends what they call an "optimization barrier". A plain
__asm__ ("" : : : "memory") is a memory barrier. Adding volatile
to the asm makes it a barrier for every other volatile instruction,
nothing more.
The term "optimization barrier" isn't well-defined.
Richard.
More information about the Gcc
mailing list