[LLVMdev] PROPOSAL : Introduce NamedMetadata

Devang Patel devang.patel at gmail.com
Tue Jul 28 10:52:38 PDT 2009


On Mon, Jul 27, 2009 at 10:16 PM, Nick Lewycky<nicholas at mxc.ca> wrote:
> Devang Patel wrote:
>> On Mon, Jul 27, 2009 at 9:31 PM, Nick Lewycky<nicholas at mxc.ca> wrote:
>>
>>> Why not have a named GlobalValue with an MDNode initializer? How is this
>>> different from what we had before?
>>
>> GlobalValue initializer accepts only Constants.
>
> So in my initial implementation, before I submitted it for review, I
> tried making them not be Constants, only to discover that if I did that
> then I couldn't use then as GV initializers.
>
> And it's not preposterous for them to be Constants. Functions are an
> example of a nameable zero-operand non-uniqued constant.
>
> Is there any particular benefit to keeping them out of Constant and
> adding NamedMetadata?

There are many reasons why MDNodes are not Constant. Metadata can be recursive.
Metadata can refer to instructions, basic blocks or any other
non-Constant Values. Metadata are not stored in the Module directly.
However, someone may want to maintain a collection of selected MDNodes
in a module. And that's where NamedMetadata is used.

I like Dan's suggestion to not inherit NamedMetadata from constant.
-
Devang



More information about the llvm-dev mailing list