Skip to main content
skill CX Codex

llvm-ir-and-passes — Claude Code skill: what it does, how to install

llvm-ir-and-passes teaches the agent to read LLVM IR, understand SSA form, and navigate optimization passes. Useful when tracing what -O2 changed or preparing to write a custom pass.

MIT 384 installs ★ 298 updated 2026-06-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill llvm-ir-and-passes -a claude-code
Open on GitHub

What llvm-ir-and-passes does

The agent learns LLVM IR structure: basic blocks, PHI nodes at merge points, typed values like i32 or ptr. The skill covers the standard optimization pipeline (SimplifyCFG, InstCombine, GVN, LICM) and commands to run passes via opt. It includes examples for emitting IR from source (clang -S -emit-llvm), disassembling bitcode (llvm-dis), and comparing code before and after transformations.

You need clang and opt of matching versions. Different LLVM major versions produce incompatible IR. The skill complements skills/compilers/llvm (toolchain overview) and skills/compiler-internals/llvm-passes (plugin development).

What it helps with

  • trace what -O2 did to a function
  • understand SSA form and dominator trees without writing C++ passes
  • find the root cause of a miscompile between Clang versions
  • inspect the optimization pipeline before writing a custom pass
  • compare IR before and after specific transformations

Example prompts for the agent

  • Explain this PHI node and which pass likely created it
  • Show the dominator tree for foo.ll
  • Run opt with the -O2 pipeline and compare the result to the original IR

How to install llvm-ir-and-passes

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill llvm-ir-and-passes -a claude-code

2Manually: put the files in place

~/.claude/skills/llvm-ir-and-passes/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/llvm-ir-and-passes/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about llvm-ir-and-passes

How to install llvm-ir-and-passes in Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill llvm-ir-and-passes -a claude-code. The skill will appear in ~/.claude/skills/llvm-ir-and-passes/SKILL.md.

What does llvm-ir-and-passes do?

Teaches the agent to read LLVM IR, work with SSA form, understand optimization pass order, and use opt for inspection and transformations.

What does llvm-ir-and-passes require?

You need clang and opt of matching LLVM major versions. Different versions produce incompatible IR.

Source text

SKILL.md · MIT
---
name: llvm-ir-and-passes
description: LLVM IR and passes skill for reading compiler IR. Use when analyzing LLVM IR, understanding SSA, pass pipeline order, or running opt on bitcode. Activates on queries about LLVM IR, SSA form, opt passes, llvm-dis, pass pipeline, or reading .ll files.
---

# LLVM IR and Passes

## Purpose

Teach agents to read and reason about LLVM IR (SSA, types, terminators), navigate the standard pass pipeline, and use `opt`/`llvm-dis` for inspection. Complements `skills/compilers/llvm` (toolchain) and `skills/compiler-internals/llvm-passes` (writing plugins) — not merged.

## When to Use

- Understanding what `-O2` changed in generated IR
- Triaging miscompiles between Clang versions
- Preparing to write a custom pass
- Teaching SSA and dominance without writing C++ passes yet

## Workflow

### 1. LLVM IR structure

```llvm
; Function in SSA form
define i32 @add(i32 %a, i32 %b) {
entry:
  %sum = add i32 %a, %b
  ret i32 %sum
}
```

Key concepts: basic blocks, PHI nodes at merges, typed values (`i32`, `ptr`, vectors).

### 2. Emit IR from Clang

```bash
clang -S -emit-llvm -O0 -o foo.ll foo.c
clang -c -emit-llvm -O2 -o foo.bc foo.c
llvm-dis foo.bc -o foo.ll
```

### 3. Standard optimization pipeline (New PM)

Clang `-O2` roughly runs:

```
SimplifyCFG → InstCombine → GVN → LICM → LoopVectorize → ...
```

Inspect with:

```bash
opt -passes='default<O2>' -S foo.ll -o foo-opt.ll
opt -passes='default<O2>' -print-passes foo.ll 2>&1 | head
```

### 4. Useful analysis passes

| Pass | Shows |
|------|-------|
| `-passes=print<domtree>` | Dominator tree |
| `-passes=print<loops>` | Loop nests |
| `-passes=print-alias-sets` | Alias sets |

```bash
opt -passes='print<domtree>' -disable-output foo.ll
```

### 5. Reading PHI and UB

```llvm
merge:
  %v = phi i32 [ %a, %then ], [ %b, %else ]
```

`undef` and `poison` in IR model LLVM poison semantics — distinct from C UB but related.

### 6. Compare before/after

```bash
opt -passes='instcombine,simplifycfg' -S foo.ll -o - | diff -u foo.ll -
```

### 7. Agent usage

```
/llvm-ir-and-passes Explain this PHI node and which pass likely created it
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| Pass not found | LLVM version rename | `opt --print-passes` for your build |
| IR mismatch | Different LLVM major | Match clang/opt versions |
| "optnone" blocks opts | `-O0` attribute | Compile with `-O1+` |
| Huge IR | Inlined headers | `-fno-discard-value-names` off; filter function |
| Wrong pipeline | Legacy vs NPM | Use `-passes=` syntax |

## Related Skills

- `skills/compilers/llvm` — toolchain overview
- `skills/compiler-internals/llvm-passes` — writing PassPlugins
- `skills/compiler-internals/compiler-optimizations-deep` — RA and ISel
- `skills/compiler-internals/compiler-frontend` — IR generation
- `skills/rust/rustc-basics` — `rustc --emit=llvm-ir`

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

All skills for Programming languages →

From the same set140

The whole set →
compiler-frontend A skill for building compiler frontends, from tokenization and parsing to type checks and LLVM IR generation. Useful for a language, DSL, or interpreter. CX Codex +1 390installs qemu-embedded-simulation The qemu-embedded-simulation skill guides QEMU runs of bare-metal ARM and RISC-V firmware and GDB sessions. Use it to test firmware without a board. CX Codex +1 389installs kernel-memory-management kernel-memory-management — a skill that walks an AI agent through Linux kernel allocation: kmalloc vs vmalloc vs page allocator, GFP flags, zones and OOM debugging. CX Codex +1 388installs cuda-debugging Walks the agent through CUDA debugging: cuda-gdb, Compute Sanitizer, GPU core dumps, error codes 700 and 702. Useful when a kernel crashes or returns wrong values. CX Codex +1 386installs spi-i2c-baremetal The spi-i2c-baremetal skill guides bare-metal SPI and I2C driver work, from register reads to bus troubleshooting. Use it when bringing up sensors, flash, or displays. CX Codex +1 384installs protocol-analysis protocol-analysis is a Claude Code skill that decodes I2C, SPI, and UART captures with sigrok and PulseView, then checks them against driver code. It handles silent-sensor bus analysis. CX Codex +1 383installs gpio-baremetal gpio-baremetal configures GPIO modes, alternate functions, pull resistors, and EXTI interrupts on bare-metal microcontrollers without HAL. CX Codex +1 383installs apple-silicon A skill for developers building on Apple Silicon: tuning code for unified memory, Metal Performance Shaders, Instruments profiling, Rosetta 2 behavior, and 16KB page size quirks. CX Codex +1 383installs

Project sponsors

Companies that keep this analytics open