[llvm-branch-commits] [llvm] [DirectX] Gather resource names in DXIL resource analysis (PR #140633)

Helena Kotas via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 19 15:11:28 PDT 2025


https://github.com/hekota created https://github.com/llvm/llvm-project/pull/140633

Gather resource names from `llvm.dx.resource.handlefrombinding` calls during DXIL resource analysis and add them to ResourceMap.

Part 3/4 of llvm/llvm-project#105059

>From a73cdb9288a0f325d4c03a58daf6803e8d8d2ddf Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Mon, 19 May 2025 14:55:18 -0700
Subject: [PATCH] [DirectX] Gather resource names in resource analysis

---
 llvm/include/llvm/Analysis/DXILResource.h     | 17 +++--
 llvm/lib/Analysis/DXILResource.cpp            | 35 ++++++++-
 .../DXILResource/buffer-frombinding.ll        | 39 +++++++---
 llvm/unittests/Analysis/DXILResourceTest.cpp  | 73 ++++++++-----------
 4 files changed, 101 insertions(+), 63 deletions(-)

diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index b6efd82bb308e..a274e2294561e 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -16,9 +16,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
-#include "llvm/Support/Alignment.h"
 #include "llvm/Support/DXILABI.h"
-#include <climits>
 #include <cstdint>
 
 namespace llvm {
@@ -32,6 +30,10 @@ class DXILResourceTypeMap;
 
 namespace dxil {
 
+// Returns the resource name from dx_resource_handlefrombinding or
+// dx_resource_handlefromimplicitbinding call
+StringRef getResourceNameFromBindingCall(CallInst *CI);
+
 /// The dx.RawBuffer target extension type
 ///
 /// `target("dx.RawBuffer", Type, IsWriteable, IsROV)`
@@ -358,6 +360,7 @@ class ResourceInfo {
 private:
   ResourceBinding Binding;
   TargetExtType *HandleTy;
+  StringRef Name;
   GlobalVariable *Symbol = nullptr;
 
 public:
@@ -365,10 +368,10 @@ class ResourceInfo {
   ResourceCounterDirection CounterDirection = ResourceCounterDirection::Unknown;
 
   ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
-               uint32_t Size, TargetExtType *HandleTy,
+               uint32_t Size, TargetExtType *HandleTy, StringRef Name = "",
                GlobalVariable *Symbol = nullptr)
       : Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy),
-        Symbol(Symbol) {}
+        Name(Name), Symbol(Symbol) {}
 
   void setBindingID(unsigned ID) { Binding.RecordID = ID; }
 
@@ -378,10 +381,12 @@ class ResourceInfo {
 
   const ResourceBinding &getBinding() const { return Binding; }
   TargetExtType *getHandleTy() const { return HandleTy; }
-  StringRef getName() const { return Symbol ? Symbol->getName() : ""; }
+  const StringRef getName() const {
+    return Name.empty() ? (Symbol ? Symbol->getName() : "") : Name;
+  }
 
   bool hasSymbol() const { return Symbol; }
-  GlobalVariable *createSymbol(Module &M, StructType *Ty, StringRef Name = "");
+  GlobalVariable *createSymbol(Module &M, StructType *Ty);
   MDTuple *getAsMetadata(Module &M, dxil::ResourceTypeInfo &RTI) const;
 
   std::pair<uint32_t, uint32_t>
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index 36b3901246285..8cc9316dfb667 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -21,7 +21,6 @@
 #include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/FormatVariadic.h"
-#include <climits>
 #include <cstdint>
 #include <optional>
 
@@ -531,8 +530,7 @@ void ResourceTypeInfo::print(raw_ostream &OS, const DataLayout &DL) const {
   }
 }
 
-GlobalVariable *ResourceInfo::createSymbol(Module &M, StructType *Ty,
-                                           StringRef Name) {
+GlobalVariable *ResourceInfo::createSymbol(Module &M, StructType *Ty) {
   assert(!Symbol && "Symbol has already been created");
   Symbol = new GlobalVariable(M, Ty, /*isConstant=*/true,
                               GlobalValue::ExternalLinkage,
@@ -659,6 +657,9 @@ ResourceInfo::getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const {
 
 void ResourceInfo::print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI,
                          const DataLayout &DL) const {
+  if (!Name.empty())
+    OS << "  Name: " << Name << "\n";
+
   if (Symbol) {
     OS << "  Symbol: ";
     Symbol->printAsOperand(OS);
@@ -706,6 +707,29 @@ static bool isUpdateCounterIntrinsic(Function &F) {
   return F.getIntrinsicID() == Intrinsic::dx_resource_updatecounter;
 }
 
+StringRef dxil::getResourceNameFromBindingCall(CallInst *CI) {
+  Value *Op = nullptr;
+  switch (CI->getCalledFunction()->getIntrinsicID()) {
+  default:
+    return "";
+  case Intrinsic::dx_resource_handlefrombinding:
+  case Intrinsic::dx_resource_handlefromimplicitbinding:
+    Op = CI->getArgOperand(5);
+    break;
+  }
+  StringRef Name;
+  if (auto *GV = dyn_cast<llvm::GlobalVariable>(Op)) {
+    auto *CA = dyn_cast<ConstantDataArray>(GV->getInitializer());
+    if (CA && CA->isString()) {
+      Name = CA->getAsString();
+      // strip trailing 0
+      if (Name.ends_with('\0'))
+        Name = Name.drop_back(1);
+    }
+  }
+  return Name;
+}
+
 void DXILResourceMap::populateResourceInfos(Module &M,
                                             DXILResourceTypeMap &DRTM) {
   SmallVector<std::tuple<CallInst *, ResourceInfo, ResourceTypeInfo>> CIToInfos;
@@ -731,8 +755,11 @@ void DXILResourceMap::populateResourceInfos(Module &M,
               cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
           uint32_t Size =
               cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
+          StringRef Name = getResourceNameFromBindingCall(CI);
+
           ResourceInfo RI =
-              ResourceInfo{/*RecordID=*/0, Space, LowerBound, Size, HandleTy};
+              ResourceInfo{/*RecordID=*/0, Space,    LowerBound,
+                           Size,           HandleTy, Name};
 
           CIToInfos.emplace_back(CI, RI, RTI);
         }
diff --git a/llvm/test/Analysis/DXILResource/buffer-frombinding.ll b/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
index efacff71ee127..6c8476617e693 100644
--- a/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
+++ b/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
@@ -2,11 +2,22 @@
 
 @G = external constant <4 x float>, align 4
 
+ at Zero.str = private unnamed_addr constant [5 x i8] c"Zero\00", align 1
+ at One.str = private unnamed_addr constant [4 x i8] c"One\00", align 1
+ at Two.str = private unnamed_addr constant [4 x i8] c"Two\00", align 1
+ at Three.str = private unnamed_addr constant [6 x i8] c"Three\00", align 1
+ at Four.str = private unnamed_addr constant [5 x i8] c"Four\00", align 1
+ at Array.str = private unnamed_addr constant [6 x i8] c"Array\00", align 1
+ at Five.str = private unnamed_addr constant [5 x i8] c"Five\00", align 1
+ at CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1
+ at Constants.str = private unnamed_addr constant [10 x i8] c"Constants\00", align 1
+
 define void @test_typedbuffer() {
   ; ByteAddressBuffer Buf : register(t8, space1)
   %srv0 = call target("dx.RawBuffer", void, 0, 0)
-      @llvm.dx.resource.handlefrombinding(i32 1, i32 8, i32 1, i32 0, i1 false, ptr null)
+      @llvm.dx.resource.handlefrombinding(i32 1, i32 8, i32 1, i32 0, i1 false, ptr @Zero.str)
   ; CHECK: Resource [[SRV0:[0-9]+]]:
+  ; CHECK:   Name: Zero
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 0
   ; CHECK:     Space: 1
@@ -18,8 +29,9 @@ define void @test_typedbuffer() {
   ; struct S { float4 a; uint4 b; };
   ; StructuredBuffer<S> Buf : register(t2, space4)
   %srv1 = call target("dx.RawBuffer", {<4 x float>, <4 x i32>}, 0, 0)
-      @llvm.dx.resource.handlefrombinding(i32 4, i32 2, i32 1, i32 0, i1 false, ptr null)
+      @llvm.dx.resource.handlefrombinding(i32 4, i32 2, i32 1, i32 0, i1 false, ptr @One.str)
   ; CHECK: Resource [[SRV1:[0-9]+]]:
+  ; CHECK:   Name: One
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 1
   ; CHECK:     Space: 4
@@ -32,8 +44,9 @@ define void @test_typedbuffer() {
 
   ; Buffer<uint4> Buf[24] : register(t3, space5)
   %srv2 = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 0)
-      @llvm.dx.resource.handlefrombinding(i32 5, i32 3, i32 24, i32 0, i1 false, ptr null)
+      @llvm.dx.resource.handlefrombinding(i32 5, i32 3, i32 24, i32 0, i1 false, ptr @Two.str)
   ; CHECK: Resource [[SRV2:[0-9]+]]:
+  ; CHECK:   Name: Two
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 2
   ; CHECK:     Space: 5
@@ -46,8 +59,9 @@ define void @test_typedbuffer() {
 
   ; RWBuffer<int> Buf : register(u7, space2)
   %uav0 = call target("dx.TypedBuffer", i32, 1, 0, 1)
-      @llvm.dx.resource.handlefrombinding(i32 2, i32 7, i32 1, i32 0, i1 false, ptr null)
+      @llvm.dx.resource.handlefrombinding(i32 2, i32 7, i32 1, i32 0, i1 false, ptr @Three.str)
   ; CHECK: Resource [[UAV0:[0-9]+]]:
+  ; CHECK:   Name: Three
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 0
   ; CHECK:     Space: 2
@@ -63,9 +77,10 @@ define void @test_typedbuffer() {
 
   ; RWBuffer<float4> Buf : register(u5, space3)
   %uav1 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
-      @llvm.dx.resource.handlefrombinding(i32 3, i32 5, i32 1, i32 0, i1 false, ptr null)
+      @llvm.dx.resource.handlefrombinding(i32 3, i32 5, i32 1, i32 0, i1 false, ptr @Four.str)
   call i32 @llvm.dx.resource.updatecounter(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %uav1, i8 -1)
   ; CHECK: Resource [[UAV1:[0-9]+]]:
+  ; CHECK:   Name: Four
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 1
   ; CHECK:     Space: 3
@@ -82,12 +97,13 @@ define void @test_typedbuffer() {
   ; RWBuffer<float4> BufferArray[10] : register(u0, space4)
   ; RWBuffer<float4> Buf = BufferArray[0]
   %uav2_1 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
-        @llvm.dx.resource.handlefrombinding(i32 4, i32 0, i32 10, i32 0, i1 false, ptr null)
+        @llvm.dx.resource.handlefrombinding(i32 4, i32 0, i32 10, i32 0, i1 false, ptr @Array.str)
   ; RWBuffer<float4> Buf = BufferArray[5]
   %uav2_2 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
-        @llvm.dx.resource.handlefrombinding(i32 4, i32 0, i32 10, i32 5, i1 false, ptr null)
+        @llvm.dx.resource.handlefrombinding(i32 4, i32 0, i32 10, i32 5, i1 false, ptr @Array.str)
   call i32 @llvm.dx.resource.updatecounter(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %uav2_2, i8 1)
   ; CHECK: Resource [[UAV2:[0-9]+]]:
+  ; CHECK:   Name: Array
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 2
   ; CHECK:     Space: 4
@@ -103,10 +119,11 @@ define void @test_typedbuffer() {
 
   ; RWBuffer<float4> Buf : register(u0, space5)
   %uav3 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
-      @llvm.dx.resource.handlefrombinding(i32 5, i32 0, i32 1, i32 0, i1 false, ptr null)
+      @llvm.dx.resource.handlefrombinding(i32 5, i32 0, i32 1, i32 0, i1 false, ptr @Five.str)
   call i32 @llvm.dx.resource.updatecounter(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %uav3, i8 -1)
   call i32 @llvm.dx.resource.updatecounter(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %uav3, i8 1)
   ; CHECK: Resource [[UAV3:[0-9]+]]:
+  ; CHECK:   Name: Five
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 3
   ; CHECK:     Space: 5
@@ -121,8 +138,9 @@ define void @test_typedbuffer() {
   ; CHECK:   Element Count: 4
 
   %cb0 = call target("dx.CBuffer", {float})
-     @llvm.dx.resource.handlefrombinding(i32 1, i32 0, i32 1, i32 0, i1 false, ptr null)
+     @llvm.dx.resource.handlefrombinding(i32 1, i32 0, i32 1, i32 0, i1 false, ptr @CB.str)
   ; CHECK: Resource [[CB0:[0-9]+]]:
+  ; CHECK:   Name: CB
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 0
   ; CHECK:     Space: 1
@@ -133,8 +151,9 @@ define void @test_typedbuffer() {
   ; CHECK:   CBuffer size: 4
 
   %cb1 = call target("dx.CBuffer", target("dx.Layout", {float}, 4, 0))
-     @llvm.dx.resource.handlefrombinding(i32 1, i32 8, i32 1, i32 0, i1 false, ptr null)
+     @llvm.dx.resource.handlefrombinding(i32 1, i32 8, i32 1, i32 0, i1 false, ptr @Constants.str)
   ; CHECK: Resource [[CB1:[0-9]+]]:
+  ; CHECK:   Name: Constants
   ; CHECK:   Binding:
   ; CHECK:     Record ID: 1
   ; CHECK:     Space: 1
diff --git a/llvm/unittests/Analysis/DXILResourceTest.cpp b/llvm/unittests/Analysis/DXILResourceTest.cpp
index 669f849bbaa97..f6d6ddf9cbb2d 100644
--- a/llvm/unittests/Analysis/DXILResourceTest.cpp
+++ b/llvm/unittests/Analysis/DXILResourceTest.cpp
@@ -101,9 +101,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "Buffer");
+        RTI.getHandleTy(), "Buffer");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000000bU, 0U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "Buffer", 0, 0, 1, 11, 0, nullptr));
@@ -119,9 +118,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/1, /*Space=*/2, /*LowerBound=*/3, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "BufferOut");
+        RTI.getHandleTy(), "BufferOut");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000100bU, 0U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(1, GV, "BufferOut", 2, 3, 1, 11, false, false, false,
@@ -146,9 +144,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "Buffer0");
+        RTI.getHandleTy(), "Buffer0");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000030cU, 0x00000010U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI), TestMD.get(0, GV, "Buffer0", 0, 0, 1,
                                                      12, 0, TestMD.get(1, 16)));
@@ -166,9 +163,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/1, /*Space=*/0, /*LowerBound=*/1, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "Buffer1");
+        RTI.getHandleTy(), "Buffer1");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000000cU, 0x0000000cU);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI), TestMD.get(1, GV, "Buffer1", 0, 1, 1,
                                                      12, 0, TestMD.get(1, 12)));
@@ -188,9 +184,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/2, /*Space=*/0, /*LowerBound=*/2, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "ColorMapTexture");
+        RTI.getHandleTy(), "ColorMapTexture");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x00000002U, 0x00000409U);
     EXPECT_MDEQ(
         RI.getAsMetadata(M, RTI),
@@ -213,9 +208,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "DepthBuffer");
+        RTI.getHandleTy(), "DepthBuffer");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x00000003U, 0x00080109U);
     EXPECT_MDEQ(
         RI.getAsMetadata(M, RTI),
@@ -235,9 +229,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "feedbackMinMip");
+        RTI.getHandleTy(), "feedbackMinMip");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x00001011U, 0U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "feedbackMinMip", 0, 0, 1, 17, false, false,
@@ -257,9 +250,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "feedbackMipRegion");
+        RTI.getHandleTy(), "feedbackMipRegion");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x00001012U, 0x00000001U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "feedbackMipRegion", 0, 0, 1, 18, false,
@@ -280,10 +272,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/2, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
+        RTI.getHandleTy(), "OutputTexture");
     RI.GloballyCoherent = true;
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "OutputTexture");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x00005002U, 0x00000204U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "OutputTexture", 2, 0, 1, 2, true, false,
@@ -308,8 +299,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct(), "ROB");
+        RTI.getHandleTy(), "ROB");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000300aU, 0x00000409U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "ROB", 0, 0, 1, 10, false, false, true,
@@ -334,10 +325,9 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/2, /*Size=*/1,
-        RTI.getHandleTy());
+        RTI.getHandleTy(), "g_OutputBuffer");
     RI.CounterDirection = ResourceCounterDirection::Increment;
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "g_OutputBuffer");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000920cU, 0x00000014U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "g_OutputBuffer", 0, 2, 1, 12, false, true,
@@ -364,9 +354,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "g_rw_t2dmsa");
+        RTI.getHandleTy(), "g_rw_t2dmsa");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x00001008U, 0x00080105U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "g_rw_t2dmsa", 0, 0, 1, 8, false, false,
@@ -388,8 +377,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct(), "");
+        RTI.getHandleTy(), "");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000000dU, 0x00000020U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "", 0, 0, 1, 32, nullptr));
@@ -406,9 +395,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "ColorMapSampler");
+        RTI.getHandleTy(), "ColorMapSampler");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000000eU, 0U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "ColorMapSampler", 0, 0, 1, 0, nullptr));
@@ -424,9 +412,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
 
     ResourceInfo RI(
         /*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
-        RTI.getHandleTy());
-    GlobalVariable *GV =
-        RI.createSymbol(M, RTI.createElementStruct(), "CmpSampler");
+        RTI.getHandleTy(), "CmpSampler");
+    GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct());
     EXPECT_PROPS_EQ(RI.getAnnotateProps(M, RTI), 0x0000800eU, 0U);
     EXPECT_MDEQ(RI.getAsMetadata(M, RTI),
                 TestMD.get(0, GV, "CmpSampler", 0, 0, 1, 1, nullptr));



More information about the llvm-branch-commits mailing list