skills/compiler-internals/llvm-ir-and-passes/SKILL.md
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.
npx skillsauth add mohitmishra786/low-level-dev-skills llvm-ir-and-passesInstall 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.
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.
-O2 changed in generated IR; 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).
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
Clang -O2 roughly runs:
SimplifyCFG → InstCombine → GVN → LICM → LoopVectorize → ...
Inspect with:
opt -passes='default<O2>' -S foo.ll -o foo-opt.ll
opt -passes='default<O2>' -print-passes foo.ll 2>&1 | head
| Pass | Shows |
|------|-------|
| -passes=print<domtree> | Dominator tree |
| -passes=print<loops> | Loop nests |
| -passes=print-alias-sets | Alias sets |
opt -passes='print<domtree>' -disable-output foo.ll
merge:
%v = phi i32 [ %a, %then ], [ %b, %else ]
undef and poison in IR model LLVM poison semantics — distinct from C UB but related.
opt -passes='instcombine,simplifycfg' -S foo.ll -o - | diff -u foo.ll -
/llvm-ir-and-passes Explain this PHI node and which pass likely created it
| 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 |
skills/compilers/llvm — toolchain overviewskills/compiler-internals/llvm-passes — writing PassPluginsskills/compiler-internals/compiler-optimizations-deep — RA and ISelskills/compiler-internals/compiler-frontend — IR generationskills/rust/rustc-basics — rustc --emit=llvm-irdevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
development
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.