[llvm] [SPIR-V] Prevent adding duplicate binding instructions for implicit binding (PR #161299)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 1 07:40:59 PDT 2025
================
@@ -92,6 +92,32 @@ void SPIRVLegalizeImplicitBinding::collectBindingInfo(Module &M) {
cast<ConstantInt>(B->getArgOperand(OrderIdArgIdx))->getZExtValue();
return OrderA < OrderB;
});
+
+ // Check that the order Id is unique per resource.
+ for (uint32_t i = 1; i < ImplicitBindingCalls.size(); ++i) {
+ const uint32_t OrderIdArgIdx = 0;
+ const uint32_t DescSetArgIdx = 1;
+ const uint32_t OrderA =
+ cast<ConstantInt>(
+ ImplicitBindingCalls[i - 1]->getArgOperand(OrderIdArgIdx))
+ ->getZExtValue();
+ const uint32_t OrderB =
+ cast<ConstantInt>(ImplicitBindingCalls[i]->getArgOperand(OrderIdArgIdx))
+ ->getZExtValue();
+ if (OrderA == OrderB) {
+ const uint32_t DescSetA =
+ cast<ConstantInt>(
+ ImplicitBindingCalls[i - 1]->getArgOperand(DescSetArgIdx))
+ ->getZExtValue();
+ const uint32_t DescSetB =
+ cast<ConstantInt>(
+ ImplicitBindingCalls[i]->getArgOperand(DescSetArgIdx))
+ ->getZExtValue();
+ assert(DescSetA == DescSetB &&
+ "If two implicit binding calls have the same order ID, they must "
+ "also have the same descriptor set.");
+ }
+ }
----------------
s-perron wrote:
I think all of this should be moved out into it own function. `verifyUniqueOrderIdPerResource(ImplicitBindingCalls)`.
https://github.com/llvm/llvm-project/pull/161299
More information about the llvm-commits
mailing list