# bytedance/tangollvm architecture

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

- Interactive diagram: https://gitdiagram.com/bytedance/tangollvm
- Repository: https://github.com/bytedance/tangollvm

## Overview

TangoLLVM is an LLVM distribution intended as an opt-in backend for Tango’s Go compiler: the frontend supplies LLVM IR, LLVM produces a relocatable object using Go ABIInternal conventions, and a Go-toolchain step merges it with other outputs. The README also documents Go runtime-call and GC/statepoint support plus a small C API, but those implementation paths are not present in the supplied tree. The tree does include BOLT and substantial Clang components; BOLT is described as future Tango work. Edges below rely on README statements or the shown source references, not an inspection of unsampled implementation.

Main entry points: [`clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp) (Expression engine), [`clang/lib/Basic/SourceManager.cpp`](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/lib/Basic/SourceManager.cpp) (Source management), [`bolt/lib/Rewrite/BinaryPassManager.cpp`](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/bolt/lib/Rewrite/BinaryPassManager.cpp) (Binary pass manager), [`clang/include/clang/AST/Decl.h`](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/AST/Decl.h) (AST declarations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Tango integration"]
  node_llvm_ir["LLVM IR input"]
  node_abi_codegen["Go ABI codegen"]
  node_go_runtime["Go runtime patterns"]
  node_gc_support["GC statepoints"]
  node_c_api["Tango C API"]
  node_object_output["Relocatable object"]
  node_patch_merge["Patch and merge"]
  node_go_toolchain["Go toolchain outputs"]
end

subgraph group_clang["Clang frontend"]
  node_clang_ast["AST declarations<br/>[Decl.h]"]
  node_clang_statements["AST statements<br/>[Stmt.h]"]
  node_source_manager["Source management<br/>[SourceManager.cpp]"]
  node_preprocessor["Preprocessor<br/>[Preprocessor.h]"]
end

subgraph group_analysis["Static analysis"]
  node_expr_engine["Expression engine<br/>[ExprEngine.cpp]"]
  node_checker_manager["Checker dispatch<br/>[CheckerManager.h]"]
  node_bug_reports["Bug reporting<br/>[BugReporter.h]"]
end

subgraph group_bolt["BOLT rewriting"]
  node_bolt_binary["Binary pass manager"]
  node_bolt_passes["Binary optimization passes"]
end

node_go_frontend(("Tango Go frontend"))

node_go_frontend -->|"lowers to"| node_llvm_ir
node_llvm_ir -->|"compiles with"| node_abi_codegen
node_abi_codegen -->|"emits"| node_object_output
node_go_runtime -->|"supports"| node_abi_codegen
node_gc_support -->|"supports"| node_abi_codegen
node_c_api -->|"exposes"| node_abi_codegen
node_object_output -->|"feeds"| node_patch_merge
node_patch_merge -->|"combines with"| node_go_toolchain
node_source_manager -.->|"tracks locations for"| node_clang_ast
node_expr_engine -->|"dispatches checks"| node_checker_manager
node_expr_engine -.->|"uses reports"| node_bug_reports
node_bolt_binary -->|"registers passes"| node_bolt_passes

click node_clang_ast "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/AST/Decl.h"
click node_clang_statements "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/AST/Stmt.h"
click node_source_manager "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/lib/Basic/SourceManager.cpp"
click node_preprocessor "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/Lex/Preprocessor.h"
click node_expr_engine "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp"
click node_checker_manager "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h"
click node_bug_reports "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
click node_bolt_binary "https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/bolt/lib/Rewrite/BinaryPassManager.cpp"
click node_bolt_passes "https://github.com/bytedance/tangollvm/tree/release/tangollvm19.x/bolt/lib/Passes"

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_llvm_ir,node_abi_codegen,node_go_runtime,node_gc_support,node_c_api,node_object_output,node_patch_merge,node_go_toolchain,node_go_frontend toneBlue
class node_clang_ast,node_clang_statements,node_source_manager,node_preprocessor toneAmber
class node_expr_engine,node_checker_manager,node_bug_reports toneMint
class node_bolt_binary,node_bolt_passes toneRose
```

## Components

### Tango integration

- **LLVM IR input**
- **Go ABI codegen**
- **Go runtime patterns**
- **GC statepoints**
- **Tango C API**
- **Relocatable object**
- **Patch and merge**
- **Go toolchain outputs**

### Clang frontend

- [AST declarations](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/AST/Decl.h): `clang/include/clang/AST/Decl.h`
- [AST statements](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/AST/Stmt.h): `clang/include/clang/AST/Stmt.h`
- [Source management](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/lib/Basic/SourceManager.cpp): `clang/lib/Basic/SourceManager.cpp`
- [Preprocessor](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/Lex/Preprocessor.h): `clang/include/clang/Lex/Preprocessor.h`

### Static analysis

- [Expression engine](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp): `clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`
- [Checker dispatch](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h): `clang/include/clang/StaticAnalyzer/Core/CheckerManager.h`
- [Bug reporting](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h): `clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h`

### BOLT rewriting

- [Binary pass manager](https://github.com/bytedance/tangollvm/blob/release/tangollvm19.x/bolt/lib/Rewrite/BinaryPassManager.cpp): `bolt/lib/Rewrite/BinaryPassManager.cpp`
- [Binary optimization passes](https://github.com/bytedance/tangollvm/tree/release/tangollvm19.x/bolt/lib/Passes): `bolt/lib/Passes`

### Other components

- **Tango Go frontend**

## Connections

- Tango Go frontend → LLVM IR input: lowers to (evidence: `README.md`)
- LLVM IR input → Go ABI codegen: compiles with (evidence: `README.md`)
- Go ABI codegen → Relocatable object: emits (evidence: `README.md`)
- Go runtime patterns → Go ABI codegen: supports (evidence: `README.md`)
- GC statepoints → Go ABI codegen: supports (evidence: `README.md`)
- Tango C API → Go ABI codegen: exposes (evidence: `README.md`)
- Relocatable object → Patch and merge: feeds (evidence: `README.md`)
- Patch and merge → Go toolchain outputs: combines with (evidence: `README.md`)
- Source management → AST declarations: tracks locations for (evidence: `clang/lib/Basic/SourceManager.cpp`)
- Expression engine → Checker dispatch: dispatches checks (evidence: `clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`)
- Expression engine → Bug reporting: uses reports (evidence: `clang/lib/StaticAnalyzer/Core/ExprEngine.cpp`)
- Binary pass manager → Binary optimization passes: registers passes (evidence: `bolt/lib/Rewrite/BinaryPassManager.cpp`)
