[llvm-branch-commits] [llvm] [SPIRV] Refactor implicit binding legalization (PR #221662)

Deric C. via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 10 11:57:42 PDT 2026


================
@@ -182,43 +139,121 @@ uint32_t SPIRVLegalizeImplicitBindingImpl::getAndReserveFirstUnusedBinding(
   return NewBinding;
 }
 
-void SPIRVLegalizeImplicitBindingImpl::replaceImplicitBindingCalls(Module &M) {
-  uint32_t lastOrderId = -1;
-  uint32_t lastBindingNumber = -1;
+// Replace the implicit binding call with a new call using explicit binding.
+static void replaceWithHandleFromBinding(Module &M, CallInst *CI,
+                                         uint32_t DescSet, uint32_t Binding,
+                                         Value *IndexOp, Value *RangeOp,
+                                         Value *Name) {
+  IRBuilder<> Builder(CI);
----------------
Icohedron wrote:

[SUGGESTION] Start this function with an assert on `CI` just like `replaceWithCounterHandleFromBinding` does?
```suggestion
  assert(CI->getIntrinsicID() ==
             Intrinsic::spv_resource_handlefrombinding &&
         "unexpected implicit binding intrinsic");
  IRBuilder<> Builder(CI);
```

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


More information about the llvm-branch-commits mailing list