[LLVMdev] DIFactory interface is going away

Devang Patel dpatel at apple.com
Fri Feb 25 09:35:21 PST 2011


On Feb 25, 2011, at 8:57 AM, Duncan Sands wrote:

> Hi Devang,
> 
>>> It does make me wonder how you are supposed to represent types which cannot
>>> be properly represented by LLVM types, for example structs with fields at
>>> variable offsets from the start and/or of variable size; or structs with
>>> fields that may or may not be present depending on the value of other fields.
>>> Such types occur in Ada for example.
>> 
>> The metadata constructs used to encode debugging information do not use (or refer) LLVM types directly.  Here is the interface to emit debug info for a member.
> 
> thanks for the explanation.
> 
>> 
>>     /// createMemberType - Create debugging information entry for a member.
>>     /// @param Name         Member name.
>>     /// @param File         File where this member is defined.
>>     /// @param LineNo       Line number.
>>     /// @param SizeInBits   Member size.
> 
> For Ada this needs to be a Value* since it is dynamic.

It would be very easy to add createAdaMemberType(...). After all it does is create a MDNode using the arguments. Once you have the MDNode, it will survive all the way through all LLVM phases until the end where DWARF entries are emitted. So only thing you need is understanding of how to emit it in DWARF in such cases.

-
Devang

>  But presumably this
> interface is a direct mapping to the Dwarf specification, i.e. Dwarf itself
> has no way of encoding a variable size here?
> 
>>     /// @param AlignInBits  Member alignment.
>>     /// @param OffsetInBits Member offset.
> 
> This is likewise dynamic in general.
> 
>>     /// @param Flags        Flags to encode member attribute, e.g. private
>>     /// @param Ty           Parent type.
>>     DIType createMemberType(StringRef Name, DIFile File,
>>                             unsigned LineNo, uint64_t SizeInBits,
>>                             uint64_t AlignInBits, uint64_t OffsetInBits,
>>                             unsigned Flags, DIType Ty);
>> 
>> 
>> Of course,  the FE needs to know the offset, size, alignment etc... for each field as per source language. The Parent type here is also debug info entry for the enclosing structure/class. Regarding variable size fields, I am not sure how they are encoded in DWARF.
> 
> GCC outputs some language specific Dwarf tags for Ada, perhaps to handle these
> kinds of mad types.
> 
> Ciao, Duncan.





More information about the llvm-dev mailing list