[llvm] [NFC][DirectX] Rename ResourceInfo::RecordID to BindingID (PR #216376)

Helena Kotas via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 15:00:58 PDT 2026


https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/216376

>From 96b765f26eaca97133d64b19f80d2fd6d5c8cb92 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 14 Aug 2026 11:31:32 -0700
Subject: [PATCH 1/2] [NFC][DirectX] Rename ResourceInfo::RecordID to BindingID

Rename ResourceInfo::RecordID to BindingID to better reflect its purpose.
This field is set only for resources with an associated binding.

This also clarifies the distinction from the upcoming HeapResourceID member,
which will identify resources originating from a heap. The existing RecordID
name could be ambiguous once both identifiers are present.
---
 llvm/include/llvm/Analysis/DXILResource.h     | 20 +++++++++----------
 llvm/lib/Analysis/DXILResource.cpp            |  9 ++++-----
 llvm/lib/Target/DirectX/DXILOpLowering.cpp    |  2 +-
 llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp |  2 +-
 4 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index 1473a0f7d56c0..f2ff027df9ec3 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -371,14 +371,14 @@ enum class ResourceCounterDirection {
 class ResourceInfo {
 public:
   struct ResourceBinding {
-    uint32_t RecordID;
+    uint32_t BindingID;
     uint32_t Space;
     uint32_t LowerBound;
     uint32_t Size;
 
     bool operator==(const ResourceBinding &RHS) const {
-      return std::tie(RecordID, Space, LowerBound, Size) ==
-             std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
+      return std::tie(BindingID, Space, LowerBound, Size) ==
+             std::tie(RHS.BindingID, RHS.Space, RHS.LowerBound, RHS.Size);
     }
     bool operator!=(const ResourceBinding &RHS) const {
       return !(*this == RHS);
@@ -388,8 +388,8 @@ class ResourceInfo {
       // guarantees a well ordered results.
       const bool LHSIsUnbounded = Size == 0;
       const bool RHSIsUnbounded = RHS.Size == 0;
-      return std::tie(RecordID, Space, LowerBound, LHSIsUnbounded, Size) <
-             std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHSIsUnbounded,
+      return std::tie(BindingID, Space, LowerBound, LHSIsUnbounded, Size) <
+             std::tie(RHS.BindingID, RHS.Space, RHS.LowerBound, RHSIsUnbounded,
                       RHS.Size);
     }
     bool overlapsWith(const ResourceBinding &RHS) const {
@@ -412,13 +412,13 @@ class ResourceInfo {
   ResourceCounterDirection CounterDirection = ResourceCounterDirection::Unknown;
   bool HasAtomic64Use = false;
 
-  ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
-               uint32_t Size, TargetExtType *HandleTy, StringRef Name = "",
+  ResourceInfo(uint32_t Space, uint32_t LowerBound, uint32_t Size,
+               TargetExtType *HandleTy, StringRef Name = "",
                GlobalVariable *Symbol = nullptr)
-      : Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy),
-        Name(Name), Symbol(Symbol) {}
+      : Binding{ResourceBinding{0, Space, LowerBound, Size}},
+        HandleTy(HandleTy), Name(Name), Symbol(Symbol) {}
 
-  void setBindingID(unsigned ID) { Binding.RecordID = ID; }
+  void setBindingID(unsigned ID) { Binding.BindingID = ID; }
 
   bool hasCounter() const {
     return CounterDirection != ResourceCounterDirection::Unknown;
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index 767c33684da60..c7c408b6b57f4 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -688,7 +688,7 @@ MDTuple *ResourceInfo::getAsMetadata(Module &M,
         Constant::getIntegerValue(I1Ty, APInt(1, V)));
   };
 
-  MDVals.push_back(getIntMD(Binding.RecordID));
+  MDVals.push_back(getIntMD(Binding.BindingID));
   assert(Symbol && "Cannot yet create useful resource metadata without symbol");
   MDVals.push_back(ValueAsMetadata::get(Symbol));
   MDVals.push_back(MDString::get(Ctx, Name));
@@ -800,7 +800,7 @@ void ResourceInfo::print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI,
   }
 
   OS << "  Binding:\n"
-     << "    Record ID: " << Binding.RecordID << "\n"
+     << "    Record ID: " << Binding.BindingID << "\n"
      << "    Space: " << Binding.Space << "\n"
      << "    Lower Bound: " << Binding.LowerBound << "\n"
      << "    Size: " << Binding.Size << "\n";
@@ -889,8 +889,7 @@ void DXILResourceMap::populateResourceInfos(Module &M,
           StringRef Name = getResourceNameFromBindingCall(CI);
 
           ResourceInfo RI =
-              ResourceInfo{/*RecordID=*/0, Space,    LowerBound,
-                           Size,           HandleTy, Name};
+              ResourceInfo{Space, LowerBound, Size, HandleTy, Name};
 
           CIToInfos.emplace_back(CI, RI, RTI);
         }
@@ -917,7 +916,7 @@ void DXILResourceMap::populateResourceInfos(Module &M,
   }
 
   unsigned Size = Infos.size();
-  // In DXC, Record ID is unique per resource type. Match that.
+  // In DXC, Binding ID is unique per resource type. Match that.
   FirstUAV = FirstCBuffer = FirstSampler = Size;
   uint32_t NextID = 0;
   for (unsigned I = 0, E = Size; I != E; ++I) {
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
index 61dc9e533ba0f..dc15c02481468 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
@@ -357,7 +357,7 @@ class OpLowerer {
           (Binding.Size == 1) ? false : hasNonUniformIndex(IndexOp);
       std::array<Value *, 4> Args{
           ConstantInt::get(Int8Ty, llvm::to_underlying(RC)),
-          ConstantInt::get(Int32Ty, Binding.RecordID), IndexOp,
+          ConstantInt::get(Int32Ty, Binding.BindingID), IndexOp,
           ConstantInt::get(Int1Ty, HasNonUniformIndex)};
       Expected<CallInst *> OpCall =
           OpBuilder.tryCreateOp(OpCode::CreateHandle, Args, CI->getName());
diff --git a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
index cc092819913a8..272e2db675431 100644
--- a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
@@ -194,7 +194,7 @@ struct FormatBindingID
         RC(RTI.getResourceClass()) {}
 
   void format(llvm::raw_ostream &OS, StringRef Style) {
-    OS << getRCPrefix(RC).upper() << Item.getBinding().RecordID;
+    OS << getRCPrefix(RC).upper() << Item.getBinding().BindingID;
   }
 };
 

>From 8e9f79eda5060c9ceb612a83c8da81244671b184 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 14 Aug 2026 15:00:38 -0700
Subject: [PATCH 2/2] code review feedback & update tests!

---
 llvm/include/llvm/Analysis/DXILResource.h     |  4 ++--
 llvm/lib/Analysis/DXILResource.cpp            |  2 +-
 .../buffer-frombinding-unbounded.ll           |  4 ++--
 .../DXILResource/buffer-frombinding.ll        | 20 +++++++++----------
 .../Analysis/DXILResource/has-atomic64-use.ll |  6 +++---
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index f2ff027df9ec3..413bf1a83eec5 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -371,7 +371,7 @@ enum class ResourceCounterDirection {
 class ResourceInfo {
 public:
   struct ResourceBinding {
-    uint32_t BindingID;
+    uint32_t BindingID = 0;
     uint32_t Space;
     uint32_t LowerBound;
     uint32_t Size;
@@ -415,7 +415,7 @@ class ResourceInfo {
   ResourceInfo(uint32_t Space, uint32_t LowerBound, uint32_t Size,
                TargetExtType *HandleTy, StringRef Name = "",
                GlobalVariable *Symbol = nullptr)
-      : Binding{ResourceBinding{0, Space, LowerBound, Size}},
+      : Binding{0, Space, LowerBound, Size},
         HandleTy(HandleTy), Name(Name), Symbol(Symbol) {}
 
   void setBindingID(unsigned ID) { Binding.BindingID = ID; }
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index c7c408b6b57f4..413521ac64d61 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -800,7 +800,7 @@ void ResourceInfo::print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI,
   }
 
   OS << "  Binding:\n"
-     << "    Record ID: " << Binding.BindingID << "\n"
+     << "    Binding ID: " << Binding.BindingID << "\n"
      << "    Space: " << Binding.Space << "\n"
      << "    Lower Bound: " << Binding.LowerBound << "\n"
      << "    Size: " << Binding.Size << "\n";
diff --git a/llvm/test/Analysis/DXILResource/buffer-frombinding-unbounded.ll b/llvm/test/Analysis/DXILResource/buffer-frombinding-unbounded.ll
index ee47bd4bb1bd5..5fb768c2bc6a2 100644
--- a/llvm/test/Analysis/DXILResource/buffer-frombinding-unbounded.ll
+++ b/llvm/test/Analysis/DXILResource/buffer-frombinding-unbounded.ll
@@ -10,7 +10,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[#SRV:]]:
   ; CHECK:   Name: One
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 0
+  ; CHECK:     Binding ID: 0
   ; CHECK:     Space: 0
   ; CHECK:     Lower Bound: 0
   ; CHECK:     Size: 4294967295
@@ -27,7 +27,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[#UAV:]]:
   ; CHECK:   Name: Two
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 0
+  ; CHECK:     Binding ID: 0
   ; CHECK:     Space: 0
   ; CHECK:     Lower Bound: 0
   ; CHECK:     Size: 4294967262
diff --git a/llvm/test/Analysis/DXILResource/buffer-frombinding.ll b/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
index d92010ed41d4c..52c5206aa70ed 100644
--- a/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
+++ b/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
@@ -20,7 +20,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[SRV0:[0-9]+]]:
   ; CHECK:   Name: Zero
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 0
+  ; CHECK:     Binding ID: 0
   ; CHECK:     Space: 1
   ; CHECK:     Lower Bound: 8
   ; CHECK:     Size: 1
@@ -34,7 +34,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[SRV1:[0-9]+]]:
   ; CHECK:   Name: One
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 1
+  ; CHECK:     Binding ID: 1
   ; CHECK:     Space: 4
   ; CHECK:     Lower Bound: 2
   ; CHECK:     Size: 1
@@ -49,7 +49,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[SRV2:[0-9]+]]:
   ; CHECK:   Name: Two
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 2
+  ; CHECK:     Binding ID: 2
   ; CHECK:     Space: 5
   ; CHECK:     Lower Bound: 3
   ; CHECK:     Size: 24
@@ -64,7 +64,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[UAV0:[0-9]+]]:
   ; CHECK:   Name: Three
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 0
+  ; CHECK:     Binding ID: 0
   ; CHECK:     Space: 2
   ; CHECK:     Lower Bound: 7
   ; CHECK:     Size: 1
@@ -83,7 +83,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[UAV1:[0-9]+]]:
   ; CHECK:   Name: Four
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 1
+  ; CHECK:     Binding ID: 1
   ; CHECK:     Space: 3
   ; CHECK:     Lower Bound: 5
   ; CHECK:     Size: 1
@@ -106,7 +106,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[UAV2:[0-9]+]]:
   ; CHECK:   Name: Array
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 2
+  ; CHECK:     Binding ID: 2
   ; CHECK:     Space: 4
   ; CHECK:     Lower Bound: 0
   ; CHECK:     Size: 10
@@ -126,7 +126,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[UAV3:[0-9]+]]:
   ; CHECK:   Name: Five
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 3
+  ; CHECK:     Binding ID: 3
   ; CHECK:     Space: 5
   ; CHECK:     Lower Bound: 0
   ; CHECK:     Size: 1
@@ -143,7 +143,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[UAV4:[0-9]+]]:
   ; CHECK:   Name: Six
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 4
+  ; CHECK:     Binding ID: 4
   ; CHECK:     Space: 5
   ; CHECK:     Lower Bound: 0
   ; CHECK:     Size: 1
@@ -160,7 +160,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[CB0:[0-9]+]]:
   ; CHECK:   Name: CB
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 0
+  ; CHECK:     Binding ID: 0
   ; CHECK:     Space: 1
   ; CHECK:     Lower Bound: 0
   ; CHECK:     Size: 1
@@ -173,7 +173,7 @@ define void @test_typedbuffer() {
   ; CHECK: Resource [[CB1:[0-9]+]]:
   ; CHECK:   Name: Constants
   ; CHECK:   Binding:
-  ; CHECK:     Record ID: 1
+  ; CHECK:     Binding ID: 1
   ; CHECK:     Space: 1
   ; CHECK:     Lower Bound: 8
   ; CHECK:     Size: 1
diff --git a/llvm/test/Analysis/DXILResource/has-atomic64-use.ll b/llvm/test/Analysis/DXILResource/has-atomic64-use.ll
index 1d32da7fb8d57..0bedebe59c539 100644
--- a/llvm/test/Analysis/DXILResource/has-atomic64-use.ll
+++ b/llvm/test/Analysis/DXILResource/has-atomic64-use.ll
@@ -15,7 +15,7 @@ define void @main() {
       @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_1_0t(
           i32 0, i32 0, i32 1, i32 0, ptr null)
   ; CHECK:      Binding:
-  ; CHECK:        Record ID: 0
+  ; CHECK:        Binding ID: 0
   ; CHECK:        Space: 0
   ; CHECK:        Lower Bound: 0
   ; CHECK:        Size: 1
@@ -29,7 +29,7 @@ define void @main() {
       @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_1_0t(
           i32 0, i32 1, i32 1, i32 0, ptr null)
   ; CHECK:      Binding:
-  ; CHECK:        Record ID: 1
+  ; CHECK:        Binding ID: 1
   ; CHECK:        Space: 0
   ; CHECK:        Lower Bound: 1
   ; CHECK:        Size: 1
@@ -43,7 +43,7 @@ define void @main() {
       @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_1_0_1t(
           i32 0, i32 2, i32 1, i32 0, ptr null)
   ; CHECK:      Binding:
-  ; CHECK:        Record ID: 2
+  ; CHECK:        Binding ID: 2
   ; CHECK:        Space: 0
   ; CHECK:        Lower Bound: 2
   ; CHECK:        Size: 1



More information about the llvm-commits mailing list