[llvm] [LangRef] asm clobber constrains: '~memory' allows reads and synchronization (PR #150191)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 13 09:33:21 PST 2025
nikic wrote:
> > I do find it somewhat confusing that we have all of ~{memory}, asm sideffect and memory(...) on the call-site. I believe from a middle-end perspective, the only thing that actually matters is memory(...).
>
> The docs for `memory(...)` does not talk about synchronization at all... does that mean a `memory(none)` may contain fences, and a `memory(read)` can do acquire reads? Is that "obvious" or should it be documented explicitly?
It's something we should document -- after we decide what the exact memory effects of synchronization are :) A good conservative assumption is that synchronization requires a readwrite effect on affected memory plus inaccessible memory. `memory(none)` excludes all forms of synchronization.
(For extra confusion, add the `nosync` attribute on top, which tries to pretend that memory and synchronization effects are orthogonal, but that does not match how LLVM actually models this at all.)
> IIUC, `~memory` _adds_ to the list of things this asm block may do, while `memory(...)` _removes_ capabilities that would otherwise be present. Is that correct?
Yes. But they are unrelated mechanisms. `memory()` will be used by the middle-end, and (I presume) `~{memory}` will be used by the back-end.
https://github.com/llvm/llvm-project/pull/150191
More information about the llvm-commits
mailing list