[llvm] [HLSL] Analyze update counter usage (PR #130356)

Ashley Coleman via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 25 09:01:10 PDT 2025


================
@@ -574,6 +577,80 @@ class DXILResourceBindingWrapperPass : public ModulePass {
 
 ModulePass *createDXILResourceBindingWrapperPassPass();
 
+enum class ResourceCounterDirection {
+  Increment,
+  Decrement,
+  Unknown,
+  Invalid,
+};
+
+class DXILResourceCounterDirectionMap {
+  std::vector<std::pair<dxil::ResourceBindingInfo, ResourceCounterDirection>>
+      CounterDirections;
+
+public:
+  void populate(Module &M, DXILBindingMap &DBM);
+
+  ResourceCounterDirection
+  operator[](const dxil::ResourceBindingInfo &Info) const {
+    auto Lower = llvm::lower_bound(
+        CounterDirections, Info,
+        [](const auto &LHS, const auto &RHS) { return LHS.first < RHS; });
+
+    if (Lower == CounterDirections.end()) {
+      return ResourceCounterDirection::Unknown;
+    }
+
+    if (Lower->first != Info) {
+      return ResourceCounterDirection::Unknown;
+    }
----------------
V-FEXrt wrote:

lol I swear one day I'll get this bashed into my head. I notice it on reviews but when I'm writing code the muscle memory takes over

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


More information about the llvm-commits mailing list