[llvm-commits] PATCH: stronger tail recursion elimination with nocapture
Duncan Sands
baldrick at free.fr
Thu Oct 4 00:26:50 PDT 2012
Hi Nick,
On 04/10/12 06:59, Nick Lewycky wrote:
> Tail recursion elimination has to check whether allocas are escaping. It
> currently doesn't bother and just assumes that if mem2reg/sroa hasn't removed
> the alloca, then it's an escaping alloca. This patch teaches it to use
> CaptureTracking to find calls to functions where the alloca is passed in through
> an argument marked nocapture, and safely ignore those. Those calls can't
> themselves be marked tail, but they don't block other calls from being marked tail.
I didn't read very far, but...
> --- include/llvm/Analysis/CaptureTracking.h (revision 165196)
> +++ include/llvm/Analysis/CaptureTracking.h (working copy)
> @@ -46,12 +46,17 @@
> /// capture) return false. To search it, return true.
> ///
> /// U->getUser() is always an Instruction.
> - virtual bool shouldExplore(Use *U) = 0;
> + virtual bool shouldExplore(Use *U);
>
> /// captured - Information about the pointer was captured by the user of
> /// use U. Return true to stop the traversal or false to continue looking
> /// for more capturing instructions.
> virtual bool captured(Use *U) = 0;
> +
> + /// temporarilyCaptured - Information about the pointer was captured by the
> + /// user of use U, but only for a known duration, such as the length of a
> + /// single function call. Return true to stop the traversal.
> + virtual bool temporarilyCaptured(Use *U);
this seems way too vaguely defined to me. Is it just for the duration of a call
or not? And how can you determine that anyway: what if the callee stores it to
a global?
Ciao, Duncan.
> };
>
> /// PointerMayBeCaptured - Visit the value and the values derived from it and
More information about the llvm-commits
mailing list