Skip to content

[DirectX] Remove DXILResourceMDAnalysis #130323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2025
Merged

Conversation

hekota
Copy link
Member

@hekota hekota commented Mar 7, 2025

Removing DXILResourceMDAnalysis that gathers information about resources for the DXILTranslateMetadata pass. It collects the info based on obsolete resource metadata annotations that are going to be removed soon.

Part 1/2 of #114126

@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2025

@llvm/pr-subscribers-backend-directx

Author: Helena Kotas (hekota)

Changes

DXILResourceMDAnalysis gathers information about resources from obsolete resource metadata annotations that are going to be removed in a follow-up PR.

Part 1/2 of #114126


Patch is 33.16 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/130323.diff

15 Files Affected:

  • (modified) llvm/lib/Target/DirectX/CMakeLists.txt (-2)
  • (modified) llvm/lib/Target/DirectX/DXILDataScalarization.h (-1)
  • (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h (-1)
  • (modified) llvm/lib/Target/DirectX/DXILOpLowering.cpp (-2)
  • (modified) llvm/lib/Target/DirectX/DXILPrepare.cpp (-2)
  • (modified) llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp (+3-20)
  • (removed) llvm/lib/Target/DirectX/DXILResource.cpp (-346)
  • (removed) llvm/lib/Target/DirectX/DXILResource.h (-133)
  • (removed) llvm/lib/Target/DirectX/DXILResourceAnalysis.cpp (-41)
  • (removed) llvm/lib/Target/DirectX/DXILResourceAnalysis.h (-55)
  • (modified) llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp (+4-27)
  • (modified) llvm/lib/Target/DirectX/DirectX.h (-3)
  • (modified) llvm/lib/Target/DirectX/DirectXPassRegistry.def (-1)
  • (modified) llvm/lib/Target/DirectX/DirectXTargetMachine.cpp (-2)
  • (modified) llvm/test/CodeGen/DirectX/llc-pipeline.ll (-1)
diff --git a/llvm/lib/Target/DirectX/CMakeLists.txt b/llvm/lib/Target/DirectX/CMakeLists.txt
index 5a167535b0afa..6904a1c0f1e73 100644
--- a/llvm/lib/Target/DirectX/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/CMakeLists.txt
@@ -28,8 +28,6 @@ add_llvm_target(DirectXCodeGen
   DXILOpLowering.cpp
   DXILPrepare.cpp
   DXILPrettyPrinter.cpp
-  DXILResource.cpp
-  DXILResourceAnalysis.cpp
   DXILResourceAccess.cpp
   DXILShaderFlags.cpp
   DXILTranslateMetadata.cpp
diff --git a/llvm/lib/Target/DirectX/DXILDataScalarization.h b/llvm/lib/Target/DirectX/DXILDataScalarization.h
index 560e061db96d0..e8cd495729431 100644
--- a/llvm/lib/Target/DirectX/DXILDataScalarization.h
+++ b/llvm/lib/Target/DirectX/DXILDataScalarization.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_TARGET_DIRECTX_DXILDATASCALARIZATION_H
 #define LLVM_TARGET_DIRECTX_DXILDATASCALARIZATION_H
 
-#include "DXILResource.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 
diff --git a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h
index c283386c6e3df..43fc4d7735e1f 100644
--- a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h
+++ b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.h
@@ -8,7 +8,6 @@
 #ifndef LLVM_TARGET_DIRECTX_DXILINTRINSICEXPANSION_H
 #define LLVM_TARGET_DIRECTX_DXILINTRINSICEXPANSION_H
 
-#include "DXILResource.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
index 92b6787b9571e..1b02206464661 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
@@ -10,7 +10,6 @@
 #include "DXILConstants.h"
 #include "DXILIntrinsicExpansion.h"
 #include "DXILOpBuilder.h"
-#include "DXILResourceAnalysis.h"
 #include "DXILShaderFlags.h"
 #include "DirectX.h"
 #include "llvm/ADT/SmallVector.h"
@@ -889,7 +888,6 @@ class DXILOpLoweringLegacy : public ModulePass {
     AU.addRequired<DXILResourceTypeWrapperPass>();
     AU.addRequired<DXILResourceBindingWrapperPass>();
     AU.addPreserved<DXILResourceBindingWrapperPass>();
-    AU.addPreserved<DXILResourceMDWrapper>();
     AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
     AU.addPreserved<ShaderFlagsAnalysisWrapper>();
   }
diff --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index 355c79ae0edc9..0014cc9e1f67c 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -11,7 +11,6 @@
 /// Language (DXIL).
 //===----------------------------------------------------------------------===//
 
-#include "DXILResourceAnalysis.h"
 #include "DXILShaderFlags.h"
 #include "DirectX.h"
 #include "DirectXIRPasses/PointerTypeAnalysis.h"
@@ -248,7 +247,6 @@ class DXILPrepareModule : public ModulePass {
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.addRequired<DXILMetadataAnalysisWrapperPass>();
     AU.addPreserved<ShaderFlagsAnalysisWrapper>();
-    AU.addPreserved<DXILResourceMDWrapper>();
     AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
     AU.addPreserved<DXILResourceBindingWrapperPass>();
   }
diff --git a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
index 7255a9be06d51..c1f2483044693 100644
--- a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "DXILPrettyPrinter.h"
-#include "DXILResourceAnalysis.h"
 #include "DirectX.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/DXILResource.h"
@@ -222,8 +221,7 @@ struct FormatBindingSize
 } // namespace
 
 static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
-                                 DXILResourceTypeMap &DRTM,
-                                 const dxil::Resources &MDResources) {
+                                 DXILResourceTypeMap &DRTM) {
   // Column widths are arbitrary but match the widths DXC uses.
   OS << ";\n; Resource Bindings:\n;\n";
   OS << formatv("; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", "Name",
@@ -237,11 +235,6 @@ static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
     const dxil::ResourceTypeInfo &RTI = DRTM[RBI.getHandleTy()];
 
     dxil::ResourceClass RC = RTI.getResourceClass();
-    assert((RC != dxil::ResourceClass::CBuffer || !MDResources.hasCBuffers()) &&
-           "Old and new cbuffer representations can't coexist");
-    assert((RC != dxil::ResourceClass::UAV || !MDResources.hasUAVs()) &&
-           "Old and new UAV representations can't coexist");
-
     StringRef Name(RBI.getName());
     StringRef Type(getRCName(RC));
     StringRef Format(getFormatName(RTI));
@@ -252,12 +245,6 @@ static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
     OS << formatv("; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", Name,
                   Type, Format, Dim, ID, Bind, Count);
   }
-
-  if (MDResources.hasCBuffers())
-    MDResources.printCBuffers(OS);
-  if (MDResources.hasUAVs())
-    MDResources.printUAVs(OS);
-
   OS << ";\n";
 }
 
@@ -265,8 +252,7 @@ PreservedAnalyses DXILPrettyPrinterPass::run(Module &M,
                                              ModuleAnalysisManager &MAM) {
   const DXILBindingMap &DBM = MAM.getResult<DXILResourceBindingAnalysis>(M);
   DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
-  const dxil::Resources &MDResources = MAM.getResult<DXILResourceMDAnalysis>(M);
-  prettyPrintResources(OS, DBM, DRTM, MDResources);
+  prettyPrintResources(OS, DBM, DRTM);
   return PreservedAnalyses::all();
 }
 
@@ -293,7 +279,6 @@ class DXILPrettyPrinterLegacy : public llvm::ModulePass {
     AU.setPreservesAll();
     AU.addRequired<DXILResourceTypeWrapperPass>();
     AU.addRequired<DXILResourceBindingWrapperPass>();
-    AU.addRequired<DXILResourceMDWrapper>();
   }
 };
 } // namespace
@@ -303,7 +288,6 @@ INITIALIZE_PASS_BEGIN(DXILPrettyPrinterLegacy, "dxil-pretty-printer",
                       "DXIL Metadata Pretty Printer", true, true)
 INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DXILResourceMDWrapper)
 INITIALIZE_PASS_END(DXILPrettyPrinterLegacy, "dxil-pretty-printer",
                     "DXIL Metadata Pretty Printer", true, true)
 
@@ -312,8 +296,7 @@ bool DXILPrettyPrinterLegacy::runOnModule(Module &M) {
       getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
   DXILResourceTypeMap &DRTM =
       getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
-  dxil::Resources &Res = getAnalysis<DXILResourceMDWrapper>().getDXILResource();
-  prettyPrintResources(OS, DBM, DRTM, Res);
+  prettyPrintResources(OS, DBM, DRTM);
   return false;
 }
 
diff --git a/llvm/lib/Target/DirectX/DXILResource.cpp b/llvm/lib/Target/DirectX/DXILResource.cpp
deleted file mode 100644
index f027283b70521..0000000000000
--- a/llvm/lib/Target/DirectX/DXILResource.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-//===- DXILResource.cpp - DXIL Resource helper objects --------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file This file contains helper objects for working with DXIL Resources.
-///
-//===----------------------------------------------------------------------===//
-
-#include "DXILResource.h"
-#include "CBufferDataLayout.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/Metadata.h"
-#include "llvm/IR/Module.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/Format.h"
-
-using namespace llvm;
-using namespace llvm::dxil;
-
-template <typename T> void ResourceTable<T>::collect(Module &M) {
-  NamedMDNode *Entry = M.getNamedMetadata(MDName);
-  if (!Entry || Entry->getNumOperands() == 0)
-    return;
-
-  uint32_t Counter = 0;
-  for (auto *Res : Entry->operands()) {
-    Data.push_back(T(Counter++, hlsl::FrontendResource(cast<MDNode>(Res))));
-  }
-}
-
-template <> void ResourceTable<ConstantBuffer>::collect(Module &M) {
-  NamedMDNode *Entry = M.getNamedMetadata(MDName);
-  if (!Entry || Entry->getNumOperands() == 0)
-    return;
-
-  uint32_t Counter = 0;
-  for (auto *Res : Entry->operands()) {
-    Data.push_back(
-        ConstantBuffer(Counter++, hlsl::FrontendResource(cast<MDNode>(Res))));
-  }
-  // FIXME: share CBufferDataLayout with CBuffer load lowering.
-  //   See https://github.com/llvm/llvm-project/issues/58381
-  CBufferDataLayout CBDL(M.getDataLayout(), /*IsLegacy*/ true);
-  for (auto &CB : Data)
-    CB.setSize(CBDL);
-}
-
-void Resources::collect(Module &M) {
-  UAVs.collect(M);
-  CBuffers.collect(M);
-}
-
-ResourceBase::ResourceBase(uint32_t I, hlsl::FrontendResource R)
-    : ID(I), GV(R.getGlobalVariable()), Name(""), Space(R.getSpace()),
-      LowerBound(R.getResourceIndex()), RangeSize(1) {
-  if (auto *ArrTy = dyn_cast<ArrayType>(GV->getValueType()))
-    RangeSize = ArrTy->getNumElements();
-}
-
-StringRef ResourceBase::getElementTypeName(ElementType ElTy) {
-  switch (ElTy) {
-  case ElementType::Invalid:
-    return "invalid";
-  case ElementType::I1:
-    return "i1";
-  case ElementType::I16:
-    return "i16";
-  case ElementType::U16:
-    return "u16";
-  case ElementType::I32:
-    return "i32";
-  case ElementType::U32:
-    return "u32";
-  case ElementType::I64:
-    return "i64";
-  case ElementType::U64:
-    return "u64";
-  case ElementType::F16:
-    return "f16";
-  case ElementType::F32:
-    return "f32";
-  case ElementType::F64:
-    return "f64";
-  case ElementType::SNormF16:
-    return "snorm_f16";
-  case ElementType::UNormF16:
-    return "unorm_f16";
-  case ElementType::SNormF32:
-    return "snorm_f32";
-  case ElementType::UNormF32:
-    return "unorm_f32";
-  case ElementType::SNormF64:
-    return "snorm_f64";
-  case ElementType::UNormF64:
-    return "unorm_f64";
-  case ElementType::PackedS8x32:
-    return "p32i8";
-  case ElementType::PackedU8x32:
-    return "p32u8";
-  }
-  llvm_unreachable("All ElementType enums are handled in switch");
-}
-
-void ResourceBase::printElementType(ResourceKind Kind, ElementType ElTy,
-                                    unsigned Alignment, raw_ostream &OS) {
-  switch (Kind) {
-  default:
-    // TODO: add vector size.
-    OS << right_justify(getElementTypeName(ElTy), Alignment);
-    break;
-  case ResourceKind::RawBuffer:
-    OS << right_justify("byte", Alignment);
-    break;
-  case ResourceKind::StructuredBuffer:
-    OS << right_justify("struct", Alignment);
-    break;
-  case ResourceKind::CBuffer:
-  case ResourceKind::Sampler:
-    OS << right_justify("NA", Alignment);
-    break;
-  case ResourceKind::Invalid:
-  case ResourceKind::NumEntries:
-    break;
-  }
-}
-
-StringRef ResourceBase::getKindName(ResourceKind Kind) {
-  switch (Kind) {
-  case ResourceKind::NumEntries:
-  case ResourceKind::Invalid:
-    return "invalid";
-  case ResourceKind::Texture1D:
-    return "1d";
-  case ResourceKind::Texture2D:
-    return "2d";
-  case ResourceKind::Texture2DMS:
-    return "2dMS";
-  case ResourceKind::Texture3D:
-    return "3d";
-  case ResourceKind::TextureCube:
-    return "cube";
-  case ResourceKind::Texture1DArray:
-    return "1darray";
-  case ResourceKind::Texture2DArray:
-    return "2darray";
-  case ResourceKind::Texture2DMSArray:
-    return "2darrayMS";
-  case ResourceKind::TextureCubeArray:
-    return "cubearray";
-  case ResourceKind::TypedBuffer:
-    return "buf";
-  case ResourceKind::RawBuffer:
-    return "rawbuf";
-  case ResourceKind::StructuredBuffer:
-    return "structbuf";
-  case ResourceKind::CBuffer:
-    return "cbuffer";
-  case ResourceKind::Sampler:
-    return "sampler";
-  case ResourceKind::TBuffer:
-    return "tbuffer";
-  case ResourceKind::RTAccelerationStructure:
-    return "ras";
-  case ResourceKind::FeedbackTexture2D:
-    return "fbtex2d";
-  case ResourceKind::FeedbackTexture2DArray:
-    return "fbtex2darray";
-  }
-  llvm_unreachable("All ResourceKind enums are handled in switch");
-}
-
-void ResourceBase::printKind(ResourceKind Kind, unsigned Alignment,
-                             raw_ostream &OS, bool SRV, bool HasCounter,
-                             uint32_t SampleCount) {
-  switch (Kind) {
-  default:
-    OS << right_justify(getKindName(Kind), Alignment);
-    break;
-
-  case ResourceKind::RawBuffer:
-  case ResourceKind::StructuredBuffer:
-    if (SRV)
-      OS << right_justify("r/o", Alignment);
-    else {
-      if (!HasCounter)
-        OS << right_justify("r/w", Alignment);
-      else
-        OS << right_justify("r/w+cnt", Alignment);
-    }
-    break;
-  case ResourceKind::TypedBuffer:
-    OS << right_justify("buf", Alignment);
-    break;
-  case ResourceKind::Texture2DMS:
-  case ResourceKind::Texture2DMSArray: {
-    std::string DimName = getKindName(Kind).str();
-    if (SampleCount)
-      DimName += std::to_string(SampleCount);
-    OS << right_justify(DimName, Alignment);
-  } break;
-  case ResourceKind::CBuffer:
-  case ResourceKind::Sampler:
-    OS << right_justify("NA", Alignment);
-    break;
-  case ResourceKind::Invalid:
-  case ResourceKind::NumEntries:
-    break;
-  }
-}
-
-void ResourceBase::print(raw_ostream &OS, StringRef IDPrefix,
-                         StringRef BindingPrefix) const {
-  std::string ResID = IDPrefix.str();
-  ResID += std::to_string(ID);
-  OS << right_justify(ResID, 8);
-
-  std::string Bind = BindingPrefix.str();
-  Bind += std::to_string(LowerBound);
-  if (Space)
-    Bind += ",space" + std::to_string(Space);
-
-  OS << right_justify(Bind, 15);
-  if (RangeSize != UINT_MAX)
-    OS << right_justify(std::to_string(RangeSize), 6) << "\n";
-  else
-    OS << right_justify("unbounded", 6) << "\n";
-}
-
-void UAVResource::print(raw_ostream &OS) const {
-  OS << "; " << left_justify(Name, 31);
-
-  OS << right_justify("UAV", 10);
-
-  printElementType(Shape, ExtProps.ElementType.value_or(ElementType::Invalid),
-                   8, OS);
-
-  // FIXME: support SampleCount.
-  // See https://github.com/llvm/llvm-project/issues/58175
-  printKind(Shape, 12, OS, /*SRV*/ false, HasCounter);
-  // Print the binding part.
-  ResourceBase::print(OS, "U", "u");
-}
-
-ConstantBuffer::ConstantBuffer(uint32_t I, hlsl::FrontendResource R)
-    : ResourceBase(I, R) {}
-
-void ConstantBuffer::setSize(CBufferDataLayout &DL) {
-  CBufferSizeInBytes = DL.getTypeAllocSizeInBytes(GV->getValueType());
-}
-
-void ConstantBuffer::print(raw_ostream &OS) const {
-  OS << "; " << left_justify(Name, 31);
-
-  OS << right_justify("cbuffer", 10);
-
-  printElementType(ResourceKind::CBuffer, ElementType::Invalid, 8, OS);
-
-  printKind(ResourceKind::CBuffer, 12, OS, /*SRV*/ false, /*HasCounter*/ false);
-  // Print the binding part.
-  ResourceBase::print(OS, "CB", "cb");
-}
-
-template <typename T> void ResourceTable<T>::print(raw_ostream &OS) const {
-  for (auto &Res : Data)
-    Res.print(OS);
-}
-
-MDNode *ResourceBase::ExtendedProperties::write(LLVMContext &Ctx) const {
-  IRBuilder<> B(Ctx);
-  SmallVector<Metadata *> Entries;
-  if (ElementType) {
-    Entries.emplace_back(
-        ConstantAsMetadata::get(B.getInt32(TypedBufferElementType)));
-    Entries.emplace_back(ConstantAsMetadata::get(
-        B.getInt32(static_cast<uint32_t>(*ElementType))));
-  }
-  if (Entries.empty())
-    return nullptr;
-  return MDNode::get(Ctx, Entries);
-}
-
-void ResourceBase::write(LLVMContext &Ctx,
-                         MutableArrayRef<Metadata *> Entries) const {
-  IRBuilder<> B(Ctx);
-  Entries[0] = ConstantAsMetadata::get(B.getInt32(ID));
-  Entries[1] = ConstantAsMetadata::get(GV);
-  Entries[2] = MDString::get(Ctx, Name);
-  Entries[3] = ConstantAsMetadata::get(B.getInt32(Space));
-  Entries[4] = ConstantAsMetadata::get(B.getInt32(LowerBound));
-  Entries[5] = ConstantAsMetadata::get(B.getInt32(RangeSize));
-}
-
-MDNode *UAVResource::write() const {
-  auto &Ctx = GV->getContext();
-  IRBuilder<> B(Ctx);
-  Metadata *Entries[11];
-  ResourceBase::write(Ctx, Entries);
-  Entries[6] =
-      ConstantAsMetadata::get(B.getInt32(static_cast<uint32_t>(Shape)));
-  Entries[7] = ConstantAsMetadata::get(B.getInt1(GloballyCoherent));
-  Entries[8] = ConstantAsMetadata::get(B.getInt1(HasCounter));
-  Entries[9] = ConstantAsMetadata::get(B.getInt1(IsROV));
-  Entries[10] = ExtProps.write(Ctx);
-  return MDNode::get(Ctx, Entries);
-}
-
-MDNode *ConstantBuffer::write() const {
-  auto &Ctx = GV->getContext();
-  IRBuilder<> B(Ctx);
-  Metadata *Entries[7];
-  ResourceBase::write(Ctx, Entries);
-
-  Entries[6] = ConstantAsMetadata::get(B.getInt32(CBufferSizeInBytes));
-  return MDNode::get(Ctx, Entries);
-}
-
-template <typename T> MDNode *ResourceTable<T>::write(Module &M) const {
-  if (Data.empty())
-    return nullptr;
-  SmallVector<Metadata *> MDs;
-  for (auto &Res : Data)
-    MDs.emplace_back(Res.write());
-
-  NamedMDNode *Entry = M.getNamedMetadata(MDName);
-  if (Entry)
-    Entry->eraseFromParent();
-
-  return MDNode::get(M.getContext(), MDs);
-}
-
-Metadata *Resources::writeUAVs(Module &M) const { return UAVs.write(M); }
-void Resources::printUAVs(raw_ostream &OS) const { UAVs.print(OS); }
-Metadata *Resources::writeCBuffers(Module &M) const {
-  return CBuffers.write(M);
-}
-void Resources::printCBuffers(raw_ostream &OS) const { CBuffers.print(OS); }
-
-void Resources::dump() const {
-  printCBuffers(dbgs());
-  printUAVs(dbgs());
-}
diff --git a/llvm/lib/Target/DirectX/DXILResource.h b/llvm/lib/Target/DirectX/DXILResource.h
deleted file mode 100644
index 812729bc4dc57..0000000000000
--- a/llvm/lib/Target/DirectX/DXILResource.h
+++ /dev/null
@@ -1,133 +0,0 @@
-//===- DXILResource.h - DXIL Resource helper objects ----------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file This file contains helper objects for working with DXIL Resources.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TARGET_DIRECTX_DXILRESOURCE_H
-#define LLVM_TARGET_DIRECTX_DXILRESOURCE_H
-
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Frontend/HLSL/HLSLResource.h"
-#include "llvm/IR/Metadata.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DXILABI.h"
-#include <cstdint>
-
-namespace llvm {
-class Module;
-class GlobalVariable;
-
-namespace dxil {
-class CBufferDataLayout;
-
-class ResourceBase {
-protected:
-  uint32_t ID;
-  GlobalVariable *GV;
-  StringRef Name;
-  uint32_t Space;
-  uint32_t LowerBound;
-  uint32_t RangeSize;
-  ResourceBase(uint32_t I, hlsl::FrontendResource R);
-
-  void write(LLVMContext &Ctx, MutableArrayRef<Metadata *> Entries) const;
-
-  void print(raw_ostream &O, StringRef IDPrefix, StringRef BindingPrefix) const;
-  static StringRef getKindName(dxil::ResourceKind Kind);
-  static void printKind(dxil::ResourceKind Kind, unsigned Alignment,
-                        raw_ostream &OS, bool SRV = false,
-                        bool HasCounter = false, uint32_t SampleCount = 0);
-
-  static StringRef getElementTypeName(dxil::ElementType CompType);
-  static void printElementType(dxil::ResourceKind Kind,
-                               dxil::ElementType CompType, unsigned Alignment,
-                               raw_ostream &OS);
-
-public:
-  struct ExtendedProperties {
-    std::optional<dxil::ElementType> ElementType;
-
-    // The value ordering of this enumeration is part of the DXIL ABI. Elements
-    // can only be added to the end, and not removed.
-    enum Tags : uint32_t {
-      TypedBufferElementType = 0,
-      StructuredBufferElementStride,
-      SamplerFeedbackKind,
-      Atomic64Use
-    };
-
-    MDNode *write(LLVMContext &Ctx) const;
-  };
-};
-
-class UAVResource : public ResourceBase {
-  dxil::ResourceKind Shape;
-  bool GloballyCoherent;
-...
[truncated]

Copy link
Contributor

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll leave the approval to someone with more expertise.

@hekota hekota changed the base branch from users/hekota/pr-1302220-update-resource-metadata-tests to main March 12, 2025 05:23
@hekota hekota merged commit 1db978c into llvm:main Mar 12, 2025
12 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 13, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2478

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/91/94' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-8132-91-94.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=94 GTEST_SHARD_INDEX=91 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
Removing `DXILResourceMDAnalysis` that gathers information about
resources for the `DXILTranslateMetadata` pass. It collects the info
based on obsolete resource metadata annotations that are going to be
removed soon.

Part 1/2 of llvm#114126
@damyanp damyanp moved this to Closed in HLSL Support Apr 25, 2025
@damyanp damyanp removed this from HLSL Support Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants