[cfe-dev] Does a inline assembly or a memory barrier disable optimizations in a function
Jeffrey Walton
noloader at gmail.com
Sat Aug 1 21:22:59 PDT 2015
GCC disables optimizations in a function if it encounters inline
assembly. That means we can use a memory barrier to ensure dead stores
are not optimized out:
delete m_ptr;
m_ptr = NULL:
__asm__ __volatile__ ("" ::: "memory");
Clang defines __GNUC__, but its not clear to me if the same behavior
is present. Looking at Language Compatibility at
http://clang.llvm.org/compatibility.html, there is no discussion of
the behavior.
Does inline assembly or a memory barrier tame the optimizer in a
function so that dead stores are not removed?
Thanks in advance.
More information about the cfe-dev
mailing list