[llvm-branch-commits] [clang] clang/AMDGPU: Set noalias.addrspace metadata on atomicrmw (PR #102462)

Artem Belevich via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 8 11:11:55 PDT 2024


================
@@ -550,6 +551,16 @@ AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(const LangOptions &LangOpts,
 
 void AMDGPUTargetCodeGenInfo::setTargetAtomicMetadata(
     CodeGenFunction &CGF, llvm::AtomicRMWInst &RMW) const {
+
+  if (RMW.getPointerAddressSpace() == llvm::AMDGPUAS::FLAT_ADDRESS &&
+      CGF.CGM.getLangOpts().threadPrivateMemoryAtomicsAreUndefined()) {
+    llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+    llvm::MDNode *ASRange = MDHelper.createRange(
+        llvm::APInt(32, llvm::AMDGPUAS::PRIVATE_ADDRESS),
+        llvm::APInt(32, llvm::AMDGPUAS::PRIVATE_ADDRESS + 1));
+    RMW.setMetadata(llvm::LLVMContext::MD_noalias_addrspace, ASRange);
----------------
Artem-B wrote:

What's the plan for this metadata? It does not seem to exist or be used for anything yet. 
I do not see it in https://github.com/llvm/llvm-project/blob/6b5308b7924108d63149d7c521f21c5e90da7a09/llvm/include/llvm/IR/FixedMetadataKinds.def#L21

Does this patch miss some changes or depends on other patches?

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


More information about the llvm-branch-commits mailing list