Use this skill when the user says 'LLVM', 'LLVM IR', 'compiler backend', 'optimization pass', 'frontend/backend separation', 'SSA IR'. Explains LLVM's three-phase design, SSA-form IR, and the pass pipeline. Do NOT use for: eBPF bytecode specifics (use niche/low-level/ebpf-xdp-networking) or language-specific syntax.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Llvm Compiler Architecture?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/j4flmao-llvm-compiler-architecture)
---
name: llvm-compiler-architecture
description: >
Use this skill when the user says 'LLVM', 'LLVM IR', 'compiler backend', 'optimization pass', 'frontend/backend separation', 'SSA IR'. Explains LLVM's three-phase design, SSA-form IR, and the pass pipeline. Do NOT use for: eBPF bytecode specifics (use niche/low-level/ebpf-xdp-networking) or language-specific syntax.
version: "1.0.0"
author: "j4flmao"
license: "MIT"
tags: [niche, low-level, llvm, compilers, ir]
---
# LLVM Compiler Architecture
## Purpose
Explain LLVM's modular compiler architecture: the frontend/optimizer/backend three-phase split, the SSA-form LLVM IR as the common interface, and how optimization and codegen passes transform it.
## Agent Protocol
### Trigger
User phrases: "LLVM IR", "three-phase compiler", "optimization pass", "SSA form", "target backend".
### Input Context
- Source language / frontend (Clang, rustc).
- Target architecture.
### Output Artifact
Architecture explanation and pass-pipeline guidance.
### Response Format
```
Phase: {frontend | optimizer | backend}
IR: {SSA, typed}
Pass: {analysis | transform}
```
## Core Mechanics
LLVM is a collection of modular and reusable compiler and toolchain technologies. It is the backend for Rust, Swift, and modern C/C++ (Clang).
### 1. The Three-Phase Design
Unlike monolithic compilers, LLVM strictly separates concerns:
- **Frontend (e.g., Clang):** Parses source code (C++, Rust), builds an Abstract Syntax Tree (AST), and translates it into LLVM IR.
- **Optimizer:** Takes LLVM IR, applies language-independent optimizations (dead code elimination, loop unrolling), and outputs optimized IR.
- **Backend (Code Generator):** Translates optimized IR into target-specific machine code (x86, ARM, WebAssembly).
### 2. LLVM IR (Intermediate Representation)
A strongly typed, RISC-like virtual instruction set. It uses SSA (Static Single Assignment) form, meaning every variable is assigned exactly once, making data flow analysis for optimizations mathematically trivial.
### Compiler Flow Map
```mermaid
%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
flowchart TD
subgraph Frontend ["Frontend (Language Specific)"]
A["Source Code (Rust/C)"]
B["Lexer / Parser"]
C["AST (Abstract Syntax Tree)"]
end
subgraph MiddleEnd ["Optimizer (LLVM Core)"]
D["LLVM IR (Unoptimized)"]
E["Optimization Passes"]
F["LLVM IR (Optimized)"]
end
subgraph Backend ["Backend (Hardware Specific)"]
G["Instruction Selection"]
H["Register Allocation"]
I["Machine Code (x86 / ARM)"]
end
A --> B
B --> C
C -->|"Emit IR"| D
D --> E
E --> F
F --> G
G --> H
H --> I
```