[llvm] [DirectX] Fix resource binding analysis incorrectly removing duplicates (PR #152253)

Ashley Coleman via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 10:59:09 PDT 2025


================
@@ -273,3 +273,21 @@ TEST(HLSLBindingTest, TestFindAvailable) {
   // In an empty space we find the slot at the beginning.
   EXPECT_THAT(V, HasSpecificValue(0u));
 }
+
+// Test that add duplicate bindings are correctly de-duplicated
+TEST(HLSLBindingTest, TestNoOverlapWithDuplicates) {
+  hlsl::BindingInfoBuilder Builder;
+
+  // We add the same binding three times, and just use `nullptr` for the cookie
+  // so that they should all be uniqued away.
+  Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
+                       /*UpperBound=*/5, /*Cookie=*/nullptr);
+  Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
+                       /*UpperBound=*/5, /*Cookie=*/nullptr);
+  Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
+                       /*UpperBound=*/5, /*Cookie=*/nullptr);
+  bool HasOverlap;
+  hlsl::BindingInfo Info = Builder.calculateBindingInfo(HasOverlap);
----------------
V-FEXrt wrote:

nit: if it's an easy change can we also assert that there is only one binding?

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


More information about the llvm-commits mailing list