[llvm] da036b4 - [Docs][NewPM] Add note about required passes
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 21:45:37 PDT 2020
Author: Arthur Eubanks
Date: 2020-09-28T21:45:14-07:00
New Revision: da036b4514702f3a7c1d2981ff11b3067bad4329
URL: https://github.com/llvm/llvm-project/commit/da036b4514702f3a7c1d2981ff11b3067bad4329
DIFF: https://github.com/llvm/llvm-project/commit/da036b4514702f3a7c1d2981ff11b3067bad4329.diff
LOG: [Docs][NewPM] Add note about required passes
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D88342
Added:
Modified:
llvm/docs/WritingAnLLVMNewPMPass.rst
Removed:
################################################################################
diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index a876ec4ceb00..f992c850c193 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -207,3 +207,32 @@ test at ``llvm/test/Transforms/HelloNew/helloworld.ll``. See
$ ninja -C build check-llvm
# runs our new test alongside all other llvm lit tests
+
+FAQs
+====
+
+Required passes
+---------------
+
+A pass that defines a static ``isRequired()`` method that returns true is a required pass. For example:
+
+.. code-block:: c++
+
+ class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
+ public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+ static bool isRequired() { return true; }
+ };
+
+A required pass is a pass that may not be skipped. An example of a required
+pass is ``AlwaysInlinerPass``, which must always be run to preserve
+``alwaysinline`` semantics. Pass managers are required since they may contain
+other required passes.
+
+An example of how a pass can be skipped is the ``optnone`` function
+attribute, which specifies that optimizations should not be run on the
+function. Required passes will still be run on ``optnone`` functions.
+
+For more implementation details, see
+``PassInstrumentation::runBeforePass()``.
More information about the llvm-commits
mailing list