[clang] [llvm] [DirectX] Validate registers are bound to root signature (PR #146785)

Finn Plummer via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 17 11:05:12 PDT 2025


================
@@ -136,6 +136,51 @@ struct OverlappingRanges {
 llvm::SmallVector<OverlappingRanges>
 findOverlappingRanges(llvm::SmallVector<RangeInfo> &Infos);
 
+class RootSignatureBindingValidation {
+private:
+  llvm::SmallVector<RangeInfo, 16> Bindings;
+  struct TypeRange {
+    uint32_t Start;
+    uint32_t End;
+  };
+  std::unordered_map<dxil::ResourceClass, TypeRange> Ranges;
----------------
inbelic wrote:

I still think we can simplify this logic as denote [here](https://github.com/llvm/llvm-project/pull/146785#discussion_r2205797483):

> I think we could implement this much simpler with something like:
> 
> ```
> using TypedBinding = std::pair<Type, ResourceBinding>;
> llvm::SmallVector<TypedBinding> Bindings;
> ```
> 
> and then below, instead of `Range.find` we do a `llvm::lower_bound(Bindings, ...)` with respect to the type. So that `Bindings` will be grouped together by type.
> 
> Or `addBinding` just becomes a `push_back` and then we do `llvm::sort` by group before returning them in `getBindingsOfType`
> 
> Then `getBindingsOfType` can take advantage of the sorted nature to return it. I don't think there would be any harm in returning an array ref of `TypedBinding` either.

https://github.com/llvm/llvm-project/pull/146785


More information about the cfe-commits mailing list