Here's a new way to handle it. shouldExplore() is handed each value we're going to inspect for the potential that the pointer is leaked. Scan its use-list and see if any users are calls or invokes and add those to the list.<div>

<br></div><div>New patch attached. Please review!</div><div><br></div><div>Nick<br><br><div class="gmail_quote">On 4 October 2012 01:42, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Duncan Sands wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Nick,<br>
<br>
On 04/10/12 06:59, Nick Lewycky wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Tail recursion elimination has to check whether allocas are escaping. It<br>
currently doesn't bother and just assumes that if mem2reg/sroa hasn't<br>
removed<br>
the alloca, then it's an escaping alloca. This patch teaches it to use<br>
CaptureTracking to find calls to functions where the alloca is passed<br>
in through<br>
an argument marked nocapture, and safely ignore those. Those calls can't<br>
themselves be marked tail, but they don't block other calls from being<br>
marked tail.<br>
</blockquote>
<br>
I didn't read very far, but...<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
--- include/llvm/Analysis/<u></u>CaptureTracking.h (revision 165196)<br>
+++ include/llvm/Analysis/<u></u>CaptureTracking.h (working copy)<br>
@@ -46,12 +46,17 @@<br>
/// capture) return false. To search it, return true.<br>
///<br>
/// U->getUser() is always an Instruction.<br>
- virtual bool shouldExplore(Use *U) = 0;<br>
+ virtual bool shouldExplore(Use *U);<br>
<br>
/// captured - Information about the pointer was captured by the user of<br>
/// use U. Return true to stop the traversal or false to continue looking<br>
/// for more capturing instructions.<br>
virtual bool captured(Use *U) = 0;<br>
+<br>
+ /// temporarilyCaptured - Information about the pointer was captured<br>
by the<br>
+ /// user of use U, but only for a known duration, such as the length<br>
of a<br>
+ /// single function call. Return true to stop the traversal.<br>
+ virtual bool temporarilyCaptured(Use *U);<br>
</blockquote>
<br>
this seems way too vaguely defined to me. Is it just for the duration of<br>
a call<br>
or not? And how can you determine that anyway: what if the callee stores<br>
it to<br>
a global?<br>
</blockquote>
<br></div></div>
I agree. How about:<br>
<br>
  /// used - This is a non-capturing use.<br>
  virtual bool used(Use *U);<br>
<br>
If unused, the additional function calls would melt away in any optimized build.<span class="HOEnZb"><font color="#888888"><br>
<br>
Nick</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ciao, Duncan.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
};<br>
<br>
/// PointerMayBeCaptured - Visit the value and the values derived from<br>
it and<br>
</blockquote>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>