Creating a pass
The legacy and the new pass managers have different ways of creating passes. In this section, you will learn how to achieve that task with both frameworks.
In both cases, you will see that you must provide the three main bits of information that the related pass manager needs to perform its task:
- What is the scope of a pass?
- What analyses does this pass depend on?
- What effect does this pass have on the input IR?
Let us see how you can provide this information, starting with the legacy pass manager.
Writing a pass for the legacy pass manager
As already mentioned, there are three things that a pass needs to provide for the pass manager to do its job. Depending on what your pass does, some parts may be optional because the default implementation may do what you want. You will find what the default implementation is in the related sections later in the chapter.
Now, let us start with how to specify the scope of your pass...