<div dir="ltr">consider using an non-static data member initializer rather than the ctor init list? </div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 3, 2016 at 4:44 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 18:44:01 2016<br>
New Revision: 262679<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=262679&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=262679&view=rev</a><br>
Log:<br>
Fix a use-after-free bug introduced in r262636<br>
<br>
<br>
Modified:<br>
  Â  llvm/trunk/include/llvm/Transforms/Utils/Cloning.h<br>
  Â  llvm/trunk/lib/Transforms/IPO/Inliner.cpp<br>
  Â  llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Transforms/Utils/Cloning.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=262679&r1=262678&r2=262679&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=262679&r1=262678&r2=262679&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Transforms/Utils/Cloning.h (original)<br>
+++ llvm/trunk/include/llvm/Transforms/Utils/Cloning.h Thu Mar  3 18:44:01 2016<br>
@@ -189,7 +189,7 @@ public:<br>
  Â explicit InlineFunctionInfo(CallGraph *cg = nullptr,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â AssumptionCacheTracker *ACT = nullptr,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â BlockCloningFunctor Ftor = nullptr)<br>
-  Â  Â  : CG(cg), ACT(ACT), Ftor(Ftor) {}<br>
+  Â  Â  : CG(cg), ACT(ACT), Ftor(Ftor), CallSuccessorBlockDeleted(false) {}<br>
<br>
  Â /// CG - If non-null, InlineFunction will update the callgraph to reflect the<br>
  Â /// changes it makes.<br>
@@ -198,6 +198,10 @@ public:<br>
  Â // Functor that is invoked when a block is cloned into the new function.<br>
  Â BlockCloningFunctor Ftor;<br>
<br>
+  /// CallSuccessorBlockDeleted - whether the block immediately following the<br>
+  /// call has been deleted during inlining<br>
+  bool CallSuccessorBlockDeleted;<br>
+<br>
  Â /// StaticAllocas - InlineFunction fills this in with all static allocas that<br>
  Â /// get copied into the caller.<br>
  Â SmallVector<AllocaInst *, 4> StaticAllocas;<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=262679&r1=262678&r2=262679&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=262679&r1=262678&r2=262679&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Thu Mar  3 18:44:01 2016<br>
@@ -580,11 +580,13 @@ bool Inliner::runOnSCC(CallGraphSCC &SCC<br>
  Â  Â  Â  Â  Â continue;<br>
  Â  Â  Â  Â }<br>
  Â  Â  Â  Â updateEntryCount(CallSiteBlock, Callee);<br>
-  Â  Â  Â  // The instruction following the call is part of a new basic block<br>
-  Â  Â  Â  // created during the inlining process. This does not have an entry in<br>
-  Â  Â  Â  // the BFI. We create an entry by copying the frequency of the original<br>
-  Â  Â  Â  // block containing the call.<br>
-  Â  Â  Â  copyBlockFrequency(CallSiteBlock, CallSuccessor->getParent());<br>
+  Â  Â  Â  if (!InlineInfo.CallSuccessorBlockDeleted) {<br>
+  Â  Â  Â  Â  // The instruction following the call is part of a new basic block<br>
+  Â  Â  Â  Â  // created during the inlining process. This does not have an entry in<br>
+  Â  Â  Â  Â  // the BFI. We create an entry by copying the frequency of the<br>
+  Â  Â  Â  Â  // original block containing the call.<br>
+  Â  Â  Â  Â  copyBlockFrequency(CallSiteBlock, CallSuccessor->getParent());<br>
+  Â  Â  Â  }<br>
<br>
  Â  Â  Â  Â ++NumInlined;<br>
<br>
<br>
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=262679&r1=262678&r2=262679&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=262679&r1=262678&r2=262679&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Thu Mar  3 18:44:01 2016<br>
@@ -1994,8 +1994,11 @@ bool llvm::InlineFunction(CallSite CS, I<br>
<br>
  Â // If we inlined any musttail calls and the original return is now<br>
  Â // unreachable, delete it.  It can only contain a bitcast and ret.<br>
-  if (InlinedMustTailCalls && pred_begin(AfterCallBB) == pred_end(AfterCallBB))<br>
+  if (InlinedMustTailCalls &&<br>
+  Â  Â  pred_begin(AfterCallBB) == pred_end(AfterCallBB)) {<br>
+  Â  IFI.CallSuccessorBlockDeleted = true;<br>
  Â  Â AfterCallBB->eraseFromParent();<br>
+  }<br>
<br>
  Â // We should always be able to fold the entry block of the function into the<br>
  Â // single predecessor of the block...<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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>