[llvm-dev] Meaning of loads/stores marked both atomic and volatile
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Tue Nov 21 03:18:30 PST 2017
On 21 November 2017 at 10:27, Paweł Batko <pawel.batko at gmail.com> wrote:
> Ok, let's say in Example 1. monotonic atomic prevents loop
> optimization because compiler assumes existence of other threads.
> (Compiler (effectively) assumes existence of other threads the moment
> one starts using at least monotonic atomic load/stores?)
I think that's pretty accurate, though the assumptions are of course
limited to those monotonic (or stronger) stores.
> In Example. 2 let's consider signal handler in a single thread situation.
> If monotonic atomic prevents loop optimization as in Example 1., then
> I say it does the same Example 2.
I agree, but in certain theoretical situations a general monotonic
operation might be stronger than what's actually needed there. You
could imagine a GPU or something needing a real barrier instruction to
guarantee even a monotonic store becomes visible to other cores, but
not necessarily for one in synchscope("singlethread").
More information about the llvm-dev