1. 6

Abstract: “While LLVM addresses the problem of maintaining native code generators and is a better portable assembly language than C code, it still suffers from a bias toward C runtime conventions, which makes it a less than ideal target for a functional-language compiler. Functional language implementations often use specialized register and calling conventions, and require guaranteed tail-call optimization, mechanisms to communicate with the garbage collector, and efficient support for features like first-class continuations.

In this paper, we present our approach to solving the problems of using LLVM as a backend for functional language implementations. In particular, we show how to use LLVM to support the heap-allocated first-class continuation runtime model used by the SML/NJ system and by the Manticore system. We have integrated our approach into the Parallel ML (PML) compiler that is part of the Manticore project. Initial observations suggest that the LLVM backend produces more efficient code relative to the previous MLRisc backend. The LLVM backends for Haskell (GHC) and Erlang (ErLLVM) use special language-specific calling conventions added to LLVM that support TCO. The LLVM backend for the MLton SML compiler uses trampolining to avoid the issues with TCO. As far as we know, no one has successfully implemented first-class continuations with LLVM. In the remainder of the paper, we describe a new calling convention that we have added to LLVM, how we handle the GC interface, and how we support capturing continuations to support preemption. Many details are omitted because of space limits, but can be found in an upcoming technical report.”

  1.