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

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

Build Build or investigate

  1. Emit a function named calc returning the expression result.
  2. Compile the .ll file with matching LLVM 17 Clang and link a tiny C++ harness using extern "C".
  3. 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.

Required to complete day 10
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