[cfe-dev] [LLVMdev] Function-level metadata for OpenCL (was Re: OpenCL support)

Devang Patel dpatel at apple.com
Mon Jan 10 11:59:28 PST 2011

>>>> Being discardable is a design point of metadata. You might add something
>>>> else to support this, but it won't be metadata.
>>> There's nothing intrinsic about the concept of metadata which requires
>>> it to be discardable.  

Metadata objects (MDNode, NamedMDNode etc.. ) are containers. They are always available if you keep track of anchors to find them. The optimizer does not know that they exists and you should design your use-case accordingly. The only thing discardable about metadata is the llvm values being put into these metadata containers. 

For example, if you're using a MDNode M1 to keep track of a parameter P1 then P1 can disappear any time because the optimizer does not know that M1 is "using" P1. That's by design. In this situation, the corresponding M1 element will automatically turn to null and the users of the M1 should be able to handle that. If the optimizer replaces P1 with new parameter P2 then the M1 will automatically update itself.


More information about the cfe-dev mailing list