(original) (raw)

On Mon, Nov 20, 2017 at 1:22 PM, Paweł Batko <pawel.batko@gmail.com> wrote:
Hi Reid,

On 20 November 2017 at 21:44, Reid Kleckner <rnk@google.com> wrote:
\> For example, llvm should be able to mem2reg
\> unescaped atomics because it knows they cannot be modified by other threads,

Could you point to some resources that explain what an unescaped atomic is?

I mean a local variable that is \_Atomic qualified whose address does not escape the function that allocates it. An unused \_Atomic int, for example, can be removed. If it were volatile, the storage and any loads and stores would have to be preserved.

In other words, atomics come with a threading model, semantics, and rules that permit certain transformations. Volatile still acts as an escape hatch to throw that out the window.