Demystifying LLVM: Writing Your First Compiler - The Good, The Bad, The Ugly
summary
Built a toy compiler called Cyclang in Rust and targets LLVM via the low‑level C bindings so the code generator emits LLVM IR and uses the JIT or can produce a binary. Parser uses pest and the AST performs desugaring (for → while) and loop‑depth checks to implement break as a small IR branch change. Strings end up implemented in C, constant folding and dead‑code elimination come from LLVM optimizations.
AI-written summary · about
chapters (17)
- 0:00Building a toy compiler with LLVM
- 1:12What is LLVM and why it matters
- 3:45Compiler workflow overview
- 8:46For loop in Cyclang and AST conversion
- 11:15LLVM IR of a for loop
- 15:15Adding break to the language
- 19:14Live demo of Cyclang compiler
- 23:43Challenges with strings in LLVM
- 26:09Learning LLVM three years ago versus today with AI
- 27:57Summary
- 28:17Q&A: Whitespace in PEG parsers
- 30:04Q&A: LLVM bindings vs higher-level libraries
- 32:10Q&A: Interpreted vs pre-compiled with LLVM
- 33:58Q&A: Optimization levels in REPL
- 34:41Q&A: Custom compiler backend plans
- 35:45Q&A: Syntax highlighting with Cyclang
- 37:53Q&A: Memory allocation and GC
related talks
26mHow Rust Compiles - Noratrieb
58m(Almost) Everything You Should Know About The Compiler Frontend
25mMaking Tools for Rust: An Introduction to the Compiler and How It Can Help You
48mWriting a compiler with LLVM
09mRustc: How I Learned to Respect the Compiler
36mRusty Runtimes: Building Languages In Rust
57mLLVM Optimization Remarks
25m"Compiler-Driven Development: Making Rust Work for You"
