1 ============================================= 2 Building a JIT: Per-function Lazy Compilation 3 ============================================= 4 5 .. contents:: 6 :local: 7 8 **This tutorial is under active development. It is incomplete and details may 9 change frequently.** Nonetheless we invite you to try it out as it stands, and 10 we welcome any feedback. 11 12 Chapter 3 Introduction 13 ====================== 14 15 Welcome to Chapter 3 of the "Building an ORC-based JIT in LLVM" tutorial. This 16 chapter discusses lazy JITing and shows you how to enable it by adding an ORC 17 CompileOnDemand layer the JIT from `Chapter 2 <BuildingAJIT2.html>`_. 18 19 **To be done:** 20 21 **(1) Describe lazy function-at-a-time JITing and how it differs from the kind 22 of eager module-at-a-time JITing that we've been doing so far.** 23 24 **(2) Discuss CompileCallbackManagers and IndirectStubManagers.** 25 26 **(3) Describe CompileOnDemandLayer (automates these components and builds stubs 27 and lazy compilation callbacks for IR) and how to add it to the JIT.** 28 29 Full Code Listing 30 ================= 31 32 Here is the complete code listing for our running example with a CompileOnDemand 33 layer added to enable lazy function-at-a-time compilation. To build this example, use: 34 35 .. code-block:: bash 36 37 # Compile 38 clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orc native` -O3 -o toy 39 # Run 40 ./toy 41 42 Here is the code: 43 44 .. literalinclude:: ../../examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h 45 :language: c++ 46 47 `Next: Extreme Laziness -- Using Compile Callbacks to JIT directly from ASTs <BuildingAJIT4.html>`_ 48