[LLVMdev] Associating types directly with debug metadata?

Pekka Nikander pekka.nikander at nomadiclab.com
Thu Sep 30 01:30:48 PDT 2010


>>> Would the right starting point be to simply add an MDNode pointer to the Type class?  That should be then convertible to a DIType?  
>> 
>> We want to avoid any Type class modification. Instead you can use pair in named metadata to match metadata with type.
>> 
>> !11 = metadata !{i32 524307, metadata !1, metadata !"T", metadata !1, i32 2, i64 32, i64 32, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_structure_type ]
>> 
>> !21 = metadata !{ metadata !11,  %struct.T %z}
>> 
>> !llvm.my_special_type_info = !{!21}
> 
> Ok, that approach should work.  Though we want to associate the type, not some variable with the type, i.e. something like
> 
> !21 = metadata !{ %struct.T, metadata !11 }
> 
> But I don't know if that would be valid syntax...  

I thought about that more, and I think the "right" way would be to have a syntax like

!21 = metadata !{ type %struct.T, metadata !11 } 

or perhaps

!21 = metadata !{ typeval %struct.T, metadata !11 }

to avoid the problem with the keyword 'type'.

But to be able to do that, should apparently be possible to represent types as first class values.  That in turn would apparently require a new Type::TypeID?

Would that be worth doing?  Apparently we can fake with our need, and use a null pointer instead.  Technically, that would be wrong, but would work with the current code without any modifications:

!21 = metadata !{ %struct.T *null, metadata !11 }

Any opinions?  (I guess I'll just try the number of changes needed for a 'typeval' and report back.)

--Pekka





More information about the llvm-dev mailing list