Kavya G

Understanding LLVM

What is LLVM?

Compiler Design

Existing models of compilers

  1. The first model is that of Java and .NET VM’s.
    • There is a JIT compiler and a bytecode format.
    • Multiple languages (like Java, Scala, Kotlin … in case of JVM) all compile to the same bytecode and thus use the same JIT.
  2. The second method is to compile to C code and thus make use of years of GCC optimizations.
    • This method might cause problems for exception handling and debugging.
  3. The third method is something like what GCC does.
    • It provides support for multiple front-ends (C/C++/Objective-C/Fortran) and back-ends in the same compiler.
    • Unfortunately, GCC is a giant monolithic piece of code and we cannot use only portions of it.

All three methods are monolithic beasts.

LLVM IR

LLVM

What is Clang and where does it fit in all of this?

What is libclang and how is it useful?

References