Automatic program specialization is a well-formed area of computer-science research with many interesting practical applications, but to this day most existing specializers and partial evaluators are only applicable to one of a few high level programming languages. The reason is that developing a specializer for a new language remains still a from-scratch endeavor, and it's hard.
It is the lack of general-purpose flexible program specialization tools that often leads projects to creating custom just-in-time compilers for their specific use cases. These compilers, even if based on mature compiler infrastructures such as LLVM's, immediately become way harder to develop and maintain than simple interpreters they make obsolete. In many cases, however, program specialization could bring the proverbial 80% of the benefits for a fraction of the cost, while maintaining simplicity and testability of the original design.
It is our belief that developing a specializer for a new language should be as easy as adding some supporting syntactic and semantic definitions to a language front-end and reusing an existing specializer in the middle end.
Such a language-independent specializer preferably has to:
We will present the design and the prototype implementation of a multi-stage offline specializer generator that ticks most of these boxes. The generator is based on LLVM and runs in compile time along with the compilation of a source program. It is controlled by intrinsics and function and parameter attributes in LLVM IR. Being developed in the middle-end of the LLVM optimizer, the specializer generator can be used with any language front-end. We will talk about some elements of its design, its limitations, and ways to improve.
Speakers: Eugene Sharygin