Why is there no mention of volatile, specifically for loads in https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md ? How does shared memory loads avoid a loop check load being lifted out of the loop without the idea of volatile
?
The short answer is, volatile is for talking to memory mapped I/O, while atomic is the thing to use for talking to other threads. If a loop check is a load of memory that will be stored to from another thread, it should be atomic, not volatile.
Thanks, so clang would never lift (fi that's the right verb)i32.atomic.load8_u
for example ?
sorry, I got that wrong
What I think I want to ask is that an LLVM IR load atomic require
is what should be used in the scenario?
Clang will typically not hoist atomic loads from loops (though it can do so if it believes eg. that it would be UB to store to the memory location from another thread).
LLVM's documentation for memory ordering is here.
Last updated: Dec 23 2024 at 12:05 UTC