Day 11 of 30 · LLVM IR
Understand control flow and optimization
- Time
- About 150 minutes: 45 reading, 75 lab, 20 testing, 10 notes.
- Prerequisites
- Day 10: Compile and run a tiny program
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
- Branches, phi nodes, memory operations and transformation passes.
Read Reading
- R1 · Learn LLVM 17, Second Edition
Chapter 7: pass-manager overview · 20 min - R6 · LLVM language reference
br and phi · 15 min - R7 · LLVM frontend tutorial
Control-flow discussion · 10 min
Reading budgets cover selected sections, not whole chapters. Link to the book; this site does not reproduce it.
Build Build or investigate
- Handwrite a function choosing one of two values with a branch and phi.
- Verify and run it.
- Run an optimization pipeline on a separate arithmetic example and inspect the diff.
- Keep source-language control flow out of the toy project today.
Done when
A valid control-flow example and a short before/after IR explanation.
Recall question
What does a phi input’s predecessor block tell you?
Optional
- Add if expressions to the toy language after the core tasks pass.
Optional work never counts toward completion.
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