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

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

Build Build or investigate

  1. Handwrite a function choosing one of two values with a branch and phi.
  2. Verify and run it.
  3. Run an optimization pipeline on a separate arithmetic example and inspect the diff.
  4. 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.

Required to complete day 11
Optional (not counted)

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