Skip to content
Merged
Show file tree
Hide file tree
Changes from 116 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
0e8828c
refactoring
Jun 26, 2025
2edd215
refactoring
Jun 26, 2025
242545e
clean up
Jul 2, 2025
3f8dec4
format
Jul 2, 2025
3b1ce3b
formating
Jul 2, 2025
f5720af
fix import issues
Jul 4, 2025
ea54904
formating
Jul 4, 2025
a49aa19
refactoring
Jun 26, 2025
d90676f
init refactoring
Jun 26, 2025
a04eb9f
adding validation
Jul 2, 2025
5994b8f
clean
Jul 2, 2025
e8b14bf
implementing
Jul 4, 2025
8f40e83
finish implementing && fix tests
Jul 4, 2025
28350b2
fix issue
Jul 5, 2025
4fd2e0b
sync parent
Jul 5, 2025
e25ee87
sync parent
Jul 5, 2025
881dd36
address comments
Jul 7, 2025
8779ee9
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
Jul 7, 2025
c16f15b
fix test
Jul 8, 2025
c7d5be7
format
Jul 8, 2025
cc5afae
address changes
Jul 8, 2025
571a0ef
fix tests
Jul 8, 2025
974d4bc
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
Jul 8, 2025
e0bc862
add preserved
Jul 8, 2025
b5a0b32
addressing comments
Jul 10, 2025
00a74af
Merge branch 'main' into validation/check-descriptors-are-bound
Jul 10, 2025
5ccb842
updating
Jul 11, 2025
5423aba
format
Jul 14, 2025
a7637a7
adding tests
Jul 14, 2025
da42c0c
clean up
Jul 14, 2025
edb015d
address comments
Jul 15, 2025
9f3888e
adding root constants
Jul 15, 2025
578a03b
clean
Jul 15, 2025
b4a0e16
moving code arround
Jul 17, 2025
ef14638
clean
Jul 17, 2025
662c3a8
addressing comments
Jul 21, 2025
260633c
address comments
Jul 25, 2025
d42f156
Merge branch 'main' into validation/check-descriptors-are-bound
Jul 31, 2025
9ee3a4b
Merge branch 'main' into validation/check-descriptors-are-bound
Jul 31, 2025
6db6224
update code
Aug 1, 2025
04658b8
cleanup
Aug 1, 2025
adf3feb
address comments from inbelic
Aug 5, 2025
c95ce68
refactoring
Jun 26, 2025
af6aa53
add tests
Aug 5, 2025
29eb893
cleanup
Aug 5, 2025
ed4c553
clean
Aug 5, 2025
28fb609
clean up
Aug 6, 2025
fc338b5
Merge branch 'validation/overlapping-ranges' into validation/check-de…
Aug 6, 2025
f5b5b3e
clean
Aug 6, 2025
03d571a
clean?
Aug 6, 2025
ef51048
format
Aug 6, 2025
21675e6
formating
Aug 6, 2025
403972d
addressing comments from bogner and inbelic
joaosaffran-zz Aug 7, 2025
0f0435d
clean up
joaosaffran-zz Aug 7, 2025
e841a98
clean up
joaosaffran-zz Aug 7, 2025
ae6d67a
fix build
joaosaffran-zz Aug 7, 2025
41f32bd
fix tests
joaosaffran-zz Aug 8, 2025
47662f0
Merge branch 'validation/overlapping-ranges' into validation/check-de…
Aug 8, 2025
6da5fb0
format
Aug 8, 2025
6f3d019
Merge branch 'main' into validation/overlapping-ranges
Aug 8, 2025
971ad57
Merge branch 'main' into validation/overlapping-ranges
Aug 8, 2025
db73d71
update
Aug 8, 2025
3b04c2d
address comment from inbelic
Aug 12, 2025
1ddffc3
address comments 2
Aug 12, 2025
db0008e
addressing comments from inbelic
Aug 12, 2025
0c72dcf
addressing inbelic comments
Aug 12, 2025
b4e5fb4
adding test
Aug 12, 2025
4a655a5
addressing comments from bogner
Aug 13, 2025
cc94561
addressing comments
Aug 13, 2025
98f48d2
address comments
Aug 13, 2025
eb334b8
refactoring
Aug 13, 2025
06c0da4
addressing comments
Aug 14, 2025
d58606f
Merge branch 'main' into validation/overlapping-ranges
Aug 14, 2025
74980c8
fix test
Aug 14, 2025
d376abf
address comments
Aug 14, 2025
4abb40d
Merge branch 'validation/overlapping-ranges' into validation/check-de…
Aug 14, 2025
bb44eef
fix test
Aug 14, 2025
1cf2d1e
Merge branch 'main' into validation/check-descriptors-are-bound
Aug 14, 2025
373d871
clean up
Aug 14, 2025
d2750d7
format
Aug 14, 2025
6db8d93
refactoring to not create extra space
joaosaffran Aug 21, 2025
e3a65b6
remove copy of binding
joaosaffran Aug 21, 2025
e902add
making BindingRange const
joaosaffran Aug 21, 2025
9a6d64c
doing it again for other isBound
joaosaffran Aug 21, 2025
15b7592
adding DXILResourceTypeMap
joaosaffran Aug 21, 2025
11b9fb2
updating error messages and tests
joaosaffran Aug 21, 2025
0442b99
refactoring isBound to follow first suggestion
joaosaffran Aug 22, 2025
82bdf82
adding limits tests
joaosaffran Aug 22, 2025
9f18475
using find
joaosaffran Aug 22, 2025
964d165
add siggested test
joaosaffran Aug 22, 2025
e5ca2d6
Merge branch 'main' into validation/check-descriptors-are-bound
joaosaffran Aug 25, 2025
84f449b
fixing range bug
joaosaffran Aug 26, 2025
4d0fbbe
format
joaosaffran Aug 26, 2025
1ef79ad
refactor hlsl binding to support non free bindings
joaosaffran Aug 27, 2025
485e9b6
clean up
joaosaffran Aug 27, 2025
1945403
adding consecutive range fail test
joaosaffran Aug 27, 2025
acd966a
removing double public
joaosaffran Aug 27, 2025
8d2a9d1
remove dangling public
joaosaffran Aug 27, 2025
939b6aa
refactor to use bogner suggestions
joaosaffran Aug 27, 2025
4f7856f
forgot to check clang
joaosaffran Aug 27, 2025
2c8b999
clean up 1
joaosaffran Aug 27, 2025
f866fa9
clean up 2
joaosaffran Aug 27, 2025
741960e
clean up 3?
joaosaffran Aug 27, 2025
b275160
adding space got readability
joaosaffran Aug 28, 2025
a6a0ab7
adding comment
joaosaffran Aug 28, 2025
df3f096
removing calculateBindingInfo
joaosaffran Aug 28, 2025
b9eee70
removing calculateBoundRegs
joaosaffran Aug 28, 2025
3c2119f
removing regex from tests
joaosaffran Aug 28, 2025
9541ba3
remove immutable pass from preserved
joaosaffran Aug 28, 2025
1836e43
clean up
joaosaffran Aug 28, 2025
6726f1d
clean up 2
joaosaffran Aug 28, 2025
6254024
clean up 3
joaosaffran Aug 28, 2025
c87c1c0
clean up 4
joaosaffran Aug 28, 2025
239bf83
clean up 5
joaosaffran Aug 28, 2025
ad3d595
clean up 6
joaosaffran Aug 28, 2025
263ced2
clean up 7
joaosaffran Aug 28, 2025
c8ce514
formating 1
joaosaffran Aug 28, 2025
e2ddf4d
formating 2
joaosaffran Aug 28, 2025
4f90c8f
changing function name and signature
joaosaffran Aug 28, 2025
7a7c0bf
Merge branch 'main' into validation/check-descriptors-are-bound
joaosaffran Aug 28, 2025
5443a62
updating tests
joaosaffran Aug 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,12 +1146,12 @@ struct PerVisibilityBindingChecker {
using llvm::hlsl::BindingInfoBuilder;
auto ReportOverlap = [this, &HadOverlap](
const BindingInfoBuilder &Builder,
const BindingInfoBuilder::Binding &Reported) {
const llvm::hlsl::Binding &Reported) {
HadOverlap = true;

const auto *Elem =
static_cast<const hlsl::RootSignatureElement *>(Reported.Cookie);
const BindingInfoBuilder::Binding &Previous =
const llvm::hlsl::Binding &Previous =
Builder.findOverlapping(Reported);
const auto *PrevElem =
static_cast<const hlsl::RootSignatureElement *>(Previous.Cookie);
Expand Down
43 changes: 34 additions & 9 deletions llvm/include/llvm/Frontend/HLSL/HLSLBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef LLVM_FRONTEND_HLSL_HLSLBINDING_H
#define LLVM_FRONTEND_HLSL_HLSLBINDING_H

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
Expand Down Expand Up @@ -99,15 +100,12 @@ class BindingInfo {
friend class BindingInfoBuilder;
};

/// Builder class for creating a /c BindingInfo.
class BindingInfoBuilder {
public:
struct Binding {
dxil::ResourceClass RC;
uint32_t Space;
uint32_t LowerBound;
uint32_t UpperBound;
const void *Cookie;
struct Binding {
dxil::ResourceClass RC;
uint32_t Space;
uint32_t LowerBound;
uint32_t UpperBound;
const void *Cookie;

Binding(dxil::ResourceClass RC, uint32_t Space, uint32_t LowerBound,
uint32_t UpperBound, const void *Cookie)
Expand All @@ -128,7 +126,28 @@ class BindingInfoBuilder {
std::tie(RHS.RC, RHS.Space, RHS.LowerBound);
}
};
class BoundRegs {
SmallVector<Binding> Bindings;

public:
BoundRegs(SmallVector<Binding> &&Bindings) : Bindings(std::move(Bindings)) {}

bool isBound(dxil::ResourceClass RC, uint32_t Space, uint32_t LowerBound,
uint32_t UpperBound) const {
// UpperBound and Cookie are given dummy values, since they aren't
// interesting for operator<
const Binding *It =
llvm::upper_bound(Bindings, Binding{RC, Space, LowerBound, 0, nullptr});
if (It == Bindings.begin())
return false;
--It;
return It->RC == RC && It->Space == Space && It->LowerBound <= LowerBound &&
It->UpperBound >= UpperBound;
}
};

/// Builder class for creating a /c BindingInfo.
class BindingInfoBuilder {
private:
SmallVector<Binding> Bindings;

Expand All @@ -152,6 +171,12 @@ class BindingInfoBuilder {
[&HasOverlap](auto, auto) { HasOverlap = true; });
}

LLVM_ABI BoundRegs getBoundRegs(){
assert(std::is_sorted(Bindings.begin(), Bindings.end()) &&
"Bindings must be sorted");
Copy link
Contributor

Choose a reason for hiding this comment

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

std::is_sorted already makes it clear what we're asserting. Might be better to explain why with something like "getBoundRegs should only be called after calculateBindingInfo"

return BoundRegs(std::move(Bindings));
}

/// For use in the \c ReportOverlap callback of \c calculateBindingInfo -
/// finds a binding that the \c ReportedBinding overlaps with.
LLVM_ABI const Binding &findOverlapping(const Binding &ReportedBinding) const;
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Frontend/HLSL/HLSLBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ BindingInfo BindingInfoBuilder::calculateBindingInfo(
return Info;
}

const BindingInfoBuilder::Binding &BindingInfoBuilder::findOverlapping(
const BindingInfoBuilder::Binding &ReportedBinding) const {
for (const BindingInfoBuilder::Binding &Other : Bindings)
const Binding &BindingInfoBuilder::findOverlapping(
const Binding &ReportedBinding) const {
for (const Binding &Other : Bindings)
if (ReportedBinding.LowerBound <= Other.UpperBound &&
Other.LowerBound <= ReportedBinding.UpperBound)
return Other;
Expand Down
45 changes: 36 additions & 9 deletions llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ static void reportOverlappingBinding(Module &M, DXILResourceMap &DRM) {

static void
reportOverlappingRegisters(Module &M,
const llvm::hlsl::BindingInfoBuilder::Binding &R1,
const llvm::hlsl::BindingInfoBuilder::Binding &R2) {
const llvm::hlsl::Binding &R1,
const llvm::hlsl::Binding &R2) {
SmallString<128> Message;

raw_svector_ostream OS(Message);
Expand All @@ -133,6 +133,17 @@ reportOverlappingRegisters(Module &M,
M.getContext().diagnose(DiagnosticInfoGeneric(Message));
}

static void
reportRegNotBound(Module &M, ResourceClass Class,
const llvm::dxil::ResourceInfo::ResourceBinding &Unbound) {
SmallString<128> Message;
raw_svector_ostream OS(Message);
OS << getResourceClassName(Class) << " register " << Unbound.LowerBound
<< " in space " << Unbound.Space
<< " does not have a binding in the Root Signature";
M.getContext().diagnose(DiagnosticInfoGeneric(Message));
}

static dxbc::ShaderVisibility
tripleToVisibility(llvm::Triple::EnvironmentType ET) {
switch (ET) {
Expand All @@ -157,7 +168,9 @@ tripleToVisibility(llvm::Triple::EnvironmentType ET) {

static void validateRootSignature(Module &M,
const mcdxbc::RootSignatureDesc &RSD,
dxil::ModuleMetadataInfo &MMI) {
dxil::ModuleMetadataInfo &MMI,
DXILResourceMap &DRM,
DXILResourceTypeMap &DRTM) {

hlsl::BindingInfoBuilder Builder;
dxbc::ShaderVisibility Visibility = tripleToVisibility(MMI.ShaderProfile);
Expand Down Expand Up @@ -216,11 +229,19 @@ static void validateRootSignature(Module &M,

Builder.calculateBindingInfo(
[&M](const llvm::hlsl::BindingInfoBuilder &Builder,
const llvm::hlsl::BindingInfoBuilder::Binding &ReportedBinding) {
const llvm::hlsl::BindingInfoBuilder::Binding &Overlaping =
const llvm::hlsl::Binding &ReportedBinding) {
const llvm::hlsl::Binding &Overlaping =
Builder.findOverlapping(ReportedBinding);
reportOverlappingRegisters(M, ReportedBinding, Overlaping);
});
const hlsl::BoundRegs &BoundRegs = Builder.getBoundRegs();
for (const ResourceInfo &RI : DRM) {
const ResourceInfo::ResourceBinding &Binding = RI.getBinding();
ResourceClass RC = DRTM[RI.getHandleTy()].getResourceClass();
if (!BoundRegs.isBound(RC, Binding.Space, Binding.LowerBound,
Binding.LowerBound + Binding.Size - 1))
reportRegNotBound(M, RC, Binding);
}
}

static mcdxbc::RootSignatureDesc *
Expand All @@ -234,7 +255,8 @@ getRootSignature(RootSignatureBindingInfo &RSBI,
static void reportErrors(Module &M, DXILResourceMap &DRM,
DXILResourceBindingInfo &DRBI,
RootSignatureBindingInfo &RSBI,
dxil::ModuleMetadataInfo &MMI) {
dxil::ModuleMetadataInfo &MMI,
DXILResourceTypeMap &DRTM) {
if (DRM.hasInvalidCounterDirection())
reportInvalidDirection(M, DRM);

Expand All @@ -245,7 +267,7 @@ static void reportErrors(Module &M, DXILResourceMap &DRM,
"DXILResourceImplicitBinding pass");

if (mcdxbc::RootSignatureDesc *RSD = getRootSignature(RSBI, MMI))
validateRootSignature(M, *RSD, MMI);
validateRootSignature(M, *RSD, MMI, DRM, DRTM);
}

PreservedAnalyses
Expand All @@ -254,8 +276,9 @@ DXILPostOptimizationValidation::run(Module &M, ModuleAnalysisManager &MAM) {
DXILResourceBindingInfo &DRBI = MAM.getResult<DXILResourceBindingAnalysis>(M);
RootSignatureBindingInfo &RSBI = MAM.getResult<RootSignatureAnalysis>(M);
ModuleMetadataInfo &MMI = MAM.getResult<DXILMetadataAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);

reportErrors(M, DRM, DRBI, RSBI, MMI);
reportErrors(M, DRM, DRBI, RSBI, MMI, DRTM);
return PreservedAnalyses::all();
}

Expand All @@ -271,8 +294,10 @@ class DXILPostOptimizationValidationLegacy : public ModulePass {
getAnalysis<RootSignatureAnalysisWrapper>().getRSInfo();
dxil::ModuleMetadataInfo &MMI =
getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
DXILResourceTypeMap &DRTM =
getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();

reportErrors(M, DRM, DRBI, RSBI, MMI);
reportErrors(M, DRM, DRBI, RSBI, MMI, DRTM);
return false;
}
StringRef getPassName() const override {
Expand All @@ -286,6 +311,7 @@ class DXILPostOptimizationValidationLegacy : public ModulePass {
AU.addRequired<DXILResourceBindingWrapperPass>();
AU.addRequired<DXILMetadataAnalysisWrapperPass>();
AU.addRequired<RootSignatureAnalysisWrapper>();
AU.addRequired<DXILResourceTypeWrapperPass>();
AU.addPreserved<DXILResourceWrapperPass>();
AU.addPreserved<DXILResourceBindingWrapperPass>();
AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
Expand All @@ -303,6 +329,7 @@ INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DXILMetadataAnalysisWrapperPass)
INITIALIZE_PASS_DEPENDENCY(RootSignatureAnalysisWrapper)
INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
INITIALIZE_PASS_END(DXILPostOptimizationValidationLegacy, DEBUG_TYPE,
"DXIL Post Optimization Validation", false, false)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; This is a valid code, it checks the limits of a binding space
; CHECK-NOT: error:

%__cblayout_CB = type <{ float }>

@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 5, i32 0, i1 false, ptr nonnull @CB.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2}
!2 = !{!"DescriptorTable", i32 0, !3}
!3 = !{!"CBV", i32 5, i32 0, i32 0, i32 0, i32 4}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; This is a valid code, it checks the limits of a binding space

; CHECK-NOT: error:

%__cblayout_CB = type <{ float }>

@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 4294967294, i32 1, i32 0, i1 false, ptr nonnull @CB.str)
%CB1 = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false, ptr nonnull @CB.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2, !3}
!2 = !{!"RootCBV", i32 0, i32 4294967294, i32 0, i32 4}
!3 = !{!"RootCBV", i32 0, i32 0, i32 0, i32 4}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also add a couple tests for when it doesn't fail validation. For instance the cases:

CBV(b0) with CBuffer ... : register(b0) and DescriptorTable(CBV(b0, numDescriptors = 3)) with CBuffer [3] : register(b0)

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: error: CBV register 2 in space 666 does not have a binding in the Root Signature

%__cblayout_CB = type <{ float }>

@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 666, i32 2, i32 1, i32 0, i1 false, ptr nonnull @CB.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2}
!2 = !{!"RootConstants", i32 0, i32 2, i32 0, i32 4}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: CBV register 3 in space 0 does not have a binding in the Root Signature
%__cblayout_CB = type <{ float }>

@CB.str = private unnamed_addr constant [3 x i8] c"CB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
%CB = tail call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB, 4, 0)) @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 6, i32 0, i1 false, ptr nonnull @CB.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2}
!2 = !{!"DescriptorTable", i32 0, !3, !4}
!3 = !{!"CBV", i32 5, i32 2, i32 0, i32 0, i32 4}
!4 = !{!"CBV", i32 4, i32 7, i32 0, i32 10, i32 4}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: error: Sampler register 3 in space 2 does not have a binding in the Root Signature

@Smp.str = private unnamed_addr constant [4 x i8] c"Smp\00", align 1


define void @CSMain() "hlsl.shader"="compute" {
entry:
%Sampler = call target("dx.Sampler", 0) @llvm.dx.resource.handlefrombinding(i32 2, i32 3, i32 1, i32 0, i1 false, ptr nonnull @Smp.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2}
!2 = !{!"DescriptorTable", i32 0, !3}
!3 = !{!"Sampler", i32 1, i32 42, i32 0, i32 -1, i32 0}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: error: SRV register 0 in space 0 does not have a binding in the Root Signature

@SB.str = private unnamed_addr constant [3 x i8] c"SB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
; StructuredBuffer<int> In : register(t0, space0);
%SB = tail call target("dx.RawBuffer", i32, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_0_0t(i32 0, i32 0, i32 1, i32 0, i1 false, ptr nonnull @SB.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2, !3, !5, !7}
!2 = !{!"RootCBV", i32 0, i32 3, i32 666, i32 4}
!3 = !{!"DescriptorTable", i32 1, !4}
!4 = !{!"SRV", i32 1, i32 0, i32 0, i32 -1, i32 4}
!5 = !{!"DescriptorTable", i32 0, !6}
!6 = !{!"Sampler", i32 2, i32 0, i32 0, i32 -1, i32 0}
!7 = !{!"DescriptorTable", i32 0, !8}
!8 = !{!"UAV", i32 -1, i32 0, i32 0, i32 -1, i32 2}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | FileCheck %s
; CHECK: error: UAV register 4294967294 in space 0 does not have a binding in the Root Signature

@RWB.str = private unnamed_addr constant [4 x i8] c"RWB\00", align 1

define void @CSMain() "hlsl.shader"="compute" {
entry:
; RWBuffer<float> UAV : register(4294967294);
%RWB = tail call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0_0t(i32 0, i32 4294967294, i32 1, i32 0, i1 false, ptr nonnull @RWB.str)
ret void
}

!dx.rootsignatures = !{!0}

!0 = !{ptr @CSMain, !1, i32 2}
!1 = !{!2, !3, !5, !7}
!2 = !{!"RootCBV", i32 0, i32 3, i32 666, i32 4}
!3 = !{!"DescriptorTable", i32 1, !4}
!4 = !{!"SRV", i32 1, i32 0, i32 0, i32 -1, i32 4}
!5 = !{!"DescriptorTable", i32 0, !6}
!6 = !{!"Sampler", i32 2, i32 0, i32 0, i32 -1, i32 0}
!7 = !{!"DescriptorTable", i32 0, !8}
!8 = !{!"UAV", i32 10, i32 0, i32 0, i32 -1, i32 2}
Loading