LLVM
Online Resources
Documentation, Tutorials
- LLVM Docs
- LLVM Discourse
- Awesome LLVM
- 2011/05/26 ⚠️ The Architecture of Open Source Applications: LLVM
- 2011/10/14 Stack Overflow: Is it possible to use LLVM-assembly directly?
- 2012/02/05 Stack Overflow: How to make clang compile to llvm IR
- 2013/07/24 IR is better than assembly
- 2015/09/08 ⚠️ XRay the LLVM/Clang source code
- 2016/02/15 How To Write An LLVM Register Allocator
- 2016/10/25 ⚠️ Mapping High Level Constructs to LLVM IR
- 2016/11/10 LLVM Optimizations
- 2019/10/01 Combining GNAT with LLVM
- 2020/01/19 Gandiva, using LLVM and Arrow to JIT and evaluate Pandas expressions
- 2020/05/10 Make LLVM fast again
- 2020/09/28 Zig's New Relationship with LLVM
- 2020/12/24 ⚠️ A Complete Guide to LLVM for Programming Language Creators
- 2021/04/13 Reducing code size with LLVM Machine Outliner on 32-bit Arm targets
- 2021/05/20 Building LLVM in 90 seconds using Amazon Lambda L.rs
- 2021/06/02 ⚠️ Design issues in LLVM IR
- 2021/06/11 Can memcpy be implemented in LLVM IR? L.rs
- 2021/07/16 ⚠️ A Journey to understand LLVM IR
- 2021/08/09 Intel C/C++ compilers complete adoption of LLVM
- 2021/08/13 Exploring Clang/LLVM optimization on programming horror
- 2021/09/06 ⚠️ Learning Almost Nothing About LLVM
- 2021/11/04 ⚠️ How to Learn Compilers: LLVM Edition
- 2021/18/04 [llvm-dev] Inline function not eventually inlined is removed
- 2022/09/21 What's new for RISC-V in LLVM 15
- 2022/11/17 Compiling Containers - Dockerfiles, LLVM, and BuildKit
- 2023/01/09 ⚠️ Mapping Python to LLVM
- LLVM Blog
- John Regehr
- 2017/01/07 ⚠️ A Tourist’s Guide to the LLVM Source Code
- 2017/04/15 Taming Undefined Behavior in LLVM
- Eli Bendersky
- William Woodruff
- 2020/09/19 LLVM's getelementptr, by example
- 2020/10/23 ⚠️ Understanding static single assignment forms
- 2021/07/19 ⚠️ LLVM internals, part 1: the bitcode format
- 2021/08/10 ⚠️ LLVM internals, part 2: parsing the bitstream
- 2021/09/14 ⚠️ LLVM internals, part 3: from bitcode to IR
- 2021/11/29 ⚠️ LLVM internals, part 4: attributes and attribute groups
- 2022/04/30 ⚠️ LLVM internals, part 5: a very brief update
- Harlan Haskins
- Phil Eaton
- Github - eatonphil/ulisp: A compiler for a lisp-like language targeting LLVM IR, x86 assembly
- 2018/11/20 Writing a lisp compiler from scratch in JavaScript: 1. lisp to assembly
- 2019/01/20 Writing a lisp compiler from scratch in JavaScript: 2. user-defined functions and variables
- 2019/03/10 Writing a lisp compiler from scratch in JavaScript: 3. LLVM
- 2019/05/04 Writing a lisp compiler from scratch in JavaScript: 4. LLVM conditionals and compiling fibonacci
- 2019/06/22 Writing a lisp compiler from scratch in JavaScript: 5. LLVM system calls
- 2019/12/08 Writing a lisp compiler from scratch in JavaScript: 6. an x86 upgrade
MLIR
- Lei Zhang
- 2021/09/19 CodeGen Performant Convolution Kernels for Mobile GPUs
- 2022/01/08 Compilers and IRs: LLVM IR, SPIR-V, and MLIR
- 2022/02/20 MLIR CodeGen Dialects for Machine Learning Compilers
- 2022/07/21 MLIR Vector Dialect and Patterns
- 2022/08/31 MLIR Linalg Dialect and Patterns
- LLVM/MLIR Toy Language Tutorial
- How to build a compiler with LLVM and MLIR
Youtube
- LLVM in 100 Seconds
- LVVM Project Youtube Channel
- Tim Morgan
- Compilers Lab
- 2019/04/28 2019 EuroLLVM Developers’ Meeting: “LLVM IR Tutorial - Phis, GEPs, and other things”
- 2021/08/16 Modular, Compositional, and Executable Formal Semantics for LLVM IR
- 2021/12/13 Nick Baron - Reading LLVM IR
- 2021/12/13 Making LLVM IR
- 2021/12/02 Tutorial: LLVM for Security Practitioners
- 2022/06/18 Rust versus DWARF versus LLVM
Applications
- GitHub - ark-lang/ark: A compiled systems programming language written in Go using the LLVM framework
- Github - banach-space/llvm-tutor: A collection of out-of-tree LLVM passes for teaching and learning
- GitHub - brain-labs/brain: An esoteric programming language compiler on top of LLVM based on Brainfuck
- Github - dibyendumajumdar/dmr_c: dmr_C is a C parser and JIT compiler with LLVM, Eclipse OMR and NanoJIT backends
- GitHub - froggey/Iota: LLVM to Common Lisp transpiler.
- Github - G3orge26/llvm-memlog-pass: A complete guide to writing an LLVM Pass
- Github - google/llvm-propeller: PROPELLER: Profile Guided Optimizing Large Scale LLVM-based Relinker
- GitHub - igor84/summus: Simple compiler frontend using LLVM as backend
- Designing ParaSail, a new programming language: Compiling ParaSail to LLVM, first in a series...
- ErLLVM
Clang Analyzer
Polly
Bindings
Rust
Books
LLVM Essentials
- Table of Contents
- 1 Playing with LLVM
- Modular design and collection of libraries
- Getting familiar with LLVM IR
- LLVM tools and using them in the command line
- 2 Building LLVM IR
- Creating an LLVM module
- Emitting a function in a module
- Adding a block to a function
- Emitting a global variable
- Emitting a return statement
- Emitting function arguments
- Emitting a simple arithmetic statement in a basic block
- Emitting if-else condition IR
- Emitting LLVM IR for loop
- 3 Advanced LLVM IR
- Memory access violations
- Getting the address of an element
- Reading from the memory
- Writing into a memory location
- Inserting a scalar into a vector
- Extracting a scalar from a vector
- 4 Basic IR Tranformations
- Opt tool
- Pass and Pass Manager
- Using other pass info in the current pass
- Instruction simplification example
- Instruction combining
- 5 Advanced IR Blokc Transformations
- Loop processing
- Scalar evolution
- LLVM intrinsics
- Vectorization
- 6 IR to Selection DAG Phase
- Converting IR to SelectionDAG
- Legalizing SelectionDAG
- Optimizing SelectionDAG
- Instruction selection
- Scheduling and emitting machine instructions
- Register allocation
- Code emission
- 7 Generating Code for Target Architecture
- Sample backend
- Implementing frame lowering
- Lowering instructions
- Printing an instruction
- 1 Playing with LLVM
Learn LLVM 12
- Table of Contents
- Section 1 The Basic of Compiler Construction with LLVM
- 1 Installing LLVM
- 2 Touring the LLVM Source Code
- 3 The Structure of the Compiler
- Section 2 From Source Code to Machine Code Construction
- 4 Turning the Source File into an Abstract Syntax Tree
- 5 Basic of IR Code Generation
- 6 IR Generation for High-level Language Constructs
- 7 Advanced IR Generation
- 8 Optimizing IR
- Section 3 Taking LLVM to the Next Level
- 9 Instruction Selection
- 10 JIT Compilation
- 11 Debugging with LLVM Tools
- 12 Create your own backend
- Section 1 The Basic of Compiler Construction with LLVM
Getting Started with LLVM Core Libraries
- Table of Contents
- 1 Build and install LLVM
- 2 External Projectos
- 3 Tools and Design
- 4 The Frontend
- 5 The LLVM Intermediate Representation
- 6 The Backend
- 7 The Just-In-Time Compiler
- 8 Cross-platform Compilation
- 9 The Clang Static Analyzer
- 10 Clang Tools with LibTooling
LLVM Cookbook
- Table of Contents
- 1 LLVM Design and Use
- Introduction
- Understanding modular design
- Cross-compiling Clang/LLVM
- Converting a C source code to LLVM assembly
- Converting IR to LLVM bitcode
- Converting LLVM bitcode back to target machine assembly
- Transforming LLVM IR
- Linking LLVM bitcode
- Executing LLVM bitcode
- Using the C frontend Clang
- Using the GO frontend
- Using DragonEgg
- 2 Steps in Writing a Frontend
- Introduction
- Defining a TOY Language
- Implementing a lexer
- Defining Abstract Syntax Trees
- Implementing a parser
- Parsing simple expressions
- Parsing binary expressions
- Invoking a driver for parsing
- Running lexer and parser on our TOY language
- Defining IR code generation methods for each AST class
- Generating IR code for expressions
- Generating IR code for functions
- Adding IR optimizations support
- 3 Extending the Frontend and Adding JIT Support
- Introduction
- Handling decision making paradigms - if/then/else constructs
- Generating code for loops
- Handling user-defined operators - binary operators
- Handling user-defined operators - unary operators
- Adding JIT support
- 4 Preparing Optimizations
- Introduction
- Various levels of optimization
- Writing your own LLVM pass
- Running your own pass with the opt tool
- Using another pass in a new pass
- Registering a pass with pass manager
- Writing an analysis pass
- Writing an alias analysis pass
- Using other analysis passes
- 5 Implementing Optimizations
- Introduction
- Writing a dead code elimination pass
- Writing an inlining transformation pass
- Writing a pass for memory optimization
- Combining LLVM IR
- Transforming and optimizing loops
- Reassociating expressions
- Vectorizing IR
- Other optimization passes
- 6 Target-independent Code Generator
- Introduction
- The life of an LLVM IR instruction
- Machine DAG
- Visualizing LLVM IR CFG using GraphViz
- Describing targets using TableGen
- Defining an instruction set
- Adding a machine code descriptor
- Implementing the MachineInstrBuilder class
- Implementing the MachineBasicBlock class
- Implementing the MachineFunction class
- Writing an instruction selector
- Legalizing SelectionDAG
- Optimizing SelectionDAG
- Selecting instruction from the DAG
- Scheduling instructions in SelectionDAG
- 7 Optimizing the Machine Code
- Introduction
- Eliminating common subexpression from machine code
- Analyzing live internals
- Allocating registers
- Inserting the prologue-epilogue code
- Code emission
- Tail call optimization
- Sibling call optimization
- 8 Writing an LLVM Backend
- Introduction
- Defining registers and registers sets
- Defining the calling convention
- Defining the instruction set
- Implementing frame lowering
- Printing an instruction
- Selecting an instruction
- Adding an instruction encodeing
- Supporting a subtarget
- Lowering to multiple instructions
- Registering a target
- 9 Using LLVM for Various Useful Projects
- Introduction
- Exception handling in LLVM
- Using sanitizers
- Writing the garbage collector with LLVM
- Converting LLVM IR to JavaScript
- Using the Clang Static Analyzer
- Using bugpoint
- Using LLDB
- Using LLVM utility passes
- 1 LLVM Design and Use
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
- Table of Contents
- Section 1 Build System and LLVM-specific Tooling
- 1 Saving resources when building LLVM
- 2 Exploring LLVM's Build System Features
- 3 Testing with LLVM LIT
- 4 TableGen Development
- Section 2 Frontend Development
- 5 Exploring Clang's Architecture
- 6 Extending the Preprocessor
- 7 Handling AST
- 8 Working with Compiler Flags and Toolchains
- Section 3 Middle-End Management
- 9 Working with PassManager and AnalysisManager
- 10 Processing LLVM IR
- 11 Gearing up with Support Utilities
- 12 Learning LLVM IR Instrumentation
- Section 1 Build System and LLVM-specific Tooling