[PATCH] D88342: [Docs][NewPM] Add note about required passes
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 15:23:59 PDT 2020
aeubanks created this revision.
aeubanks added reviewers: ychen, asbirlea.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
aeubanks requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88342
Files:
llvm/docs/WritingAnLLVMNewPMPass.rst
Index: llvm/docs/WritingAnLLVMNewPMPass.rst
===================================================================
--- llvm/docs/WritingAnLLVMNewPMPass.rst
+++ llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -207,3 +207,30 @@
$ ninja -C build check-llvm
# runs our new test alongside all other llvm lit tests
+
+FAQs
+====
+
+Required passes
+---------------
+
+If the pass is a required pass, meaning it must run on the IR to produce
+semantically valid output, add a static ``isRequired()`` method that returns
+true to the pass class.
+
+.. code-block:: c++
+
+ class HelloWorldPass : public PassInfoMixin<HelloWorldPass> {
+ public:
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+
+ static bool isRequired() { return true; }
+ };
+
+This will make it run even in the presence of something that skips
+optimization passes, like the ``optnone`` function attribute.
+
+``AlwaysInlinerPass`` is an example of a required pass in-tree.
+
+For more info on how this works, see
+``PassInstrumentation::runBeforePass()``.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88342.294440.patch
Type: text/x-patch
Size: 1044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200925/7ae29a67/attachment.bin>
More information about the llvm-commits
mailing list