[clang] [llvm] [SPIRV][RFC] Rework / extend support for memory scopes (PR #106429)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 11 04:02:15 PDT 2024


================
@@ -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(),
+                                                   SyncScope::OpenCLDevice,
+                                                   Order, CGF.getLLVMContext());
+    else
+      SS = CGF.getLLVMContext().getOrInsertSyncScopeID("");
----------------
arsenm wrote:

Don't need to query this, this can just be llvm::SyncScope::System

https://github.com/llvm/llvm-project/pull/106429


More information about the cfe-commits mailing list