Hoopl vs LLVM?

Simon Peyton-Jones simonpj at microsoft.com
Thu Dec 13 10:13:08 CET 2012

| > My question was more: why do we CPS transform? I guess it's because we
| > manage our own stack?
| Right.  In fact, LLVM does its own CPS transform (but doesn't call it
| that) when the code contains non-tail function calls.  We give LLVM code
| with tail-calls only.
| The choice about whether to manage our own stack is *very* deep, and has
| ramifications all over the system.  Changing it would mean a completely
| new backend and replacing a lot of the RTS, that is if you could find a
| good scheme for tracking pointers in the stack - I'm not sure LLVM is up
| to the job without more work.  It could probably be done, but it's a
| huge undertaking and it's not at all clear that you could do any better
| than GHC currently does.  We generate very good code from idiomatic
| Haskell; where we fall down is in heavy numerical and loopy code, where
| LLVM does a much better job.

Right on the money.

Incidentally, for the heavy numerical work, the inner loops that GHC generates often don't have calls or allocations, and so they DO get through to LLVM which CAN optimise them.  That's why DPH and vector programs benefit particularly from LLVM.


More information about the Glasgow-haskell-users mailing list