[clang] [llvm] [DirectX] Add resource name argument to llvm.dx.handlefrom[implicit]binding intrinsics (PR #139991)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Tue May 27 11:40:06 PDT 2025


================
@@ -557,29 +553,47 @@ static void initializeBuffer(CodeGenModule &CGM, llvm::GlobalVariable *GV,
   CGM.AddCXXGlobalInit(InitResFunc);
 }
 
-static void initializeBufferFromBinding(CodeGenModule &CGM,
-                                        llvm::GlobalVariable *GV,
-                                        HLSLResourceBindingAttr *RBA) {
+void CGHLSLRuntime::initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
+                                                llvm::GlobalVariable *GV,
+                                                HLSLResourceBindingAttr *RBA) {
   llvm::Type *Int1Ty = llvm::Type::getInt1Ty(CGM.getLLVMContext());
   auto *NonUniform = llvm::ConstantInt::get(Int1Ty, false);
   auto *Index = llvm::ConstantInt::get(CGM.IntTy, 0);
   auto *RangeSize = llvm::ConstantInt::get(CGM.IntTy, 1);
   auto *Space =
       llvm::ConstantInt::get(CGM.IntTy, RBA ? RBA->getSpaceNumber() : 0);
+  Value *Name = nullptr;
+
+  // DXIL intrinsic includes resource name
+  if (getArch() == Triple::dxil) {
+    std::string Str = std::string(BufDecl->getName());
+    std::string GlobalName = Str + ".str";
----------------
bogner wrote:

Nit: I think constructor syntax is more readable here.
```suggestion
    std::string Str(BufDecl->getName());
    std::string GlobalName(Str + ".str");
```

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


More information about the cfe-commits mailing list