LLVM back end

John Meacham john at repetae.net
Fri Dec 22 20:00:42 EST 2006


On Thu, Dec 21, 2006 at 12:54:50AM +0100, Wolfgang Thaller wrote:
> ad c)
> While they are supported in theory, I couldn't get LLVM to generate  
> any tailcalls. Maybe I've done something wrong, maybe they're not  
> really implemented yet.

it seems that ghc could benefit from a tail-call elimination
optimization, that turns them directly into loops. I have implemented it
for jhc and it was not terribly difficult (though, not trivial)

basically, I just refrained from lambda lifting any functions that were
always applied in a fully saturated manner and called in tail-position.
then when spitting out C, I just compile them directly into 'goto's. It
seems to work well and subsumes turning jump-points directly into goto's
rather than function calls as well.

I actually do lambda lifting twice, once right before converting to
grin, where I lambda lift everything that can never be directly jumped
to because it occurs in an unsaturated call or in a lazy context (even
if it is called outside of tail position in a strict context), then I
optimize, then I lambda lift right before conversion to C any that
wern't able to be turned into true jumps. the grin optimizations seem to
be able to expose more tail-calls so make this two pass lambda lifting
worth it.


        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Glasgow-haskell-users mailing list