Textual versus binary format
As already mentioned at the beginning of this chapter, the LLVM IR supports two formats: textual or human-readable and binary, also known as bitcode.
Aside from being more compact, the bitcode format offers some backward properties, meaning that a bitcode file created with an older version of LLVM will work with a new version of LLVM. There is no such guarantee for the textual format. What this means is that in theory, the human-readable syntax of LLVM IR can change all the time and IR written in the past may not work with a parser from a newer LLVM. In practice, the textual format is relatively stable but still breaks from time to time. When this happens, you can leverage the backward properties of the bitcode format by doing the following:
- Saving your textual IR to bitcode using
opt
from the old LLVM - Loading your bitcode file using
opt
from the new LLVM and saving the output in textual format
This process is illustrated...