-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learn LLVM 12
By :
A Pass can perform arbitrary complex transformations on the LLVM IR. To illustrate the mechanics of adding a new Pass, our new Pass only counts the number of IR instructions and basic blocks. We name the Pass countir. Adding the Pass to the LLVM source tree or as a standalone Pass differs slightly, so we will do both in the following sections. Let's begin by adding a new Pass to the LLVM source tree.
Let's start by adding the new Pass to the LLVM source. This is the right approach if we later want to publish the new Pass in the LLVM tree.
The source of Passes that perform transformations on the LLVM IR is located in the llvm-project/llvm/lib/Transforms folder, and the header files are in the llvm-project/llvm/include/llvm/Transforms folder. Because there are so many Passes, they are sorted into subfolders after the category they fit in.
For our new Pass, we create a new folder...