Day 08 of 30 · LLVM IR
Read LLVM intermediate representation
- Time
- About 150 minutes: 45 reading, 75 lab, 20 testing, 10 notes.
- Prerequisites
- Day 07: Consolidate the compiler foundations
Toolchain: LLVM 17
Use your LLVM 17 clang++, llvm-as and opt for book exercises, by explicit path. Use the matching archived documentation. Do not mix headers, libraries or plugins with your current-main build. Setup guide
Learn
- Modules, functions, blocks, instructions, types and SSA values.
Read Reading
- R1 · Learn LLVM 17, Second Edition
Chapter 4: first IR generation discussion · 25 min - R6 · LLVM language reference
Functions, basic blocks and arithmetic instructions · 20 min
Reading budgets cover selected sections, not whole chapters. Link to the book; this site does not reproduce it.
Build Build or investigate
- Use LLVM 17 Clang to emit IR for two tiny C++ functions.
- Annotate arguments, return type, basic block and instructions.
- Handwrite a small i32 function and check it with
llvm-asandoptverification.
Done when
An annotated .ll file and a verifier-clean handwritten function.
Recall question
Why is an LLVM SSA value different from a mutable C++ local variable?
Completion checks
Progress tracking needs JavaScript. The lesson above is complete without it.
Notes
Saved only in this browser. Keep it short enough to finish in ten minutes; none of the prompts are required. All notes, export and import