<div dir="ltr">Depends where the code instantiate's unique_ptr's dtor - if unique_ptr's dtor is only needed in InlineCost's dtor, then if you make the InlineCost dtor out of line (In the .cpp file) you wouldn't need the extra #includes. We do this in other places across LLVM.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 4, 2016 at 3:27 PM, Easwaran Raman <span dir="ltr"><<a href="mailto:eraman@google.com" target="_blank">eraman@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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?<div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 4, 2016 at 1:41 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Any chance of using unique_ptr instead?</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 3, 2016 at 5:18 PM, Easwaran Raman via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: eraman<br>
Date: Thu Mar  3 19:18:40 2016<br>
New Revision: 262682<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=262682&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=262682&view=rev</a><br>
Log:<br>
Fix a memory leak.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Analysis/InlineCost.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/InlineCost.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=262682&r1=262681&r2=262682&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=262682&r1=262681&r2=262682&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Thu Mar  3 19:18:40 2016<br>
@@ -1600,5 +1600,8 @@ BlockFrequencyInfo *BlockFrequencyAnalys<br>
<br>
 /// \brief Invalidate BlockFrequencyInfo for a function.<br>
 void BlockFrequencyAnalysis::invalidateBlockFrequencyInfo(Function *F) {<br>
-  BFM.erase(F);<br>
+  if (BFM.count(F)) {<br>
+    delete BFM[F];<br>
+    BFM.erase(F);<br>
+  }<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>