Skip to content

Commit da036b4

Browse files
committed
[Docs][NewPM] Add note about required passes
Reviewed By: ychen Differential Revision: https://reviews.llvm.org/D88342
1 parent e862e78 commit da036b4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

llvm/docs/WritingAnLLVMNewPMPass.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,32 @@ test at ``llvm/test/Transforms/HelloNew/helloworld.ll``. See
207207
208208
$ ninja -C build check-llvm
209209
# runs our new test alongside all other llvm lit tests
210+
211+
FAQs
212+
====
213+
214+
Required passes
215+
---------------
216+
217+
A pass that defines a static ``isRequired()`` method that returns true is a required pass. For example:
218+
219+
.. code-block:: c++
220+
221+
class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
222+
public:
223+
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
224+
225+
static bool isRequired() { return true; }
226+
};
227+
228+
A required pass is a pass that may not be skipped. An example of a required
229+
pass is ``AlwaysInlinerPass``, which must always be run to preserve
230+
``alwaysinline`` semantics. Pass managers are required since they may contain
231+
other required passes.
232+
233+
An example of how a pass can be skipped is the ``optnone`` function
234+
attribute, which specifies that optimizations should not be run on the
235+
function. Required passes will still be run on ``optnone`` functions.
236+
237+
For more implementation details, see
238+
``PassInstrumentation::runBeforePass()``.

0 commit comments

Comments
 (0)