[llvm] r262682 - Fix a memory leak.

Easwaran Raman via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 4 15:27:37 PST 2016


AFAICT, using unique_ptr would require including BlockFrequencyInfo.h and
BlockFrequencyInfoImpl.h in InlineCost.h (instantiation of operator() in
default_delete requires complete type). I thought that since the use
of BlockFrequencyInfo* is fairly isolated within BlockFrequencyAnalysis, it
is probably ok to not use the unique_ptr and avoid these two header file
inclusions. Thoughts?



On Fri, Mar 4, 2016 at 1:41 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Any chance of using unique_ptr instead?
>
> On Thu, Mar 3, 2016 at 5:18 PM, Easwaran Raman via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: eraman
>> Date: Thu Mar  3 19:18:40 2016
>> New Revision: 262682
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262682&view=rev
>> Log:
>> Fix a memory leak.
>>
>> Modified:
>>     llvm/trunk/lib/Analysis/InlineCost.cpp
>>
>> Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=262682&r1=262681&r2=262682&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
>> +++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Mar  3 19:18:40 2016
>> @@ -1600,5 +1600,8 @@ BlockFrequencyInfo *BlockFrequencyAnalys
>>
>>  /// \brief Invalidate BlockFrequencyInfo for a function.
>>  void BlockFrequencyAnalysis::invalidateBlockFrequencyInfo(Function *F) {
>> -  BFM.erase(F);
>> +  if (BFM.count(F)) {
>> +    delete BFM[F];
>> +    BFM.erase(F);
>> +  }
>>  }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160304/55f42191/attachment.html>


More information about the llvm-commits mailing list