Skip to content

Commit 1b5fae9

Browse files
authored
[docs] Try to make it easier to find info about new PM vs legacy PM (#80834)
Seen several beginner questions popping up in discourse about how to implement and run custom passes. And then it turns out that they are following the old "Writing an LLVM Pass" guide that describe legacy passes, and then things are mixed up when they try to run that pass using opt that nowadays default to the new pass manager. This is an attempt to make it slightly clearer in the User Guides that there are two different "Writing an LLVM Pass" pages depending on which pass manager that should be used. This is done by renaming the legacy version of "Writing an LLVM Pass" as "Writing an LLVM Pass (legacy PM version)". Also reordered the links to put the link to the new pass manager documentation first. This patch also moves the warning text that cross references the description on how to write a pass for legacy/new PM to make sure it ends up already in the beginning of the descriptions. Also adding a new warning in the "Running a pass with opt" section of the legacy PM version of the guide, to inform that those examples are outdated.
1 parent 1dd9162 commit 1b5fae9

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

llvm/docs/UserGuides.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ LLVM Builds and Distributions
123123
Optimizations
124124
-------------
125125

126-
:doc:`WritingAnLLVMPass`
127-
Information on how to write LLVM transformations and analyses.
128-
129126
:doc:`WritingAnLLVMNewPMPass`
130127
Information on how to write LLVM transformations under the new pass
131128
manager.
132129

130+
:doc:`WritingAnLLVMPass`
131+
Information on how to write LLVM transformations and analyses under the
132+
legacy pass manager.
133+
133134
:doc:`Passes`
134135
A list of optimizations and analyses implemented in LLVM.
135136

llvm/docs/WritingAnLLVMNewPMPass.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Writing an LLVM Pass
1010
Introduction --- What is a pass?
1111
================================
1212

13+
.. warning::
14+
This document deals with the new pass manager. LLVM uses the legacy pass
15+
manager for the codegen pipeline. For more details, see
16+
:doc:`WritingAnLLVMPass` and :doc:`NewPassManager`.
17+
1318
The LLVM pass framework is an important part of the LLVM system, because LLVM
1419
passes are where most of the interesting parts of the compiler exist. Passes
1520
perform the transformations and optimizations that make up the compiler, they
@@ -29,11 +34,6 @@ We start by showing you how to construct a pass, from setting up the build,
2934
creating the pass, to executing and testing it. Looking at existing passes is
3035
always a great way to learn details.
3136

32-
.. warning::
33-
This document deals with the new pass manager. LLVM uses the legacy pass
34-
manager for the codegen pipeline. For more details, see
35-
:doc:`WritingAnLLVMPass` and :doc:`NewPassManager`.
36-
3737
Quick Start --- Writing hello world
3838
===================================
3939

llvm/docs/WritingAnLLVMPass.rst

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
====================
2-
Writing an LLVM Pass
3-
====================
1+
========================================
2+
Writing an LLVM Pass (legacy PM version)
3+
========================================
44

55
.. program:: opt
66

@@ -10,6 +10,13 @@ Writing an LLVM Pass
1010
Introduction --- What is a pass?
1111
================================
1212

13+
.. warning::
14+
This document deals with the legacy pass manager. LLVM uses the new pass
15+
manager for the optimization pipeline (the codegen pipeline
16+
still uses the legacy pass manager), which has its own way of defining
17+
passes. For more details, see :doc:`WritingAnLLVMNewPMPass` and
18+
:doc:`NewPassManager`.
19+
1320
The LLVM Pass Framework is an important part of the LLVM system, because LLVM
1421
passes are where most of the interesting parts of the compiler exist. Passes
1522
perform the transformations and optimizations that make up the compiler, they
@@ -34,13 +41,6 @@ We start by showing you how to construct a pass, everything from setting up the
3441
code, to compiling, loading, and executing it. After the basics are down, more
3542
advanced features are discussed.
3643

37-
.. warning::
38-
This document deals with the legacy pass manager. LLVM uses the new pass
39-
manager for the optimization pipeline (the codegen pipeline
40-
still uses the legacy pass manager), which has its own way of defining
41-
passes. For more details, see :doc:`WritingAnLLVMNewPMPass` and
42-
:doc:`NewPassManager`.
43-
4444
Quick Start --- Writing hello world
4545
===================================
4646

@@ -224,6 +224,13 @@ can have them) to be useful.
224224
Running a pass with ``opt``
225225
---------------------------
226226

227+
.. warning::
228+
This document deals with the legacy pass manager. The :program:`opt` tool no
229+
longer supports running legacy passes (except for certain hardcoded backend
230+
passes and when using bugpoint). So the examples below for loading and
231+
running legacy passes using :program:`opt` are deprecated and no longer
232+
guaranteed to work.
233+
227234
Now that you have a brand new shiny shared object file, we can use the
228235
:program:`opt` command to run an LLVM program through your pass. Because you
229236
registered your pass with ``RegisterPass``, you will be able to use the

0 commit comments

Comments
 (0)