Mike Vine (EMUL8R) via llvm-dev
2019-Jun-04 14:41 UTC
[llvm-dev] Is it possible to mark llvm.masked.store as volatile or to achieve similar functionality?
I'm using llvm.masked.store in our compiler. However, as this is an intrinsic function, I cannot mark it as volatile like I could with an ordinary store. I don't really care if the masked store is broken down into multiple stores or the ordering of those, I just effectively want those stores to be volatile w.r.t other volatile stores (and loads) before and after. Is there any easy way to either mark them as volatile, or add fences around the intrinsic call which force similar functionality? I was thinking of something like adding fences with syncscope of "singlethreaded" to achieve the same things as volatile but I can't work out whether that would work. Code in question which doesn't let me include a volatile parameter: bldr.CreateMaskedStore(value, addrVal, align, mask); thanks Mike Vine
Tim Northover via llvm-dev
2019-Jun-04 20:35 UTC
[llvm-dev] Is it possible to mark llvm.masked.store as volatile or to achieve similar functionality?
Hi Mike, On Tue, 4 Jun 2019 at 10:40, Mike Vine (EMUL8R) via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I was thinking of something like adding fences with syncscope of "singlethreaded" to achieve the same things as volatile but I can't work out whether that would work.Nothing will convert an access to volatile, even ignoring the properties you mention you don't care about (they're actually not even guaranteed by volatile). The implementation might still duplicate or eliminate the stores for example, which would never happen with volatile. But if you're actually trying to enforce ordering (and not with memory-mapped I/O registers on the host) then volatile is probably the wrong tool for the job anyway, and fences have a pretty good chance of being what you should be doing. But exactly what fences you need will depend on more details of your use-case. Specifically, on what other resources (CPU/GPU/...) might be able to see that the operation happened out of order. Cheers. Tim.