Adding a new machine function pass to LLVM
In this section, we will explore how to implement a new machine function pass within LLVM that runs after instruction selection. Specifically, a MachineFunctionPass
class will be created, which is a subset of the original FunctionPass
class within LLVM that can be run with opt
. This class adapts the original infrastructure to allow for the implementation of passes that operate on the MachineFunction
representation in the backend through llc
.
It is important to note that the implementation of passes within the backend utilizes the interfaces of the legacy pass manager, rather than the new pass manager. This is because LLVM currently does not have a complete working implementation of the new pass manager within the backend. Due to this, this chapter will follow the method of adding a new pass within the legacy pass manager pipeline.
In terms of the actual implementation, such as function passes, machine function passes optimize a single...