[llvm] [AMDGPU] Fix a potential use-after-erase in `AMDGPUPromoteAlloca` pass (PR #174529)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 7 04:25:17 PST 2026


================
@@ -1166,9 +1166,18 @@ void AMDGPUPromoteAllocaImpl::promoteAllocaToVector(AllocaAnalysis &AA) {
   });
 
   // Now fixup the placeholders.
+  DenseMap<Value *, Value *> PlaceholderMap;
   for (Instruction *Placeholder : Placeholders) {
-    Placeholder->replaceAllUsesWith(
-        Updater.GetValueInMiddleOfBlock(Placeholder->getParent()));
+    Value *NewVal = Updater.GetValueInMiddleOfBlock(Placeholder->getParent());
+    Placeholder->replaceAllUsesWith(NewVal);
----------------
arsenm wrote:

I mean, do you avoid this issue if this stops using SSAUpdater, and instead uses SSAUpdaterBulk 

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


More information about the llvm-commits mailing list