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

Reading budgets cover selected sections, not whole chapters. Link to the book; this site does not reproduce it.

Build Build or investigate

  1. Use LLVM 17 Clang to emit IR for two tiny C++ functions.
  2. Annotate arguments, return type, basic block and instructions.
  3. Handwrite a small i32 function and check it with llvm-as and opt verification.

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.

Required to complete day 08

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