[llvm] [SPIR-V] Prevent adding duplicate binding instructions for implicit binding (PR #161299)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 30 06:48:13 PDT 2025


================
@@ -112,11 +112,22 @@ uint32_t SPIRVLegalizeImplicitBinding::getAndReserveFirstUnusedBinding(
 }
 
 void SPIRVLegalizeImplicitBinding::replaceImplicitBindingCalls(Module &M) {
+  std::unordered_map<uint32_t, uint32_t> OrderIdToBinding;
----------------
s-perron wrote:

I don't think we need the hash table. The ImplicitBindingCalls should be sorted by the order id. You should have to only keep track of the last binding that you used.

Also, `std::unordered_map` is generally not used. In this case, where the orderIDs are dense, https://llvm.org/doxygen/classllvm_1_1DenseMap.html is probably the best option.

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


More information about the llvm-commits mailing list