Compiling with Continuations and LLVM

@article{Farvardin2016CompilingWC,
  title={Compiling with Continuations and LLVM},
  author={Kavon Farvardin and John H. Reppy},
  journal={CoRR},
  year={2016},
  volume={abs/1805.08842},
  pages={131-142}
}
LLVM is an infrastructure for code generation and low-level optimizations, which has been gaining popularity as a backend for both research and industrial compilers, including many compilers for functional languages. While LLVM provides a relatively easy path to high-quality native code, its design is based on a traditional runtime model which is not well suited to alternative compilation strategies used in high-level language compilers, such as the use of heap-allocated continuation closures… 

Figures from this paper

A New Backend for Standard ML of New Jersey
TLDR
The design and implementation of a new backend for the Standard ML of New Jersey (SML/NJ) system that is based on the LLVM compiler infrastructure is described, which poses challenges to building a backend using LLVM.
From folklore to fact: comparing implementations of stacks and continuations
TLDR
An ``apples-to-apples'' comparison of six different approaches to implementing call stacks and continuations, with the only differences being those required by the differences in implementation strategy.

References

SHOWING 1-10 OF 31 REFERENCES
LLVM: a compilation framework for lifelong program analysis & transformation
  • Chris Lattner, V. Adve
  • Computer Science
    International Symposium on Code Generation and Optimization, 2004. CGO 2004.
  • 2004
TLDR
The design of the LLVM representation and compiler framework is evaluated in three ways: the size and effectiveness of the representation, including the type information it provides; compiler performance for several interprocedural problems; and illustrative examples of the benefits LLVM provides for several challenging compiler problems.
LLVM: AN INFRASTRUCTURE FOR MULTI-STAGE OPTIMIZATION
TLDR
The LLVM compiler infrastructure is a maturing and efficient system, which is a good host for a variety of research and is designed to support optimization in the field, both at run-time and during otherwise unused idle time on the machine.
No assembly required: compiling standard ML to C
TLDR
This work shows how to compile Standard ML to C without compromising on portability and proper tail recursion, and analyzes the performance and determines the aspects of the compilation method that lead to the observed slowdown.
Compiler support for lightweight context switching
TLDR
It is argued that compiler-supported lightweight context switching can be significantly faster than using a library to switch between contexts, and provided experimental evidence to support the position.
Compiling with Continuations
TLDR
This book shows how continuation-passing style is used as an intermediate representation to perform optimizations and program transformations to create practical optimizing compilers for modern languages like ML.
An llVM backend for GHC
TLDR
A new backend for the Glasgow Haskell Compiler is explored that leverages the Low Level Virtual Machine (LLVM), a new breed of compiler written explicitly for use by other compiler writers, not high-level programmers, that promises to enable outsourcing of low-level and architecture-dependent aspects of code generation.
Practical and effective higher-order optimizations
TLDR
This paper provides the first practical and effective technique for superΒ (higher-order) inlining and copy propagation, which it is shown that this technique is practical by implementing it in the context of a real compiler for an ML-family language and showing that the required analyses have costs below 3% of the total compilation time.
Arity Raising in Manticore
TLDR
This work presents a novel strategy that uses both control-flow and type information to provide an arity raising implementation addressing the challenges of optimizing the boxing of raw values, flattening of argument tuples, and raising the arity of functions that handle complex structures to reduce memory usage.
C--: A Portable Assembly Language that Supports Garbage Collection
TLDR
This paper addresses the problems in the support of such high-level run-time services as garbage collection, exception handling, concurrency, profiling, and debugging in the use of a portable assembly language by combining the C-— language with a C--— run- time interface.
A Portable and Optimizing Back End for the SML/NJ Compiler
TLDR
It is argued that porting the compiler to a new architecture requires substantially less effort than the existing abstract machine approach, and significant gains from preliminary architecture description driven optimizations are reported.
...
...