Reducing the input IR size
One of the challenges that you’ll face as a compiler writer is wrestling with the complexity of the input IR.
While sometimes there’s nothing you can do about it, at the end of the day, you must compile what the user asked for. When performing certain tasks, it’s desirable to scale this complexity back. One effective way to do this is by reducing the input IR size.
The LLVM infrastructure offers several tools that you can use to reduce the input IR size.
The first one is a tool that can be used to extract a subset of the input IR.
Extracting a subset of the input IR
The llvm-extract
tool is a command-line tool that allows us to extract pieces of the input IR and create a new standalone module from it.
For instance, let’s assume that we have thousands of lines of IR in an input module, but we’re only interested in one function.
Naively copy-pasting the IR of the function may not be enough because...