Stream: wasm

Topic: volatile


view this post on Zulip Scott Waye (Nov 23 2024 at 13:51):

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 ?

Threads and Atomics in WebAssembly. Contribute to WebAssembly/threads development by creating an account on GitHub.

view this post on Zulip Dan Gohman (Nov 23 2024 at 14:51):

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.

view this post on Zulip Scott Waye (Nov 23 2024 at 14:57):

Thanks, so clang would never lift (fi that's the right verb)i32.atomic.load8_ufor example ?

view this post on Zulip Scott Waye (Nov 23 2024 at 15:14):

sorry, I got that wrong

view this post on Zulip Scott Waye (Nov 23 2024 at 15:19):

What I think I want to ask is that an LLVM IR load atomic require is what should be used in the scenario?

view this post on Zulip Dan Gohman (Nov 23 2024 at 15:26):

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).

view this post on Zulip Dan Gohman (Nov 23 2024 at 15:32):

LLVM's documentation for memory ordering is here.


Last updated: Dec 23 2024 at 12:05 UTC