# llvm-mirror/llvm architecture

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

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

## Overview

LLVM is a compiler infrastructure toolkit: clients construct or parse LLVM IR, analyze and optimize it, then lower it for a target or execute it through an interpreter/JIT. The tree also exposes language bindings and specialized tools for machine-code analysis and IR comparison. The README establishes the toolkit’s broad purpose; the sampled implementation is limited, so edges describe documented subsystem responsibilities rather than uninspected internal call chains.

Main entry points: [`include/llvm-c/Core.h`](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Core.h) (IR API), [`include/llvm-c/Transforms/PassManagerBuilder.h`](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/PassManagerBuilder.h) (Pass manager), [`include/llvm-c/TargetMachine.h`](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/TargetMachine.h) (Target machine), [`include/llvm/CodeGen/Passes.h`](https://github.com/llvm-mirror/llvm/blob/master/include/llvm/CodeGen/Passes.h) (Machine codegen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ir["IR and Inputs"]
  node_ir_api["IR API<br/>[Core.h]"]
  node_asm_parser["IR parser<br/>[Parser.h]"]
  node_bit_reader["Bitcode reader<br/>[BitReader.h]"]
  node_bit_writer["Bitcode writer<br/>[BitWriter.h]"]
end

subgraph group_transform["Analysis and Transforms"]
  node_analysis["IR analysis<br/>[Passes.h]"]
  node_pass_builder["Pass manager"]
  node_scalar["Scalar transforms<br/>[Scalar.h]"]
  node_ipo["IPO transforms<br/>[IPO.h]"]
  node_vectorize["Vectorization<br/>[Vectorize.h]"]
end

subgraph group_backend["Codegen and Runtime"]
  node_target["Target machine<br/>[TargetMachine.h]"]
  node_codegen["Machine codegen<br/>[Passes.h]"]
  node_engine_api["Execution engine API<br/>[ExecutionEngine.h]"]
  node_engine_impl["Execution engine"]
  node_machine_scheduler["Loop pipeliner"]
end

subgraph group_interfaces["Bindings and Tools"]
  node_go_bindings["Go bindings<br/>[ir.go]"]
  node_ocaml_bindings["OCaml bindings<br/>[llvm_ocaml.c]"]
  node_python_bindings["Python bindings<br/>[core.py]"]
  node_mca_pipeline["MCA pipeline<br/>[Pipeline.cpp]"]
  node_mca_report["MCA reporting<br/>[PipelinePrinter.h]"]
  node_ir_diff["IR comparison"]
end

node_client(("Compiler client"))

node_client -->|"builds IR"| node_ir_api
node_client -->|"parses IR"| node_asm_parser
node_client -->|"reads bitcode"| node_bit_reader
node_ir_api -->|"writes bitcode"| node_bit_writer
node_ir_api -->|"analyzes IR"| node_analysis
node_ir_api -->|"configures passes"| node_pass_builder
node_pass_builder -->|"runs passes"| node_scalar
node_pass_builder -->|"runs passes"| node_ipo
node_pass_builder -->|"runs passes"| node_vectorize
node_ir_api -->|"provides module"| node_target
node_target -->|"lowers for target"| node_codegen
node_ir_api -->|"provides module"| node_engine_api
node_engine_api -->|"creates or invokes"| node_engine_impl
node_codegen -->|"schedules loops"| node_machine_scheduler
node_client -->|"uses"| node_go_bindings
node_client -->|"uses"| node_ocaml_bindings
node_client -->|"uses"| node_python_bindings
node_go_bindings -->|"wraps C API"| node_ir_api
node_ocaml_bindings -->|"wraps C API"| node_ir_api
node_python_bindings -->|"exposes IR"| node_ir_api
node_client -->|"analyzes machine code"| node_mca_pipeline
node_mca_pipeline -->|"reports cycles"| node_mca_report
node_client -->|"compares modules"| node_ir_diff

click node_ir_api "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Core.h"
click node_asm_parser "https://github.com/llvm-mirror/llvm/blob/master/include/llvm/AsmParser/Parser.h"
click node_bit_reader "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/BitReader.h"
click node_bit_writer "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/BitWriter.h"
click node_analysis "https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Analysis/Passes.h"
click node_pass_builder "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/PassManagerBuilder.h"
click node_scalar "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/Scalar.h"
click node_ipo "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/IPO.h"
click node_vectorize "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/Vectorize.h"
click node_target "https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/TargetMachine.h"
click node_codegen "https://github.com/llvm-mirror/llvm/blob/master/include/llvm/CodeGen/Passes.h"
click node_engine_api "https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ExecutionEngine/ExecutionEngine.h"
click node_engine_impl "https://github.com/llvm-mirror/llvm/blob/master/lib/ExecutionEngine/ExecutionEngine.cpp"
click node_machine_scheduler "https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/MachinePipeliner.cpp"
click node_go_bindings "https://github.com/llvm-mirror/llvm/blob/master/bindings/go/llvm/ir.go"
click node_ocaml_bindings "https://github.com/llvm-mirror/llvm/blob/master/bindings/ocaml/llvm/llvm_ocaml.c"
click node_python_bindings "https://github.com/llvm-mirror/llvm/blob/master/bindings/python/llvm/core.py"
click node_mca_pipeline "https://github.com/llvm-mirror/llvm/blob/master/lib/MCA/Pipeline.cpp"
click node_mca_report "https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-mca/PipelinePrinter.h"
click node_ir_diff "https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-diff/DifferenceEngine.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_ir_api,node_asm_parser,node_bit_reader,node_bit_writer,node_client toneBlue
class node_analysis,node_pass_builder,node_scalar,node_ipo,node_vectorize toneAmber
class node_target,node_codegen,node_engine_api,node_engine_impl,node_machine_scheduler toneMint
class node_go_bindings,node_ocaml_bindings,node_python_bindings,node_mca_pipeline,node_mca_report,node_ir_diff toneRose
```

## Components

### IR and Inputs

- [IR API](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Core.h): `include/llvm-c/Core.h`
- [IR parser](https://github.com/llvm-mirror/llvm/blob/master/include/llvm/AsmParser/Parser.h): `include/llvm/AsmParser/Parser.h`
- [Bitcode reader](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/BitReader.h): `include/llvm-c/BitReader.h`
- [Bitcode writer](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/BitWriter.h): `include/llvm-c/BitWriter.h`

### Analysis and Transforms

- [IR analysis](https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Analysis/Passes.h): `include/llvm/Analysis/Passes.h`
- [Pass manager](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/PassManagerBuilder.h): `include/llvm-c/Transforms/PassManagerBuilder.h`
- [Scalar transforms](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/Scalar.h): `include/llvm-c/Transforms/Scalar.h`
- [IPO transforms](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/IPO.h): `include/llvm-c/Transforms/IPO.h`
- [Vectorization](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Transforms/Vectorize.h): `include/llvm-c/Transforms/Vectorize.h`

### Codegen and Runtime

- [Target machine](https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/TargetMachine.h): `include/llvm-c/TargetMachine.h`
- [Machine codegen](https://github.com/llvm-mirror/llvm/blob/master/include/llvm/CodeGen/Passes.h): `include/llvm/CodeGen/Passes.h`
- [Execution engine API](https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ExecutionEngine/ExecutionEngine.h): `include/llvm/ExecutionEngine/ExecutionEngine.h`
- [Execution engine](https://github.com/llvm-mirror/llvm/blob/master/lib/ExecutionEngine/ExecutionEngine.cpp): `lib/ExecutionEngine/ExecutionEngine.cpp`
- [Loop pipeliner](https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/MachinePipeliner.cpp): `lib/CodeGen/MachinePipeliner.cpp`

### Bindings and Tools

- [Go bindings](https://github.com/llvm-mirror/llvm/blob/master/bindings/go/llvm/ir.go): `bindings/go/llvm/ir.go`
- [OCaml bindings](https://github.com/llvm-mirror/llvm/blob/master/bindings/ocaml/llvm/llvm_ocaml.c): `bindings/ocaml/llvm/llvm_ocaml.c`
- [Python bindings](https://github.com/llvm-mirror/llvm/blob/master/bindings/python/llvm/core.py): `bindings/python/llvm/core.py`
- [MCA pipeline](https://github.com/llvm-mirror/llvm/blob/master/lib/MCA/Pipeline.cpp): `lib/MCA/Pipeline.cpp`
- [MCA reporting](https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-mca/PipelinePrinter.h): `tools/llvm-mca/PipelinePrinter.h`
- [IR comparison](https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-diff/DifferenceEngine.cpp): `tools/llvm-diff/DifferenceEngine.cpp`

### Other components

- **Compiler client**

## Connections

- Compiler client → IR API: builds IR
- Compiler client → IR parser: parses IR
- Compiler client → Bitcode reader: reads bitcode
- IR API → Bitcode writer: writes bitcode
- IR API → IR analysis: analyzes IR
- IR API → Pass manager: configures passes
- Pass manager → Scalar transforms: runs passes
- Pass manager → IPO transforms: runs passes
- Pass manager → Vectorization: runs passes
- IR API → Target machine: provides module
- Target machine → Machine codegen: lowers for target
- IR API → Execution engine API: provides module
- Execution engine API → Execution engine: creates or invokes
- Machine codegen → Loop pipeliner: schedules loops
- Compiler client → Go bindings: uses
- Compiler client → OCaml bindings: uses
- Compiler client → Python bindings: uses
- Go bindings → IR API: wraps C API
- OCaml bindings → IR API: wraps C API
- Python bindings → IR API: exposes IR
- Compiler client → MCA pipeline: analyzes machine code
- MCA pipeline → MCA reporting: reports cycles
- Compiler client → IR comparison: compares modules
