Day 10 of 30 · LLVM IR
Compile and run a tiny program
- Time
- About 150 minutes: 40 reading, 80 lab, 20 testing, 10 notes.
- Prerequisites
- Day 09: Generate IR from your AST
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
- Connecting generated IR to a host program.
Read Reading
- R1 · Learn LLVM 17, Second Edition
Chapter 4: module and driver discussion · 30 min - R7 · LLVM frontend tutorial
Object-code chapter, skim · 10 min
Reading budgets cover selected sections, not whole chapters. Link to the book; this site does not reproduce it.
Build Build or investigate
- Emit a function named calc returning the expression result.
- Compile the
.llfile with matching LLVM 17 Clang and link a tiny C++ harness usingextern "C". - Compare executable output with your evaluator on bounded integer examples.
Done when
One end-to-end demo and at least five evaluator-versus-compiled comparisons.
Recall question
Why does the C++ harness declare calc with C linkage?
Optional
- Generate an object file directly through the book’s driver approach.
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