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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 18:51:11 PDT 2023


craig.topper added inline comments.


================
Comment at: llvm/tools/llc/llc.cpp:702
             << "run-pass is for .mir file only.\n";
+        delete MMIWP;
         return 1;
----------------
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?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147993/new/

https://reviews.llvm.org/D147993



More information about the llvm-commits mailing list