[llvm] r190190 - Debug Info: Use identifier to reference DIType in containing type field of

Manman Ren manman.ren at gmail.com
Fri Sep 6 14:12:02 PDT 2013


On Fri, Sep 6, 2013 at 12:54 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
>
> On Fri, Sep 6, 2013 at 12:02 PM, Manman Ren <manman.ren at gmail.com> wrote:
>
>>
>>
>>
>> On Fri, Sep 6, 2013 at 11:53 AM, David Blaikie <dblaikie at gmail.com>wrote:
>>
>>>
>>>
>>>
>>> On Fri, Sep 6, 2013 at 11:46 AM, Manman Ren <manman.ren at gmail.com>wrote:
>>>
>>>> Author: mren
>>>> Date: Fri Sep  6 13:46:00 2013
>>>> New Revision: 190190
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=190190&view=rev
>>>> Log:
>>>> Debug Info: Use identifier to reference DIType in containing type field
>>>> of
>>>> a DICompositeType.
>>>>
>>>> Verifier is updated accordingly.
>>>>
>>>> Added:
>>>>     llvm/trunk/test/DebugInfo/tu-composite.ll
>>>> Modified:
>>>>     llvm/trunk/include/llvm/DebugInfo.h
>>>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>>>>     llvm/trunk/lib/IR/DIBuilder.cpp
>>>>     llvm/trunk/lib/IR/DebugInfo.cpp
>>>>
>>>> Modified: llvm/trunk/include/llvm/DebugInfo.h
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo.h?rev=190190&r1=190189&r2=190190&view=diff
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/include/llvm/DebugInfo.h (original)
>>>> +++ llvm/trunk/include/llvm/DebugInfo.h Fri Sep  6 13:46:00 2013
>>>> @@ -358,8 +358,8 @@ namespace llvm {
>>>>      void setTypeArray(DIArray Elements, DIArray TParams = DIArray());
>>>>      void addMember(DIDescriptor D);
>>>>      unsigned getRunTimeLang() const { return getUnsignedField(11); }
>>>> -    DICompositeType getContainingType() const {
>>>> -      return getFieldAs<DICompositeType>(12);
>>>> +    DITypeRef getContainingType() const {
>>>> +      return getFieldAs<DITypeRef>(12);
>>>>      }
>>>>      void setContainingType(DICompositeType ContainingType);
>>>>      DIArray getTemplateParams() const { return
>>>> getFieldAs<DIArray>(13); }
>>>>
>>>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=190190&r1=190189&r2=190190&view=diff
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
>>>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Fri Sep  6
>>>> 13:46:00 2013
>>>> @@ -1083,7 +1083,7 @@ void CompileUnit::constructTypeDIE(DIE &
>>>>      if (CTy.isAppleBlockExtension())
>>>>        addFlag(&Buffer, dwarf::DW_AT_APPLE_block);
>>>>
>>>> -    DICompositeType ContainingType = CTy.getContainingType();
>>>> +    DICompositeType
>>>> ContainingType(DD->resolve(CTy.getContainingType()));
>>>>      if (DIDescriptor(ContainingType).isCompositeType())
>>>>        addDIEEntry(&Buffer, dwarf::DW_AT_containing_type,
>>>> dwarf::DW_FORM_ref4,
>>>>                    getOrCreateTypeDIE(DIType(ContainingType)));
>>>>
>>>> Modified: llvm/trunk/lib/IR/DIBuilder.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=190190&r1=190189&r2=190190&view=diff
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/lib/IR/DIBuilder.cpp (original)
>>>> +++ llvm/trunk/lib/IR/DIBuilder.cpp Fri Sep  6 13:46:00 2013
>>>> @@ -626,7 +626,7 @@ DICompositeType DIBuilder::createClassTy
>>>>      DerivedFrom,
>>>>      Elements,
>>>>      ConstantInt::get(Type::getInt32Ty(VMContext), 0),
>>>> -    VTableHolder,
>>>> +    DIType(VTableHolder).generateRef(),
>>>>
>>>
>>> Could we make the VTableHolder parameter a DIType so we don't need to
>>> cast here (& improve the type-correctness of this function)?
>>>
>> I will try.
>>
>>>
>>>
>>>>      TemplateParams,
>>>>      UniqueIdentifier.empty() ? NULL : MDString::get(VMContext,
>>>> UniqueIdentifier)
>>>>    };
>>>> @@ -663,7 +663,7 @@ DICompositeType DIBuilder::createStructT
>>>>      DerivedFrom,
>>>>      Elements,
>>>>      ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
>>>> -    VTableHolder,
>>>> +    DIType(VTableHolder).generateRef(),
>>>>
>>>
>>> and here.
>>>
>>>
>>>>      NULL,
>>>>      UniqueIdentifier.empty() ? NULL : MDString::get(VMContext,
>>>> UniqueIdentifier)
>>>>    };
>>>>
>>>> Modified: llvm/trunk/lib/IR/DebugInfo.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=190190&r1=190189&r2=190190&view=diff
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/lib/IR/DebugInfo.cpp (original)
>>>> +++ llvm/trunk/lib/IR/DebugInfo.cpp Fri Sep  6 13:46:00 2013
>>>> @@ -497,7 +497,7 @@ bool DICompositeType::Verify() const {
>>>>    // Make sure DerivedFrom @ field 9 and ContainingType @ field 12 are
>>>> MDNodes.
>>>>    if (!fieldIsMDNode(DbgNode, 9))
>>>>      return false;
>>>> -  if (!fieldIsMDNode(DbgNode, 12))
>>>> +  if (!fieldIsTypeRef(DbgNode, 12))
>>>>      return false;
>>>>
>>>>    // Make sure the type identifier at field 14 is MDString, it can be
>>>> null.
>>>> @@ -721,7 +721,7 @@ DITypeRef DIType::generateRef() {
>>>>  /// \brief Set the containing type.
>>>>  void DICompositeType::setContainingType(DICompositeType
>>>> ContainingType) {
>>>>    TrackingVH<MDNode> N(*this);
>>>> -  N->replaceOperandWith(12, ContainingType);
>>>> +  N->replaceOperandWith(12, ContainingType.generateRef());
>>>>    DbgNode = N;
>>>>  }
>>>>
>>>>
>>>> Added: llvm/trunk/test/DebugInfo/tu-composite.ll
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/tu-composite.ll?rev=190190&view=auto
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/test/DebugInfo/tu-composite.ll (added)
>>>> +++ llvm/trunk/test/DebugInfo/tu-composite.ll Fri Sep  6 13:46:00 2013
>>>>
>>>
>>> Did we not have any tests already covering this functionality? or that
>>> could be extended to do so? We generally try not to add new test cases if
>>> there's a good home to cover the functionality already.
>>>
>> The problem is that we have testing cases that refer to a DIType via
>> MDNode, but we don't have testing cases that refer to a DIType via the
>> identifier (MDString).
>> Right now, we support both type references.
>>
>> To verify that MDString works as a type reference, I added these new
>> testing cases.
>>
>> Let me know if we can avoid that.
>>
>
> We could beef up the verifier to /require/ that any type referenced that
> has an identifier should be referenced with that identifier (& do this on a
> per-TypeRef-enabled field, of course - essentially is the "isTypeRef"
> check, check if the target has an identifier & in that case fail if it's
> not using that identifier as the typeref). Then we'd find all the test
> cases that should be exercising this functionality & aren't - update those
> to use the identifier & now the're actually covering the real production
> codepath rather than a valid, but less useful one.
>
Right now, the existing testing cases all have the identifier field as
NULL. To reuse the existing testing cases, we should first set some of the
identifier to non-null.

Then we can start using the identifier as a type reference. I will see how
hard it is.

Manman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130906/f00115cb/attachment.html>


More information about the llvm-commits mailing list