[llvm] [DirectX] Add Resource uses to Resource Handle map in DXILResourceMap (PR #112798)
Helena Kotas via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 21:49:29 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;
+ }
----------------
hekota wrote:
This is a bit confusing. You are removing `origCallInst` from `CallMap`, and then iterating over its uses and remapping them the `newCallInst`. Are you doing it this way because after `replaceAllUsesWith` the `newCallInst` uses will be the temporary handle casts? It might be worth adding an explaining comment. And maybe an assert checking that `newCallInst` does nor not have any uses yet when `updateResourceMap` is called.
https://github.com/llvm/llvm-project/pull/112798
More information about the llvm-commits
mailing list