[clang] Add clang atomic control options and attribute (PR #114841)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 10:06:54 PST 2024


================
@@ -569,19 +569,21 @@ void AMDGPUTargetCodeGenInfo::setTargetAtomicMetadata(
     AtomicInst.setMetadata(llvm::LLVMContext::MD_noalias_addrspace, ASRange);
   }
 
-  if (!RMW || !CGF.getTarget().allowAMDGPUUnsafeFPAtomics())
+  if (!RMW)
     return;
 
-  // TODO: Introduce new, more controlled options that also work for integers,
-  // and deprecate allowAMDGPUUnsafeFPAtomics.
-  llvm::AtomicRMWInst::BinOp RMWOp = RMW->getOperation();
-  if (llvm::AtomicRMWInst::isFPOperation(RMWOp)) {
-    llvm::MDNode *Empty = llvm::MDNode::get(CGF.getLLVMContext(), {});
+  AtomicOptions AO = CGF.CGM.getAtomicOpts();
+  llvm::MDNode *Empty = llvm::MDNode::get(CGF.getLLVMContext(), {});
+  if (AO.getNoFineGrainedMemory())
     RMW->setMetadata("amdgpu.no.fine.grained.memory", Empty);
-
-    if (RMWOp == llvm::AtomicRMWInst::FAdd && RMW->getType()->isFloatTy())
-      RMW->setMetadata("amdgpu.ignore.denormal.mode", Empty);
-  }
+  if (AO.getNoRemoteMemory())
+    RMW->setMetadata("amdgpu.no.remote.memory", Empty);
+
+  if ((AO.getIgnoreDenormalMode() ||
+       CGF.getTarget().allowAMDGPUUnsafeFPAtomics()) &&
----------------
arsenm wrote:

allowAMDGPUUnsafeFPAtomics() is no longer implying amdgpu.no.fine.grained.memory?

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


More information about the cfe-commits mailing list