Using standalone tools
We can also exercise the compilation workflow described previously through the usage of LLVM standalone tools, linking the output of one tool into the output of another. Although this slows downs the compilation due to the use of the disk to write intermediary files, it is an interesting didactic exercise to observe the compilation pipeline. This also allows you to fine-tune the parameters given to intermediary tools. Some of these tools are as follows:
opt
: This is a tool that is aimed at optimizing a program at the IR level. The input must be an LLVM bitcode file (encoded LLVM IR) and the generated output file must have the same type.llc
: This is a tool that converts the LLVM bitcode to a target-machine assembly language file or object file via a specific backend. You can pass arguments to select an optimization level, to turn on debugging options, and to enable or disable target-specific optimizations.llvm-mc
: This tool is able to assemble instructions and generate...