Compiling Racket to LLVM

I found myself in a conversation today with Adam Perlin about compiling racket to LLVM, and I found myself wondering why there was no LLVM back-end for Racket[*]. After thinking about it for a while, I decided that the most likely reason was that with the pb back-end, compiling to LLVM (and then to some other target) probably isn't much of a win, or maybe even a win at all. Does that sound reasonable, or am I missing something obvious?



[*] Er... that I'm aware of?

  1. I don't think pb and compiling to LLVM are that related. pb is a bytecode with an interpreter, LLVM does not run via a portable interpreter.
  2. The reason not to compile via LLVM is that it's hard, particularly for a GC'ed language with a non-trivial VM. It's possible to make it work but definitely non-trivial.
  3. There was an effort by Eli Barzilay and Alex Friedman to write an LLVM backend for Racket in 2006; you can read more about it here: Racket: [plt-scheme] llvm and all that
1 Like

When I looked at LLVM a few years ago, there were three things it did not understand:

  • Garbage collection
  • That sometimes you want to add an integer to a pointer and NOT HAVE IT SCALED!
  • That it makes sense to access and use the fields of a structure before the definition of the structure is complete.

-- hendrik

This may be relevant: [2005.09028] Sham: A DSL for Fast DSLs. Excerpt: