# llvm/llvm-project architecture

> Architecture diagram of the GitHub repository llvm/llvm-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/llvm/llvm-project
- Repository: https://github.com/llvm/llvm-project
- Video tour (about a minute): https://gitdiagram.com/llvm/llvm-project/video

## Overview

LLVM BOLT is a post-link binary optimizer: a user supplies an executable and, commonly, profile data; BOLT analyzes and optimizes the binary, then emits a rewritten executable. The tree shows distinct profile handling, binary representation, optimization passes, rewriting, and instrumentation runtime capabilities. The sampled evidence is limited: the source index exposes the pass manager’s pass references, while other workflow connections are architectural context from the tree and remain dashed and uncited rather than asserted as inspected calls.

Main entry points: [`bolt/tools/driver/llvm-bolt.cpp`](https://github.com/llvm/llvm-project/blob/main/bolt/tools/driver/llvm-bolt.cpp) (BOLT driver), [`bolt/lib/Rewrite/BinaryPassManager.cpp`](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/BinaryPassManager.cpp) (Pass manager), [`bolt/lib/Rewrite/RewriteInstance.cpp`](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/RewriteInstance.cpp) (Executable rewriting), [`bolt/lib/Profile`](https://github.com/llvm/llvm-project/tree/main/bolt/lib/Profile) (Profile readers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Inputs and profiles"]
  node_exe["Input executable"]
  node_profile["Profile data"]
  node_profileio["Profile readers"]
end

subgraph group_analysis["Binary analysis"]
  node_context["Binary context<br/>[BinaryContext.cpp]"]
  node_functions["Binary functions<br/>[BinaryFunction.cpp]"]
  node_profileagg["Profile aggregation<br/>[DataAggregator.cpp]"]
end

subgraph group_optimize["Optimization"]
  node_passmgr["Pass manager"]
  node_reorder["Layout and reordering"]
  node_inlining["Inlining and folding<br/>[Inliner.cpp]"]
  node_instrument["Instrumentation passes"]
  node_analysispasses["Analysis passes"]
end

subgraph group_rewrite["Rewrite and runtime"]
  node_driver["BOLT driver<br/>[llvm-bolt.cpp]"]
  node_emitter["Binary emitter<br/>[BinaryEmitter.cpp]"]
  node_rewriter["Executable rewriting"]
  node_metadata["Metadata rewriting<br/>[DWARFRewriter.cpp]"]
  node_runtime["Instrumentation runtime<br/>[instr.cpp]"]
  node_output["Rewritten executable"]
  node_hugify["Hugify runtime<br/>[hugify.cpp]"]
end

node_user(("BOLT user"))

node_user -.->|"invokes"| node_driver
node_exe -.->|"provides input"| node_driver
node_profile -.->|"read by"| node_profileio
node_driver -.->|"analyzes through"| node_context
node_context -.->|"models"| node_functions
node_profileio -.->|"aggregates into"| node_profileagg
node_driver -.->|"runs passes"| node_passmgr
node_passmgr -->|"dispatches"| node_reorder
node_passmgr -->|"dispatches"| node_inlining
node_passmgr -->|"dispatches"| node_instrument
node_passmgr -->|"dispatches"| node_analysispasses
node_driver -.->|"rewrites through"| node_rewriter
node_rewriter -.->|"emits via"| node_emitter
node_rewriter -.->|"rewrites metadata"| node_metadata
node_emitter -.->|"writes"| node_output
node_instrument -.->|"uses"| node_runtime
node_driver -.->|"may include"| node_hugify

click node_profile "https://github.com/llvm/llvm-project/tree/main/bolt/lib/Profile"
click node_profileio "https://github.com/llvm/llvm-project/tree/main/bolt/lib/Profile"
click node_driver "https://github.com/llvm/llvm-project/blob/main/bolt/tools/driver/llvm-bolt.cpp"
click node_context "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Core/BinaryContext.cpp"
click node_functions "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Core/BinaryFunction.cpp"
click node_profileagg "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Profile/DataAggregator.cpp"
click node_passmgr "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/BinaryPassManager.cpp"
click node_reorder "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/ReorderFunctions.cpp"
click node_inlining "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/Inliner.cpp"
click node_instrument "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/Instrumentation.cpp"
click node_analysispasses "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/DataflowAnalysis.cpp"
click node_emitter "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Core/BinaryEmitter.cpp"
click node_rewriter "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/RewriteInstance.cpp"
click node_metadata "https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/DWARFRewriter.cpp"
click node_runtime "https://github.com/llvm/llvm-project/blob/main/bolt/runtime/instr.cpp"
click node_hugify "https://github.com/llvm/llvm-project/blob/main/bolt/runtime/hugify.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_exe,node_profile,node_profileio,node_user toneBlue
class node_context,node_functions,node_profileagg toneAmber
class node_passmgr,node_reorder,node_inlining,node_instrument,node_analysispasses toneMint
class node_driver,node_emitter,node_rewriter,node_metadata,node_runtime,node_output,node_hugify toneRose
```

## Components

### Inputs and profiles

- **Input executable**
- [Profile data](https://github.com/llvm/llvm-project/tree/main/bolt/lib/Profile): `bolt/lib/Profile`
- [Profile readers](https://github.com/llvm/llvm-project/tree/main/bolt/lib/Profile): `bolt/lib/Profile`

### Binary analysis

- [Binary context](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Core/BinaryContext.cpp): `bolt/lib/Core/BinaryContext.cpp`
- [Binary functions](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Core/BinaryFunction.cpp): `bolt/lib/Core/BinaryFunction.cpp`
- [Profile aggregation](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Profile/DataAggregator.cpp): `bolt/lib/Profile/DataAggregator.cpp`

### Optimization

- [Pass manager](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/BinaryPassManager.cpp): `bolt/lib/Rewrite/BinaryPassManager.cpp`
- [Layout and reordering](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/ReorderFunctions.cpp): `bolt/lib/Passes/ReorderFunctions.cpp`
- [Inlining and folding](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/Inliner.cpp): `bolt/lib/Passes/Inliner.cpp`
- [Instrumentation passes](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/Instrumentation.cpp): `bolt/lib/Passes/Instrumentation.cpp`
- [Analysis passes](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Passes/DataflowAnalysis.cpp): `bolt/lib/Passes/DataflowAnalysis.cpp`

### Rewrite and runtime

- [BOLT driver](https://github.com/llvm/llvm-project/blob/main/bolt/tools/driver/llvm-bolt.cpp): `bolt/tools/driver/llvm-bolt.cpp`
- [Binary emitter](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Core/BinaryEmitter.cpp): `bolt/lib/Core/BinaryEmitter.cpp`
- [Executable rewriting](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/RewriteInstance.cpp): `bolt/lib/Rewrite/RewriteInstance.cpp`
- [Metadata rewriting](https://github.com/llvm/llvm-project/blob/main/bolt/lib/Rewrite/DWARFRewriter.cpp): `bolt/lib/Rewrite/DWARFRewriter.cpp`
- [Instrumentation runtime](https://github.com/llvm/llvm-project/blob/main/bolt/runtime/instr.cpp): `bolt/runtime/instr.cpp`
- **Rewritten executable**
- [Hugify runtime](https://github.com/llvm/llvm-project/blob/main/bolt/runtime/hugify.cpp): `bolt/runtime/hugify.cpp`

### Other components

- **BOLT user**

## Connections

- BOLT user → BOLT driver: invokes
- Input executable → BOLT driver: provides input
- Profile data → Profile readers: read by
- BOLT driver → Binary context: analyzes through
- Binary context → Binary functions: models
- Profile readers → Profile aggregation: aggregates into
- BOLT driver → Pass manager: runs passes
- Pass manager → Layout and reordering: dispatches (evidence: `bolt/lib/Rewrite/BinaryPassManager.cpp`)
- Pass manager → Inlining and folding: dispatches (evidence: `bolt/lib/Rewrite/BinaryPassManager.cpp`)
- Pass manager → Instrumentation passes: dispatches (evidence: `bolt/lib/Rewrite/BinaryPassManager.cpp`)
- Pass manager → Analysis passes: dispatches (evidence: `bolt/lib/Rewrite/BinaryPassManager.cpp`)
- BOLT driver → Executable rewriting: rewrites through
- Executable rewriting → Binary emitter: emits via
- Executable rewriting → Metadata rewriting: rewrites metadata
- Binary emitter → Rewritten executable: writes
- Instrumentation passes → Instrumentation runtime: uses
- BOLT driver → Hugify runtime: may include
