[clang] [HLSL] Buffer handle globals should not be constants (PR #130231)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 7 13:44:29 PST 2025


================
@@ -214,12 +213,12 @@ void CGHLSLRuntime::addBuffer(const HLSLBufferDecl *BufDecl) {
   llvm::TargetExtType *TargetTy =
       cast<llvm::TargetExtType>(convertHLSLSpecificType(
           ResHandleTy, BufDecl->hasValidPackoffset() ? &Layout : nullptr));
-  llvm::GlobalVariable *BufGV =
-      new GlobalVariable(TargetTy, /*isConstant*/ true,
-                         GlobalValue::LinkageTypes::ExternalLinkage, nullptr,
-                         llvm::formatv("{0}{1}", BufDecl->getName(),
-                                       BufDecl->isCBuffer() ? ".cb" : ".tb"),
-                         GlobalValue::NotThreadLocal);
+  llvm::GlobalVariable *BufGV = new GlobalVariable(
+      TargetTy, /*isConstant*/ false,
+      GlobalValue::LinkageTypes::ExternalLinkage, PoisonValue::get(TargetTy),
----------------
hekota wrote:

Can we create these with internal linkage to match other resource classes? See https://github.com/llvm/llvm-project/pull/129100.

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


More information about the cfe-commits mailing list