Let’s say I want to annotate a C statement, let it be the simplest assignment
int i = 3. At the IR, this is straightforward as we can attach a MDNode to the IR instruction representing the assignment. But I need to be able to propagate the annotation to the binary ELF file. AFAIK, there is no mechanism to do so in the backend. Is there any particular reason to not support some sort of MIR annotation in the backend? Or is it purely because of manpower?
Thank you for your advice
I suspect the instruction-level annotations that exist (such as source location) are the ones that people needed in order to get something done. If you want to do something new, you will likely need a new kind of annotation.
Obviously the debug-info metadata survives through code generation, so you could use that as a model. One caution: preserving the debug info requires a lot of attention from the optimization passes (we have loads of bugs in this department) so it seems quite likely that a new kind of annotation would require similar attention.