LLVM Metadata from Pass to Backend optimization

Hello,

I am new in the LLVM infrastructure and I want to write a pass which creates extra information for each instruction. This information is going to be used by a back-end optimization. I am thinking
of using the Metadata structure to pass the data from the Analysis Pass to the Back end. Is this the correct methodology? Or should I use another mechanism?

Konstantinos Parasyris.

Hello,

I am new in the LLVM infrastructure and I want to write a pass which creates extra information for each instruction. This information is going to be used by a back-end optimization. I am thinking
of using the Metadata structure to pass the data from the Analysis Pass to the Back end. Is this the correct methodology? Or should I use another mechanism?

If a MachineFunctionPass can require a "regular" LLVM pass (such as a FunctionPass or ModulePass), then I would simply write the pass which creates the extra information as an LLVM analysis pass and give it methods which the MachineFunctionPass can use to query the extra information. This ensures that transformations between the time you do the analysis and the time you do code generation don't invalidate your results.

If that's too difficult, then I think adding Metadata would work. It's just not the approach I'd take.

Regards,

John Criswell