[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 20:06:50 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;
----------------
XinWang10 wrote:
> 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.
I took a try and find if we use unique_ptr instead and release the unique_ptr when we hand it over to PM, we can not handle it well after PM.add(MMIWP), at line 734 and 737 we still use it.
So I think it's not proper here to use unique_ptr.
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