Skip to content

Commit 43ea75d

Browse files
authored
[DeveloperPolicy] Add guidelines for adding/enabling passes (#158591)
This documents two things: * The recommended way to go about adding a new pass. * The criteria for enabling a pass. RFC: https://discourse.llvm.org/t/rfc-guidelines-for-adding-enabling-new-passes/88290
1 parent 8f62481 commit 43ea75d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

llvm/docs/DeveloperPolicy.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,55 @@ Suggested disclaimer for the project README and the main project web page:
11891189
necessarily a reflection of the completeness or stability of the code, it
11901190
does indicate that the project is not yet endorsed as a component of LLVM.
11911191

1192+
Adding or enabling a new LLVM pass
1193+
----------------------------------
1194+
1195+
The guidelines here are primarily targeted at the enablement of new major
1196+
passes in the target-independent optimization pipeline. Small additions, or
1197+
backend-specific passes, require a lesser degree of care. Before creating a new
1198+
pass, consider whether the functionality can be integrated into an existing
1199+
pass first. This is often both faster and more powerful.
1200+
1201+
When adding a new pass, the goal should be to enable it as part of the default
1202+
optimization pipeline as early as possible and then continue development
1203+
incrementally. (This does not apply to passes that are only relevant for
1204+
specific uses of LLVM, such as GC support passes.)
1205+
1206+
The recommended workflow is:
1207+
1208+
1. Implement a basic version of the pass and add it to the pass pipeline behind
1209+
a flag that is disabled by default. The initial version should focus on
1210+
handling simple cases correctly and efficiently.
1211+
2. Enable the pass by default. Separating this step allows easily disabling the
1212+
pass if issues are encountered, without having to revert the entire
1213+
implementation.
1214+
3. Incrementally extend the pass with new functionality. As the pass is already
1215+
enabled, it becomes easier to identify the specific change that has caused a
1216+
regression in correctness, optimization quality or compile-time.
1217+
1218+
When enabling a pass, certain requirements must be met (in no particular order):
1219+
1220+
* **Maintenance:** The pass (and any analyses it depends on) must have at
1221+
least one maintainer.
1222+
* **Usefulness:** There should be evidence that the pass improves performance
1223+
(or whatever metric it optimizes for) on real-world workloads. Improvements
1224+
seen only on synthetic benchmarks may be insufficient.
1225+
* **Compile-Time:** The pass should not have a large impact on compile-time,
1226+
where the evaluation of what "large" means is up to reviewer discretion, and
1227+
may differ based on the value the pass provides. In any case, it is expected
1228+
that a concerted effort has been made to mitigate the compile-time impact,
1229+
both for the average case, and for pathological cases.
1230+
* **Correctness:** The pass should have no known correctness issues (except
1231+
global correctness issues that affect all of LLVM). If an old pass is being
1232+
enabled (rather than implementing a new one incrementally), additional due
1233+
diligence is required. The pass should be fully reviewed to ensure that it
1234+
still complies with current quality standards. Fuzzing with disabled
1235+
profitability checks may help gain additional confidence in the
1236+
implementation.
1237+
1238+
If non-trivial issues are found in a newly enabled pass, it may be temporarily
1239+
disabled again, until the issues have been resolved.
1240+
11921241
.. _copyright-license-patents:
11931242

11941243
Copyright, License, and Patents

0 commit comments

Comments
 (0)