[llvm] [SPIRV] Preserve AMDGPU metadata through NonSemantic.AuxData (PR #215510)

Marcos Maronas via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 03:24:34 PDT 2026


================
@@ -181,6 +193,22 @@ void SPIRVAuxDataHandler::emitAuxDataStrings(SPIRV::ModuleAnalysisInfo &MAI) {
     collectAttributesFor(&GO, MAI);
     collectMetadataFor(&GO, MDNames, MAI);
   }
+  // Only a handful of distinct metadata names exist, one per AMDGPUAtomicMDKind
+  // enumerator. Track which we've seen so we can stop once every name has been
+  // emitted, instead of scanning potentially thousands of records with
+  // redundant hash lookups.
+  constexpr unsigned AllMDKindsSeen =
+      (1u << (static_cast<unsigned>(
+                  SPIRV::ModuleAnalysisInfo::AMDGPUAtomicMDKind::Last) +
+              1)) -
+      1;
+  unsigned SeenMask = 0;
+  for (const auto &Rec : MAI.InstrAuxDataRecords) {
+    SeenMask |= 1u << static_cast<unsigned>(Rec.Kind);
+    getOrEmitString(MAI.getAMDGPUAtomicMDName(Rec.Kind), MAI);
----------------
maarquitos14 wrote:

That is a good point. The operation should be relatively cheap, because it will normally fail a `try_emplace` on a `DenseMap` and return early, but still cheaper if we don't even do it. Thanks! 

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


More information about the llvm-commits mailing list