Using llvm Metadata inside llc

Is there any way to work with the metadata inside llc? Or is there a specific reason why metadata is not supported inside llc? Because as I see it the metadata get’s completely removed during instruction selection.

I would like to use the metadata to influence Loop Specific transformations and if-conversion.

Kind Regards
Michael D’hont

There's some support for metadata on MI and definitely on the IR. What
do you have in mind and what are you doing?

-eric

The project I am working on is to use the llvm toolchain for embedded CGRA processors .
This however poses some restrictions on the block formation, because modulo scheduling is applied in a later stage.
For this reason the idea was to create custom pragma’s to generate metadata and attach it to de branches of loops we wanted to map on a cgra module.
It is a lot similar to the loop parallell metadata discussed previously on the mailing list.
I was able to made the metadata survive opt passes by extending LoopInfo to remove/restore metadata as needed but once at the backend I get stuck.

I was thinking to add some custom fields to SDNode and afterwards MI but that doesn’t seem efficient (or a good idea) for many reason’s.
For example not each instruction has metadata attached (in my case it’s only branching instructions inside a loop) and also during the pattern matching nodes are replaced/combined/etc. and thus the data also gets removed.

I need the information within the metadata to force if-conversion on specific parts of the code for hyperblock formation.

Hi

As i didn’t get any respons I am reformulating my question in the hope to make myself more clear.
Has anyone an idea how to use metadata present in the llvm ir to guide the if-conversion in llc (as metadata get’s dropped during SelectionDAG) ?

-Michael

Some time ago the only way to get back to the LLVM IR metadata from
the machine level was via MemoryOperands. I do not know if this has
changed or not, but I suppose the problem is that the LLVM IR and the
MachineInstructions are of course not a 1:1 match, so retaining the data
in the general case is difficult.

What we have used in similar needs are "pseudo asm blocks" (or
perhaps custom instrinsics could work here) which are used
to transfer information up from the source level down to the code generation.
Those were simply inline asm blocks with some magical strings inside. So
maybe you can add such an asm block to the basic block with the branch you
want to if-convert.