[llvm] [SPIR-V]: Memory leak fix in SPIRVEmitIntrinsics (PR #83015)

Michal Paszkowski via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 11:15:28 PST 2024


================
@@ -660,33 +669,34 @@ bool SPIRVEmitIntrinsics::runOnFunction(Function &Func) {
       AggrStores.insert(&I);
   }
 
-  IRB->SetInsertPoint(&Func.getEntryBlock(), Func.getEntryBlock().begin());
+  B.SetInsertPoint(&Func.getEntryBlock(), Func.getEntryBlock().begin());
   for (auto &GV : Func.getParent()->globals())
-    processGlobalValue(GV);
+    processGlobalValue(GV, B);
 
-  preprocessUndefs();
-  preprocessCompositeConstants();
+  preprocessUndefs(B);
+  preprocessCompositeConstants(B);
   SmallVector<Instruction *> Worklist;
   for (auto &I : instructions(Func))
     Worklist.push_back(&I);
 
   for (auto &I : Worklist) {
-    insertAssignPtrTypeIntrs(I);
-    insertAssignTypeIntrs(I);
-    insertPtrCastInstr(I);
+    insertAssignPtrTypeIntrs(I, B);
+    insertAssignTypeIntrs(I, B);
+    insertPtrCastInstr(I, B);
   }
-
+  this->IRB = &B;
----------------
michalpaszkowski wrote:

Thank you for elaborating and looking into this carefully! I agree, this might be a better approach from the readability standpoint.

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


More information about the llvm-commits mailing list