[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:41:00 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:
We should make this an error instead of an assert. Use a call to `report_fatal_error("message");` The reason you want an error is because this would be an error from outside the SPIR-V backend. There is a misuse of the intrinsic.
https://github.com/llvm/llvm-project/pull/161299
More information about the llvm-commits
mailing list