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

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 7 11:01:23 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()) &&
----------------
yxsamliu wrote:

I will remove the use of CGF.getTarget().allowAMDGPUUnsafeFPAtomics() here since it should override the default value for IgnoreDenormalMode attribute, which I have done in Basic/Targets/AMDGPU.cpp.

amdgpu.no.fine.grained.memory is on by default, therefore does not need to be implied by allowAMDGPUUnsafeFPAtomics

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


More information about the cfe-commits mailing list