[llvm-branch-commits] [llvm] [SPIRV][SPIRVPrepareGlobals] Map AMD's dynamic LDS 0-element globals to arrays with UINT32_MAX elements (PR #166952)

Marcos Maronas via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 7 12:04:49 PST 2025


================
@@ -43,6 +44,29 @@ bool tryExtendLLVMBitcodeMarker(GlobalVariable &Bitcode) {
   return true;
 }
 
+bool tryExtendDynamicLDSGlobal(GlobalVariable &GV) {
+  constexpr unsigned WorkgroupAS = 3;
+  const bool IsWorkgroupExternal =
+      GV.hasExternalLinkage() && GV.getAddressSpace() == WorkgroupAS;
+  if (!IsWorkgroupExternal)
+    return false;
+
+  const ArrayType *AT = dyn_cast<ArrayType>(GV.getValueType());
+  if (!AT || AT->getNumElements() != 0)
+    return false;
+
+  constexpr auto Magic = std::numeric_limits<uint32_t>::max();
----------------
maarquitos14 wrote:

```suggestion
  constexpr auto Uint32Max= std::numeric_limits<uint32_t>::max();
```

Or similar, so that it's more meaningful.

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


More information about the llvm-branch-commits mailing list