[LLVMdev] More metadata questions
Devang Patel
dpatel at apple.com
Mon Nov 8 09:39:57 PST 2010
On Nov 7, 2010, at 6:43 AM, guyadini wrote:
>
> Hi,
>
> I hope I'm not too annoying with my newbie questions.
> I've read the new (great!) wiki about the DI* classes, and I still can't
> figure out how to insert metadata into the LLVM IR.
>
> Let's say that I want to have two passes, one that creates some metadata
> string and inserts it into the IR, and the second one that reads it and acts
> according to what it finds (or doesn't find).
>
> Are the DI* classes the right way to go?
> Or should I use MDString, etc?
DI* classes are only for debug info processing. You should use MDString, MDNode etc... directly from metadata.h
> Either way, I've found lots of ways to define them, but not the right way to
> actually get them to be where I want them in the IR.
Right now, there are three ways:
1) Create independent MDNodes (just like Constants).
2) Use as an operands in intrinsics
3) Attached to an instruction
http://blog.llvm.org/2010/04/extensible-metadata-in-llvm-ir.html blog post covers these three using debugging information as an example.
How do you intend to use metadata ?
-
Devang
More information about the llvm-dev
mailing list