Generic passes worth mentioning
Among the passes that the CodeGen library offers, we wanted to go over the CodeGenPrepare, PeepholeOptimizer, and MachineCombiner passes because they bring something that may not be obvious at first, are particularly useful, and require some backend work to leverage.
The last point is true for most CodeGen passes, but these are less useful than the other ones if you don’t put in some work.
Let’s start with the CodeGenPrepare pass.
The CodeGenPrepare pass
Despite being part of the CodeGen library, the CodeGenPrepare pass is an LLVM-IR-to-LLVM-IR pass. This pass is responsible for papering over some of the limitations of the legacy instruction selector called SelectionDAG. We’ll cover this in more detail in the next chapter, but at this point, the key takeaway is that you may have to perform some transformations at the LLVM IR level for this selector to produce the best possible code.
Among other things, the CodeGenPrepare...