[llvm] [NFC][DirectX] Fix a memory leak in resource access (PR #220350)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 13:51:56 PDT 2026


================
@@ -842,29 +842,26 @@ getAccessIndices(Instruction *I, SmallSetVector<Instruction *, 16> &DeadInsts,
         GetPtrPhi->addIncoming(AccessIdx.GetPtrIdx, BB);
       HandlePhi->addIncoming(AccessIdx.HandleIdx, BB);
     }
-
-    if (HasGetPtr)
-      Builder.Insert(GetPtrPhi);
-    else
-      GetPtrPhi = nullptr;
-
-    Builder.Insert(HandlePhi);
-
     DeadInsts.insert(Phi);
 
     Value *GetPtrIdx = GetPtrPhi;
-    Value *HandleIdx = HandlePhi;
-
-    if (GetPtrPhi)
+    if (HasGetPtr) {
----------------
bogner wrote:

I was thinking that it'd simplify things to put the hasConstantValue related logic in the helper, but you're right  - just using unique_ptr here is better.

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


More information about the llvm-commits mailing list