[llvm] [DirectX] Add Resource uses to Resource Handle map in DXILResourceMap (PR #112798)

Zhengxing li via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 09:34:08 PDT 2024


================
@@ -744,6 +750,23 @@ DXILResourceMap::DXILResourceMap(
   }
 }
 
+void DXILResourceMap::updateResourceMap(CallInst *origCallInst,
+                                        CallInst *newCallInst) {
+  assert((origCallInst != nullptr) && (newCallInst != nullptr) &&
+         (origCallInst != newCallInst));
+
+  CallMap.try_emplace(newCallInst, CallMap[origCallInst]);
+  CallMap.erase(origCallInst);
+
+  // Update ResUseToHandleMap since Resource Handle changed
+  for (auto it = origCallInst->users().begin();
+       it != origCallInst->users().end();
+       ++it) {
+    CallInst *CI_Use = dyn_cast<CallInst>(*it);
+    ResUseToHandleMap[CI_Use] = newCallInst;
+  }
----------------
lizhengxing wrote:

Yes, the `origCallInst` key in `CalMap` is useless after it's lowered to dx ops . It will crash in `DXILResourceMap::print` function if keeping it in `CallMap` . 

I'll add more comments here.

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


More information about the llvm-commits mailing list