clspv should use LLVM atomic instructions
clspv currently replaces OpenCL atomic builtins with SPIR-V builtins. Instead we should use llvm atomic instructions throughout the flow and translate them in SPIRVProducerPass. Currently some of the builtins are handled this way. Increment, decrement and compare exchange need updated.
Other issues with atomics in clspv: 1.2 opencl atomics should be relaxed and map to Monotonic ordering in LLVM.
All OpenCL atomic builtins claim the pointer is volatile. So at least through the clspv flow atomic instructions should get marked as volatile.
Hi, I am trying to add OpLine information also for atomic instructions in OpenCL, since LLVM atomic ones are not used. Could you please give me some hints for it?
Take a look at lib/ReplaceOpenCLBuiltins.cpp. That pass replaces the OpenCL atomic functions with the spirv.op calls (e.g. replaceAtomics). For debugging, probably what needs to change is for InsertSPIRVOp to copy debug metadata from the original call to the replacement.
Hey, thanks for replying. Already fixed it and created a PR:-)