# grqz/llvm-project architecture

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

- Interactive diagram: https://gitdiagram.com/grqz/llvm-project
- Repository: https://github.com/grqz/llvm-project

## Overview

LLVM is a compiler infrastructure project spanning language frontends, optimization/code generation, binary rewriting, and runtime libraries. A documented Clang workflow takes C-family source through LLVM to object files. The sampled code also shows Clang’s path-sensitive analyzer dispatching checker callbacks and maintaining analysis state, plus BOLT’s profile/pass/rewrite subsystems and Flang’s FIR pipeline capabilities. BOLT and Flang relationships are kept conservative: the tree and sampled files establish these subsystems, but not a complete end-to-end runtime call graph.

Main entry points: [`bolt/tools/driver/llvm-bolt.cpp`](https://github.com/grqz/llvm-project/blob/main/bolt/tools/driver/llvm-bolt.cpp) (BOLT driver), [`clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`](https://github.com/grqz/llvm-project/blob/main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp) (Path-sensitive engine), [`clang-tools-extra/clang-query/tool/ClangQuery.cpp`](https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/tool/ClangQuery.cpp) (Clang frontend), [`bolt/lib/Rewrite/BinaryPassManager.cpp`](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Rewrite/BinaryPassManager.cpp) (Pass orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Language frontends"]
  node_clang["Clang frontend<br/>[ClangQuery.cpp]"]
  node_preprocessor["Preprocessor<br/>[Preprocessor.h]"]
  node_clang_ast["AST model<br/>[Decl.h]"]
  node_query_parser["Query parsing<br/>[QueryParser.cpp]"]
  node_query_engine["AST query<br/>[Query.h]"]
end

subgraph group_analysis["Static analysis"]
  node_clang_analyzer["Path-sensitive engine<br/>[ExprEngine.cpp]"]
  node_checker_manager["Checker dispatch<br/>[CheckerManager.h]"]
  node_abstract_values["Abstract values<br/>[SVals.h]"]
  node_bug_reports["Bug reporting<br/>[BugReporter.h]"]
end

subgraph group_bolt["Binary optimization"]
  node_bolt_driver["BOLT driver<br/>[llvm-bolt.cpp]"]
  node_profile_reader["Profile input<br/>[DataReader.cpp]"]
  node_profile_aggregate["Profile aggregation<br/>[DataAggregator.cpp]"]
  node_binary_context["Binary model<br/>[BinaryContext.cpp]"]
  node_bolt_pass_manager["Pass orchestration"]
  node_bolt_passes["Optimization passes"]
  node_binary_rewriter["Binary rewriting"]
end

subgraph group_flang["Fortran lowering"]
  node_flang_pipeline["FIR pass pipelines<br/>[Pipelines.cpp]"]
  node_flang_temp["Temporary storage"]
end

node_developer(("Compiler user"))
node_llvm_backend["LLVM backend"]
node_object_file["Object file"]

node_developer -->|"provides source"| node_clang
node_clang -->|"lowers to"| node_llvm_backend
node_llvm_backend -->|"emits"| node_object_file
node_clang_analyzer -->|"dispatches callbacks"| node_checker_manager
node_clang_analyzer -.->|"models values"| node_abstract_values
node_clang_analyzer -.->|"generates diagnostics"| node_bug_reports
node_query_parser -.->|"produces queries"| node_query_engine
node_bolt_driver -.->|"reads profiles"| node_profile_reader
node_bolt_driver -.->|"loads binary"| node_binary_context
node_bolt_pass_manager -->|"runs passes"| node_bolt_passes
node_bolt_driver -.->|"configures passes"| node_bolt_pass_manager
node_bolt_driver -.->|"rewrites binary"| node_binary_rewriter
node_flang_pipeline -.->|"uses lowering"| node_flang_temp

click node_clang "https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/tool/ClangQuery.cpp"
click node_preprocessor "https://github.com/grqz/llvm-project/blob/main/clang/include/clang/Lex/Preprocessor.h"
click node_clang_ast "https://github.com/grqz/llvm-project/blob/main/clang/include/clang/AST/Decl.h"
click node_clang_analyzer "https://github.com/grqz/llvm-project/blob/main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp"
click node_checker_manager "https://github.com/grqz/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h"
click node_abstract_values "https://github.com/grqz/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
click node_bug_reports "https://github.com/grqz/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
click node_query_parser "https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/QueryParser.cpp"
click node_query_engine "https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/Query.h"
click node_bolt_driver "https://github.com/grqz/llvm-project/blob/main/bolt/tools/driver/llvm-bolt.cpp"
click node_profile_reader "https://github.com/grqz/llvm-project/blob/main/bolt/lib/Profile/DataReader.cpp"
click node_profile_aggregate "https://github.com/grqz/llvm-project/blob/main/bolt/lib/Profile/DataAggregator.cpp"
click node_binary_context "https://github.com/grqz/llvm-project/blob/main/bolt/lib/Core/BinaryContext.cpp"
click node_bolt_pass_manager "https://github.com/grqz/llvm-project/blob/main/bolt/lib/Rewrite/BinaryPassManager.cpp"
click node_bolt_passes "https://github.com/grqz/llvm-project/blob/main/bolt/lib/Passes/ReorderFunctions.cpp"
click node_binary_rewriter "https://github.com/grqz/llvm-project/blob/main/bolt/lib/Rewrite/RewriteInstance.cpp"
click node_flang_pipeline "https://github.com/grqz/llvm-project/blob/main/flang/lib/Optimizer/Passes/Pipelines.cpp"
click node_flang_temp "https://github.com/grqz/llvm-project/blob/main/flang/lib/Optimizer/Builder/TemporaryStorage.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_clang,node_preprocessor,node_clang_ast,node_query_parser,node_query_engine,node_developer toneBlue
class node_clang_analyzer,node_checker_manager,node_abstract_values,node_bug_reports toneAmber
class node_bolt_driver,node_profile_reader,node_profile_aggregate,node_binary_context,node_bolt_pass_manager,node_bolt_passes,node_binary_rewriter toneMint
class node_flang_pipeline,node_flang_temp toneRose
class node_llvm_backend,node_object_file toneIndigo
```

## Components

### Language frontends

- [Clang frontend](https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/tool/ClangQuery.cpp): `clang-tools-extra/clang-query/tool/ClangQuery.cpp`
- [Preprocessor](https://github.com/grqz/llvm-project/blob/main/clang/include/clang/Lex/Preprocessor.h): `clang/include/clang/Lex/Preprocessor.h`
- [AST model](https://github.com/grqz/llvm-project/blob/main/clang/include/clang/AST/Decl.h): `clang/include/clang/AST/Decl.h`
- [Query parsing](https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/QueryParser.cpp): `clang-tools-extra/clang-query/QueryParser.cpp`
- [AST query](https://github.com/grqz/llvm-project/blob/main/clang-tools-extra/clang-query/Query.h): `clang-tools-extra/clang-query/Query.h`

### Static analysis

- [Path-sensitive engine](https://github.com/grqz/llvm-project/blob/main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp): `clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`
- [Checker dispatch](https://github.com/grqz/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h): `clang/include/clang/StaticAnalyzer/Core/CheckerManager.h`
- [Abstract values](https://github.com/grqz/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h): `clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h`
- [Bug reporting](https://github.com/grqz/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h): `clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h`

### Binary optimization

- [BOLT driver](https://github.com/grqz/llvm-project/blob/main/bolt/tools/driver/llvm-bolt.cpp): `bolt/tools/driver/llvm-bolt.cpp`
- [Profile input](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Profile/DataReader.cpp): `bolt/lib/Profile/DataReader.cpp`
- [Profile aggregation](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Profile/DataAggregator.cpp): `bolt/lib/Profile/DataAggregator.cpp`
- [Binary model](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Core/BinaryContext.cpp): `bolt/lib/Core/BinaryContext.cpp`
- [Pass orchestration](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Rewrite/BinaryPassManager.cpp): `bolt/lib/Rewrite/BinaryPassManager.cpp`
- [Optimization passes](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Passes/ReorderFunctions.cpp): `bolt/lib/Passes/ReorderFunctions.cpp`
- [Binary rewriting](https://github.com/grqz/llvm-project/blob/main/bolt/lib/Rewrite/RewriteInstance.cpp): `bolt/lib/Rewrite/RewriteInstance.cpp`

### Fortran lowering

- [FIR pass pipelines](https://github.com/grqz/llvm-project/blob/main/flang/lib/Optimizer/Passes/Pipelines.cpp): `flang/lib/Optimizer/Passes/Pipelines.cpp`
- [Temporary storage](https://github.com/grqz/llvm-project/blob/main/flang/lib/Optimizer/Builder/TemporaryStorage.cpp): `flang/lib/Optimizer/Builder/TemporaryStorage.cpp`

### Other components

- **Compiler user**
- **LLVM backend**
- **Object file**

## Connections

- Compiler user → Clang frontend: provides source (evidence: `README.md`)
- Clang frontend → LLVM backend: lowers to (evidence: `README.md`)
- LLVM backend → Object file: emits (evidence: `README.md`)
- Path-sensitive engine → Checker dispatch: dispatches callbacks (evidence: `clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`)
- Path-sensitive engine → Abstract values: models values
- Path-sensitive engine → Bug reporting: generates diagnostics (evidence: `clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`)
- Query parsing → AST query: produces queries
- BOLT driver → Profile input: reads profiles
- BOLT driver → Binary model: loads binary
- Pass orchestration → Optimization passes: runs passes (evidence: `bolt/lib/Rewrite/BinaryPassManager.cpp`)
- BOLT driver → Pass orchestration: configures passes
- BOLT driver → Binary rewriting: rewrites binary
- FIR pass pipelines → Temporary storage: uses lowering
