[llvm-commits] [llvm] r72610 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli docs/LangRef.html include/llvm/Bitcode/LLVMBitCodes.h include/llvm/Constants.h include/llvm/MDNode.h include/llvm/Type.h lib/AsmParser/LLLexer.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/Transforms/Utils/ValueMapper.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Constants.cpp lib/VMCore/Type.cpp lib/VMCore/Verifier.cpp test/Feature/embeddedmetadata.ll unittests/VMCore/MetadataTest.cpp

Nick Lewycky nicholas at mxc.ca
Sat May 30 09:08:44 PDT 2009


Duncan Sands wrote:
> Hi Nick,
> 
>> +<p>The metadata type represents embedded metadata. The only derived type that
>> +may contain metadata is <tt>metadata*</tt> or a function type that returns or
>> +takes metadata typed parameters, but not pointer to metadata types.</p>
> 
> why aren't pointers to metadata allowed for function parameters?

Because metadata has no address to point to. The real question is why do 
we permit pointers to metadata at all.

The only permissible use of metadata* is the type of a GlobalVariable 
whose initializer is an MDNode or MDString.

So then, we could permit passing the global variable into a function as 
a parameter, but I don't forsee any use for this. The only functions 
that are allowed to take/return metadata at all are intrinsic functions 
and when generating the intrinsic you could just pass in the MDNode 
itself instead of a global variable with an MDNode intrinsic.

That said, if the use case ever did come up I wouldn't object to adding it.

>>    <dd>A metadata node is a structure-like constant with the type of an empty
>> -  struct.  For example: "<tt>{ } !{ i32 0, { } !"test" }</tt>". Unlike other
>> -  constants that are meant to be interpreted as part of the instruction stream,
>> -  metadata is a place to attach additional information such as debug info.
>> +  struct. 
> 
> I thought the type was no longer that of an empty struct, but here it
> says it is...  Also, I didn't notice any mention of pointers to metadata
> in these docs.

Oops! Fixed, thanks!

>>  <p>A metadata node will attempt to track changes to the values it holds. In
>>  the event that a value is deleted, it will be replaced with a typeless
>> -"<tt>null</tt>", such as "<tt>{ } !{null, i32 0}</tt>".</p> 
>> +"<tt>null</tt>", such as "<tt>metadata !{null, i32 10}</tt>".</p> 
> 
> Does this part belong in the LangRef?

We need to mention the typeless null since it's part of the .ll syntax. 
It seems natural to mention the important part of MDNodes -- the ability 
to track values -- at the same time.

Nick




More information about the llvm-commits mailing list