First up, I am a newbie to LLVM passes.
I am trying to add metadata to instructions in LLVM after a transformation pass (with the C++ API). I intend to store this information for use by another tool in a tool chain. I have two questions regarding this.
I expect the information I store as metadata to feed into another tool which works on the LLVM IR. So is metadata a good idea ? I intend to store strings as metadata with some instructions.
If metadata is the right way to go here, I need some help creating a metadata node. I plan to use the setMedata() function to attach it to an instruction. Which variant of setMetadata() is the right one to use. I am not sure which MDKind should my data be of. I want to create a MDString, attach it to my MDNode and then call setMetadata() with an instruction. What Context should I use in the setMedata(), if I want to attach the metadata to an instruction inside a function. What is the relevance of context to metadata?
I tried reading up a lot of discussions in forums and the llvm doxygen docs but I did not get a clear and complete answer to all my questions. I appreciate your help or some material that could help me understand this.