[llvm] [DXIL][Analysis] Uniquify duplicate resources in DXILResourceAnalysis (PR #105602)
Damyan Pepper via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 18:24:43 PDT 2024
================
@@ -216,15 +240,88 @@ class ResourceInfo {
MDTuple *getAsMetadata(LLVMContext &Ctx) const;
- ResourceBinding getBinding() const { return Binding; }
std::pair<uint32_t, uint32_t> getAnnotateProps() const;
void print(raw_ostream &OS) const;
};
} // namespace dxil
-using DXILResourceMap = MapVector<CallInst *, dxil::ResourceInfo>;
+class DXILResourceMap {
+ SmallVector<dxil::ResourceInfo> Resources;
+ DenseMap<CallInst *, unsigned> CallMap;
+ unsigned FirstUAV = 0;
+ unsigned FirstCBuffer = 0;
+ unsigned FirstSampler = 0;
+
+public:
+ using iterator = SmallVector<dxil::ResourceInfo>::iterator;
+ using const_iterator = SmallVector<dxil::ResourceInfo>::const_iterator;
+
+ DXILResourceMap(
+ SmallVectorImpl<std::pair<CallInst *, dxil::ResourceInfo>> &&CIToRI);
+
+ iterator begin() { return Resources.begin(); }
+ const_iterator begin() const { return Resources.begin(); }
+ iterator end() { return Resources.end(); }
+ const_iterator end() const { return Resources.end(); }
+
+ bool empty() const { return Resources.empty(); }
+
+ iterator find(const CallInst *Key) {
+ auto Pos = CallMap.find(Key);
+ return Pos == CallMap.end() ? Resources.end()
+ : (Resources.begin() + Pos->second);
+ }
+
+ const_iterator find(const CallInst *Key) const {
+ auto Pos = CallMap.find(Key);
+ return Pos == CallMap.end() ? Resources.end()
+ : (Resources.begin() + Pos->second);
+ }
+
+ iterator srv_begin() { return begin(); }
----------------
damyanp wrote:
We'd normally encourage this to come in with tests that exercise it, wouldn't we?
https://github.com/llvm/llvm-project/pull/105602
More information about the llvm-commits
mailing list