[cfe-dev] Does a inline assembly or a memory barrier disable optimizations in a function

Reid Kleckner rnk at google.com
Sun Aug 2 08:49:53 PDT 2015


That construct is just a memory barrier that applies to escaped objects.
Dead stores to unescaped locals for example will be removed during SSA
conversion.

Sent from phone
On Aug 1, 2015 9:29 PM, "Jeffrey Walton" <noloader at gmail.com> wrote:

> 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.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150802/98828742/attachment.html>


More information about the cfe-dev mailing list