[llvm] [AMDGPU] Fix `AMDGPUPromoteAlloca` handling certain loads incorrectly (PR #123173)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 01:44:48 PST 2025


================
@@ -397,6 +397,14 @@ calculateVectorIndex(Value *Ptr,
   return I->second;
 }
 
+static void updateVectorIndex(Value *OldIdx, Value *NewIdx,
+                              std::map<GetElementPtrInst *, Value *> &GEPIdx) {
+  for (auto &[GEP, Idx] : GEPIdx) {
+    if (Idx == OldIdx)
+      GEPIdx[GEP] = NewIdx;
----------------
arsenm wrote:

Can't you just replace the value in the map? Why do you need the loop?

Also, will this be fixed by using WeakVH in https://github.com/llvm/llvm-project/pull/122342#pullrequestreview-2541436255

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


More information about the llvm-commits mailing list