[PATCH] D147993: Add delete to fix resource leak in llc.cpp

Wang, Xin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 19:26:00 PDT 2023

XinWang10 added inline comments.

Comment at: llvm/tools/llc/llc.cpp:702
             << "run-pass is for .mir file only.\n";
+        delete MMIWP;
         return 1;
craig.topper wrote:
> XinWang10 wrote:
> > craig.topper wrote:
> > > Why is it only a leak on these paths? The are other `return 1` in this function.
> > > 
> > > Can we use std::unique_ptr where these are created?
> > 1. MMIWP and TPC will be maintained by PM here at line 717, 718. I remember that PM's destructor will handle them.
> > 2. MMIWP and TPC will be used as parameters for function like PM.add or arget->addPassesToEmitFile() in line 727, if we use unique_ptr, we need to handle more complicated issues.
> Can we release the unique_ptr when we hand it over to PM?
Yes we can. If it its preferred, will take a try.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list