[clang] [llvm] [SPIR-V] Encode Atomic metadata as UserSemantic string decoration (PR #193019)

Dmitry Sidorov via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 04:11:36 PDT 2026


================
@@ -2539,6 +2539,28 @@ void SPIRVEmitIntrinsics::insertSpirvDecorations(Instruction *I,
                       {I->getType()},
                       {I, MetadataAsValue::get(I->getContext(), MD)});
   }
+  if (I->getModule()->getTargetTriple().getVendor() == Triple::AMD &&
+      isa<AtomicRMWInst>(I)) {
+    // If present, we encode AMDGPU atomic metadata as UserSemantic string
+    // decorations, which will be parsed during reverse translation.
+    auto &Ctx = B.getContext();
+    auto *US = ConstantAsMetadata::get(
----------------
MrSidims wrote:

Strictly speaking it's invalid to decorate an instruction with UserSemantic decoration unless it's "a variable or a member of a structure type".

I do remember that @sarnex once promised to draft and publish a spec (or better, "a drawing of a spec") for auxiliary data :) and may be it can be reused for such annotations. 

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


More information about the cfe-commits mailing list