Adding comments to LLVM IR during code generation

Hello all,

this is “frivolous”, and I understand that there are good reasons as to why the IR representation does not have a representation for comments (unless I am mistaken).

However, I would really like to have the ability to generate comments along with LLVM IR from my compiler backend.

It would greatly help in debugging LLVM.

Since I cannot generate comments, what alternatives to I have to allow me to quickly add info the the IR that is easy to scan over?

Cheers,
~Siddhart.

Today, you can use inline asm with side effects to emit comments bracketing the code you care about. Of course, optimizations will move instructions past these markers as normal, but presumably that’s working as intended.