From 379d1bcd2da76263dbe45e3ef9e997aa63b62923 Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Thu, 24 Apr 2025 15:03:52 -0700 Subject: [PATCH 1/3] [HLSL][NFC] Rename getBindingMap to getResourceMap The DXILResourceMap stores more information about resource instances than just their binding. --- llvm/include/llvm/Analysis/DXILResource.h | 4 ++-- llvm/lib/Target/DirectX/DXContainerGlobals.cpp | 2 +- llvm/lib/Target/DirectX/DXILOpLowering.cpp | 2 +- llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp | 2 +- llvm/lib/Target/DirectX/DXILShaderFlags.cpp | 3 ++- llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h index 1d871a448c16c..2631c3cb94c8a 100644 --- a/llvm/include/llvm/Analysis/DXILResource.h +++ b/llvm/include/llvm/Analysis/DXILResource.h @@ -573,8 +573,8 @@ class DXILResourceWrapperPass : public ModulePass { DXILResourceWrapperPass(); ~DXILResourceWrapperPass() override; - const DXILResourceMap &getBindingMap() const { return *Map; } - DXILResourceMap &getBindingMap() { return *Map; } + const DXILResourceMap &getResourceMap() const { return *Map; } + DXILResourceMap &getResourceMap() { return *Map; } void getAnalysisUsage(AnalysisUsage &AU) const override; bool runOnModule(Module &M) override; diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp index 0aa6516db636c..9c38901f6821f 100644 --- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp +++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp @@ -180,7 +180,7 @@ void DXContainerGlobals::addRootSignature(Module &M, void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) { const DXILResourceMap &DRM = - getAnalysis().getBindingMap(); + getAnalysis().getResourceMap(); DXILResourceTypeMap &DRTM = getAnalysis().getResourceTypeMap(); diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp index fe6dff57e2625..fdaffb6b5e49e 100644 --- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp +++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp @@ -829,7 +829,7 @@ class DXILOpLoweringLegacy : public ModulePass { public: bool runOnModule(Module &M) override { DXILResourceMap &DRM = - getAnalysis().getBindingMap(); + getAnalysis().getResourceMap(); DXILResourceTypeMap &DRTM = getAnalysis().getResourceTypeMap(); diff --git a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp index 30e4ae18bdab0..dc84ae49abbe3 100644 --- a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp +++ b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp @@ -291,7 +291,7 @@ INITIALIZE_PASS_END(DXILPrettyPrinterLegacy, "dxil-pretty-printer", bool DXILPrettyPrinterLegacy::runOnModule(Module &M) { const DXILResourceMap &DRM = - getAnalysis().getBindingMap(); + getAnalysis().getResourceMap(); DXILResourceTypeMap &DRTM = getAnalysis().getResourceTypeMap(); prettyPrintResources(OS, DRM, DRTM); diff --git a/llvm/lib/Target/DirectX/DXILShaderFlags.cpp b/llvm/lib/Target/DirectX/DXILShaderFlags.cpp index 282b9dcf6de2b..2e2906192a407 100644 --- a/llvm/lib/Target/DirectX/DXILShaderFlags.cpp +++ b/llvm/lib/Target/DirectX/DXILShaderFlags.cpp @@ -337,7 +337,8 @@ PreservedAnalyses ShaderFlagsAnalysisPrinter::run(Module &M, bool ShaderFlagsAnalysisWrapper::runOnModule(Module &M) { DXILResourceTypeMap &DRTM = getAnalysis().getResourceTypeMap(); - DXILResourceMap &DRM = getAnalysis().getBindingMap(); + DXILResourceMap &DRM = + getAnalysis().getResourceMap(); const ModuleMetadataInfo MMDI = getAnalysis().getModuleMetadata(); diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp index e177fcb0520e8..e0dce3d750ed1 100644 --- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp +++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp @@ -412,7 +412,7 @@ class DXILTranslateMetadataLegacy : public ModulePass { bool runOnModule(Module &M) override { DXILResourceMap &DRM = - getAnalysis().getBindingMap(); + getAnalysis().getResourceMap(); DXILResourceTypeMap &DRTM = getAnalysis().getResourceTypeMap(); const ModuleShaderFlags &ShaderFlags = From 8e94c0937d910822eeead7be8d9ea556be465734 Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Fri, 25 Apr 2025 12:51:19 -0700 Subject: [PATCH 2/3] also update the pass description --- llvm/lib/Analysis/DXILResource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp index cc1d931c9e077..96e1b44a17f30 100644 --- a/llvm/lib/Analysis/DXILResource.cpp +++ b/llvm/lib/Analysis/DXILResource.cpp @@ -946,7 +946,7 @@ void DXILResourceWrapperPass::dump() const { print(dbgs(), nullptr); } #endif INITIALIZE_PASS(DXILResourceWrapperPass, "dxil-resources", - "DXIL Resource Binding Analysis", false, true) + "DXIL Resources Analysis", false, true) char DXILResourceWrapperPass::ID = 0; ModulePass *llvm::createDXILResourceWrapperPassPass() { From 55becad61b8084433bcf82ec749e2b57060526cf Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Fri, 25 Apr 2025 13:06:13 -0700 Subject: [PATCH 3/3] Also update the test that list pass names --- llvm/test/CodeGen/DirectX/llc-pipeline.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/CodeGen/DirectX/llc-pipeline.ll b/llvm/test/CodeGen/DirectX/llc-pipeline.ll index 729258d27aec1..a2412b6324a05 100644 --- a/llvm/test/CodeGen/DirectX/llc-pipeline.ll +++ b/llvm/test/CodeGen/DirectX/llc-pipeline.ll @@ -24,7 +24,7 @@ ; CHECK-NEXT: Scalarize vector operations ; CHECK-NEXT: DXIL Forward Handle Accesses ; CHECK-NEXT: DXIL Legalizer -; CHECK-NEXT: DXIL Resource Binding Analysis +; CHECK-NEXT: DXIL Resources Analysis ; CHECK-NEXT: DXIL Module Metadata analysis ; CHECK-NEXT: DXIL Shader Flag Analysis ; CHECK-NEXT: DXIL Translate Metadata