skills/llvm/SKILL.md
LLVM IR and pass pipeline skill. Use when working directly with LLVM Intermediate Representation (IR), running opt passes, generating IR with llc, inspecting or writing LLVM IR for custom passes, or understanding how the LLVM backend lowers IR to assembly. Activates on queries about LLVM IR, opt, llc, llvm-dis, LLVM passes, IR transformations, or building LLVM-based tools.
npx skillsauth add awfixers-stuff/opencode-config llvmInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide agents through the LLVM IR pipeline: generating IR, running optimisation passes with opt, lowering to assembly with llc, and inspecting IR for debugging or performance work.
# Emit textual IR (.ll)
clang -O0 -emit-llvm -S src.c -o src.ll
# Emit bitcode (.bc)
clang -O2 -emit-llvm -c src.c -o src.bc
# Disassemble bitcode to text
llvm-dis src.bc -o src.ll
opt# Apply a specific pass
opt -passes='mem2reg,instcombine,simplifycfg' src.ll -S -o out.ll
# Standard optimisation pipelines
opt -passes='default<O2>' src.ll -S -o out.ll
opt -passes='default<O3>' src.ll -S -o out.ll
# List available passes
opt --print-passes 2>&1 | less
# Print IR before and after a pass
opt -passes='instcombine' --print-before=instcombine --print-after=instcombine src.ll -S -o out.ll 2>&1 | less
llc# Compile IR to object file
llc -filetype=obj src.ll -o src.o
# Compile to assembly
llc -filetype=asm -masm-syntax=intel src.ll -o src.s
# Target a specific CPU
llc -mcpu=skylake -mattr=+avx2 src.ll -o src.s
# Show available targets
llc --version
Key IR constructs to understand:
| Construct | Meaning |
|-----------|---------|
| alloca | Stack allocation (pre-SSA; mem2reg promotes to registers) |
| load/store | Memory access |
| getelementptr (GEP) | Pointer arithmetic / field access |
| phi | SSA φ-node: merges values from predecessor blocks |
| call/invoke | Function call (invoke has exception edges) |
| icmp/fcmp | Integer/float comparison |
| br | Branch (conditional or unconditional) |
| ret | Return |
| bitcast | Reinterpret bits (no-op in codegen) |
| ptrtoint/inttoptr | Pointer↔integer (avoid where possible) |
| Pass | Effect |
|------|--------|
| mem2reg | Promote alloca to SSA registers |
| instcombine | Instruction combining / peephole |
| simplifycfg | CFG cleanup, dead block removal |
| loop-vectorize | Auto-vectorisation |
| slp-vectorize | Superword-level parallelism (straight-line vectorisation) |
| inline | Function inlining |
| gvn | Global value numbering (common subexpression elimination) |
| licm | Loop-invariant code motion |
| loop-unroll | Loop unrolling |
| argpromotion | Promote pointer args to values |
| sroa | Scalar Replacement of Aggregates |
# Why was a loop not vectorised?
clang -O2 -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize src.c
# Dump pass pipeline
clang -O2 -mllvm -debug-pass=Structure src.c -o /dev/null 2>&1 | less
# Print IR after each pass (very verbose)
opt -passes='default<O2>' -print-after-all src.ll -S 2>&1 | less
| Tool | Purpose |
|------|---------|
| llvm-dis | Bitcode → textual IR |
| llvm-as | Textual IR → bitcode |
| llvm-link | Link multiple bitcode files |
| llvm-lto | Standalone LTO |
| llvm-nm | Symbols in bitcode/object |
| llvm-objdump | Disassemble objects |
| llvm-profdata | Merge/show PGO profiles |
| llvm-cov | Coverage reporting |
| llvm-mca | Machine code analyser (throughput/latency) |
For binutils equivalents, see skills/binaries/binutils.
skills/compilers/clang for source-level Clang flagsskills/binaries/linkers-lto for LTO at link timeskills/profilers/linux-perf combined with llvm-mca for micro-architectural analysisdevelopment
Use when starting dev servers, watchers, tilt, or any process expected to outlive the conversation. Provides zmx session management patterns for long-lived processes.
development
Zig testing skill for writing and running tests. Use when using zig build test, writing comptime tests, using test filters, working with test allocators to detect leaks, or using Zig's built-in fuzz testing (0.14+). Activates on queries about Zig tests, zig test, zig build test, comptime testing, test allocators, Zig fuzz testing, or detecting memory leaks in Zig tests.
development
Zig debugging skill. Use when debugging Zig programs with GDB or LLDB, interpreting Zig runtime panics, using std.debug.print for tracing, configuring debug builds, or debugging Zig programs in VS Code. Activates on queries about debugging Zig, Zig panics, zig gdb, zig lldb, std.debug.print, Zig stack traces, or Zig error return traces.
tools
Zig cross-compilation skill. Use when cross-compiling Zig programs to different targets, using Zig's built-in cross-compilation for embedded, WASM, Windows, ARM, or using zig cc to cross-compile C code without a system cross-toolchain. Activates on queries about Zig cross-compilation, zig target triples, zig cc cross-compile, Zig embedded targets, or Zig WASM.