On Wed, Apr 10, 2013 at 12:34 PM, Lucian Branescu
<[email protected]> wrote:
> It would be nice if there was an attribute for expressing the wish that a
> function be tail call optimised (like Scala), It's otherwise hard to rely on
> tail calls if they don't work in the general case (and I'm assuming LLVM
> doesn't support general tail calls).
>
>
> On 10 April 2013 17:32, Patrick Walton <[email protected]> wrote:
>>
>> On 4/10/13 5:43 AM, Artella Coding wrote:
>>>
>>> Hi does rust do tail call optimization? The reason I am asking is that
>>> the following tail call recursive implementation results in a stack
>>> overflow. Thanks.
>>
>>
>> Not in the general case. But the WIP patch I have to use the machine
>> return value may allow LLVM to optimize that function into a loop.
>>
>> Patrick
>>
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>
>
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>

LLVM does support tail call optimization, but it requires using a
different calling convention than C and slowing down all function
calls.[1] If Rust was actually using the return value it could do
sibling call optimization (same function signature in the tail call)
in many cases, but destructors will often stop functions from actually
being a tail call.

[1] http://llvm.org/docs/CodeGenerator.html#tail-call-optimization
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to