[BOLT][docs] New backend guide - #211382
Merged
Merged
Conversation
aaupov
requested review from
ayermolo,
maksfb,
paschalis-mpeis,
rafaelauler,
yavtuk and
yozhu
as code owners
July 22, 2026 21:22
rafaelauler
approved these changes
Jul 22, 2026
|
@llvm/pr-subscribers-bolt Author: Amir Ayupov (aaupov) ChangesAdd a brief doc with BOLT-specific guidance for adding a new backend. Full diff: https://github.com/llvm/llvm-project/pull/211382.diff 2 Files Affected:
diff --git a/bolt/docs/NewBackend.md b/bolt/docs/NewBackend.md
new file mode 100644
index 0000000000000..f236f282909c8
--- /dev/null
+++ b/bolt/docs/NewBackend.md
@@ -0,0 +1,34 @@
+# Adding a New BOLT Backend
+
+A new BOLT backend should follow LLVM's
+[policy for adding a new target](https://llvm.org/docs/DeveloperPolicy.html#adding-a-new-target).
+New BOLT targets are experimental and are not built by default.
+
+Most target-specific work should be isolated in an `MCPlusBuilder`
+implementation under `bolt/lib/Target/<Target>`, together with
+platform-specific relocation handling in `bolt/lib/Core/Relocation.cpp`.
+
+Changes to common infrastructure, particularly `MCPlusBuilder`, must be
+separate from the target changes and land first. Such changes require thorough
+tests and must state their processing-time and peak-memory impact on existing
+targets. Measurements should use large binaries, including at least Clang
+itself.
+
+A backend does not need to implement every `MCPlusBuilder` interface initially.
+However, omitted interfaces must be checked against their callers. Analyses and
+passes that depend on missing functionality, such as stack frame analysis or
+register liveness, must remain disabled.
+
+BOLT passes are not cleanly partitioned into common and target-specific code.
+Enable them for a new target only after auditing their target assumptions and
+proving them stable with target-specific and end-to-end tests. Otherwise, keep
+them disabled.
+
+RISC targets generally need the `LongJmp` pass for branch relaxation. This
+requires correct branch-range checks and short- and long-jump construction,
+with tests covering range boundaries, calls, tail calls, and linker relaxation.
+
+The initial backend should include focused tests for instruction analysis,
+relocations, CFG construction, rewriting, and each enabled pass. Validation
+must include rewriting and executing large real-world binaries, with Clang as
+the minimum large-binary test.
diff --git a/bolt/docs/index.md b/bolt/docs/index.md
index e39892df38523..d1d0894afa68a 100644
--- a/bolt/docs/index.md
+++ b/bolt/docs/index.md
@@ -41,7 +41,7 @@ BOLTAArch64OptimizationStatus
BAT
BinaryAnalysis
+NewBackend
PointerAuthDesign
RuntimeLibrary
```
-
|
midhuncodes7
pushed a commit
to midhuncodes7/llvm-project
that referenced
this pull request
Jul 28, 2026
Add a brief doc with BOLT-specific guidance for adding a new backend.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a brief doc with BOLT-specific guidance for adding a new backend.