Metadata in the backend

Hi all,

I’m looking for a way to insert metadata into an instruction/function/basic-block in the IR level, and afterwards reading it in the backend (ARM to be exact).

So my questions are:

  1. Does/can the metadata in the IR survive the code-generator in some way?

  2. Is there a general of ‘communication’ between the optimizer and the backend?

Thanks!

Alon

Hi Alon,

There is no good mapping between IR-level instructions and MachineInstructions because we don’t do a 1:1 translation. We delete instructions and create new ones. Some of the memory operations hold references to the original IR pointer, but we drop this information in many places. We also delete or generate new basic blocks, so you can’t rely on that. However, from the MachineFunction you can access the original IR and access some metadata (which you can place on the terminator of the first basic block of something). I am not sure how much information you want to communicate between the IR-level passes and the backend, but you can introduce new intrinsics that can be lowered to pseudo instructions.

Thanks,
Nadav