================
@@ -766,8 +766,19 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr 
*Expr, Address Dest,
   // LLVM atomic instructions always have synch scope. If clang atomic
   // expression has no scope operand, use default LLVM synch scope.
   if (!ScopeModel) {
+    llvm::SyncScope::ID SS;
+    if (CGF.getLangOpts().OpenCL)
+      // OpenCL approach is: "The functions that do not have memory_scope
+      // argument have the same semantics as the corresponding functions with
+      // the memory_scope argument set to memory_scope_device." See ref.:
+      // 
https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#atomic-functions
+      SS = CGF.getTargetHooks().getLLVMSyncScopeID(CGF.getLangOpts(),
----------------
VyacheslavLevytskyy wrote:

May I ask you to add a test case to check specifically this line? That is to 
check that coming from clang/OpenCL we get the `Device` memory scope when there 
is no `synscope(...)`. We have llvm/test/CodeGen/SPIRV/atomicrmw.ll to check 
SPIRV Backend default for no `syncscope`, but there is no test to cover the 
OpenCL-specific default.

https://github.com/llvm/llvm-project/pull/106429
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to