Lines Matching full:pass
2 Writing an LLVM Pass
10 Introduction --- What is a pass?
14 This document deals with the new pass manager. LLVM uses the legacy pass
18 The LLVM pass framework is an important part of the LLVM system, because LLVM
24 Unlike passes under the legacy pass manager where the pass interface is
25 defined via inheritance, passes under the new pass manager rely on
28 the CRTP mix-in ``PassInfoMixin<PassT>``. The pass should have a ``run()``
30 along with an analysis manager. For example, a function pass would have a
33 We start by showing you how to construct a pass, from setting up the build,
34 creating the pass, to executing and testing it. Looking at existing passes is
41 pass is designed to simply print out the name of non-external functions that
45 The code below already exists; feel free to create a pass with a different
48 .. _writing-an-llvm-npm-pass-build:
58 If you'd like to create your own pass, add a new source file into
59 ``llvm/lib/Transforms/Utils/CMakeLists.txt`` (assuming you want your pass in
62 Now that we have the build set up for a new pass, we need to write the code
63 for the pass itself.
65 .. _writing-an-llvm-npm-pass-basiccode:
70 Now that the build is setup for a new pass, we just have to write it.
72 First we need to define the pass in a header file. We'll create
94 This creates the class for the pass with a declaration of the ``run()``
95 method which actually runs the pass. Inheriting from ``PassInfoMixin<PassT>``
117 Next we have the pass's ``run()`` definition:
127 ... which simply prints out the name of the function to stderr. The pass
128 manager will ensure that the pass will be run on every function in a module.
130 tree) are still valid after this pass since we didn't modify any functions.
132 That's it for the pass itself. Now in order to "register" the pass, we need
140 ... which adds the pass under the name "helloworld".
144 it constructs our pass, we need to also add the proper #include in
151 This should be all the code necessary for our pass, now it's time to compile
154 Running a pass with ``opt``
157 Now that you have a brand new shiny pass, we can build :program:`opt` and use
158 it to run some LLVM IR through the pass.
179 Our pass ran and printed the names of functions as expected!
181 Testing a pass
184 Testing our pass is important to prevent future regressions. We'll add a lit
213 A pass that defines a static ``isRequired()`` method that returns true is a required pass. For exam…
224 A required pass is a pass that may not be skipped. An example of a required
225 pass is ``AlwaysInlinerPass``, which must always be run to preserve
226 ``alwaysinline`` semantics. Pass managers are required since they may contain
229 An example of how a pass can be skipped is the ``optnone`` function
239 LLVM provides a mechanism to register pass plugins within various tools like
240 ``clang`` or ``opt``. A pass plugin can add passes to default optimization
254 The pass must provide at least one of two entry points for the new pass manager,
260 Pass plugins are compiled and linked dynamically by default. Setting
266 To make ``PassBuilder`` aware of statically linked pass plugins:
280 To make ``PassBuilder`` aware of dynamically linked pass plugins: