I require metadata information for my analysis pass. Therefore, I created an LLVM IR file without the optimization flag. Once the analysis is complete, my analyzer produces a new IR file that has been instrumented. Finally, I optimized the generated IR file using opt -O3. However, the optimization process does not remove the metadata (debugging information), so I am wondering how to remove the metadata from the IR file.
Furthermore, I am curious whether the LLVM IR file with appended metadata affects performance during execution. To the best of my knowledge, it seems not, but I have not thoroughly tested it.
Using the opt tool with option -strip-debug will read in an LLVM-IR file, strip any debug info, then write out a new LLVM-IR file, for example:
opt input.ll -strip-debug -o output.ll -S
Will read in input.ll and write to output.ll after the debug-info is removed.
Furthermore, I am curious whether the LLVM IR file with appended metadata affects performance during execution. To the best of my knowledge, it seems not, but I have not thoroughly tested it.
For very large inputs compilation can be substantially slower, although it depends on the metadata and how much there is of it. For debug-info it can range anywhere from five to 30 percent performance cost; I believe other metadata is much more lightweight, although Iām not very familiar with the other metadata.
The time to compile the code may suffer with debug info. The generated code, however, is supposed to be identical with and without debug info. So, runtime performance of the compiled program should be the same.