[LLVMdev] Tail Call Optimisation
Jeffrey Yasskin
jyasskin at google.com
Sun Jan 3 21:16:40 PST 2010
On Sun, Jan 3, 2010 at 10:50 PM, Jon Harrop <jon at ffconsultancy.com> wrote:
> On Monday 04 January 2010 03:33:06 Simon Harris wrote:
>> On 04/01/2010, at 3:01 PM, Jon Harrop wrote:
>> > I am certainly interested in tail calls because my HLVM project relies
>> > upon LLVM's tail call elimination. However, I do not understand what tail
>> > calls LLVM is not currently eliminating that you plan to eliminate?
>>
>> Mutual recursion for a start:
>>
>> def a(n)
>> n <= 0 ? "DONE" : b(n - 1)
>> end
>>
>> def b(n)
>> n <= 0 ? "DONE" : a(n - 1)
>> end
>>
>> a(10000000)
>>
>> Boom!
>
> LLVM's TCO already handles mutual recursion.
Only for fastcc functions compiled with -tailcallopt, right?
http://llvm.org/docs/CodeGenerator.html#tailcallopt
I believe gcc manages to support tail calls in many more cases, and
this restriction in llvm confuses lots of newcomers. It would be very
worthwhile if someone wanted to remove it.
More information about the llvm-dev
mailing list