[clang] [HLSL] Buffer handle globals should not be constants (PR #130231)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 13 09:59:00 PDT 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:
The global BufGV will be initialized with a resource handle based on resource bindings at the start of the entry function (or in module init function). A resource class with uninitialized handle is an error state, so poison is the right choice here.
https://github.com/llvm/llvm-project/pull/130231
More information about the cfe-commits
mailing list