[llvm] r192618 - Debug Info: static member DIE creation.

Manman Ren manman.ren at gmail.com
Mon Oct 14 16:13:19 PDT 2013


On Mon, Oct 14, 2013 at 1:46 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
>
> On Mon, Oct 14, 2013 at 1:33 PM, Manman Ren <manman.ren at gmail.com> wrote:
>
>> Author: mren
>> Date: Mon Oct 14 15:33:57 2013
>> New Revision: 192618
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=192618&view=rev
>> Log:
>> Debug Info: static member DIE creation.
>>
>> Clean up creation of static member DIEs.
>
>
> What was the motivation for this change? I've a sneaking suspicion this
> would be a crash not unlike some of the other member-adding code that I was
> playing with a week or two ago. If that's the case, a test case would be
> appropriate.
>

No, I don't see a crash. But I think this is cleaner and it is similar to
how we handle subprograms.
For a DIE that we try to construct in multiple places, using getOrCreate is
cleaner.

Manman


>
>
>> We can create static member DIEs from
>> two places, so we call getOrCreateStaticMemberDIE from the two places.
>>
>> getOrCreateStaticMemberDIE will get or create the context DIE first, then
>> it
>> will check if the DIE already exists, if not, we create the static member
>> DIE
>> and add it to the context.
>>
>> Creation of static member DIEs are handled in a similar way as subprogram
>> DIEs.
>>
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=192618&r1=192617&r2=192618&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Oct 14
>> 15:33:57 2013
>> @@ -1112,11 +1112,13 @@ void CompileUnit::constructTypeDIE(DIE &
>>            ElemDie = new DIE(dwarf::DW_TAG_friend);
>>            addType(ElemDie, resolve(DDTy.getTypeDerivedFrom()),
>>                    dwarf::DW_AT_friend);
>> -        } else if (DDTy.isStaticMember())
>> -          ElemDie = createStaticMemberDIE(DDTy);
>> -        else
>> +          Buffer.addChild(ElemDie);
>> +        } else if (DDTy.isStaticMember()) {
>> +          ElemDie = getOrCreateStaticMemberDIE(DDTy);
>> +        } else {
>>            ElemDie = createMemberDIE(DDTy);
>> -        Buffer.addChild(ElemDie);
>> +          Buffer.addChild(ElemDie);
>> +        }
>>        } else if (Element.isObjCProperty()) {
>>          DIObjCProperty Property(Element);
>>          ElemDie = new DIE(Property.getTag());
>> @@ -1454,11 +1456,7 @@ void CompileUnit::createGlobalVariableDI
>>    if (SDMDecl.Verify()) {
>>      assert(SDMDecl.isStaticMember() && "Expected static member decl");
>>      // We need the declaration DIE that is in the static member's class.
>> -    // But that class might not exist in the DWARF yet.
>> -    // Creating the class will create the static member decl DIE.
>> -    getOrCreateContextDIE(resolve(SDMDecl.getContext()));
>> -    VariableDIE = getDIE(SDMDecl);
>> -    assert(VariableDIE && "Static member decl has no context?");
>> +    VariableDIE = getOrCreateStaticMemberDIE(SDMDecl);
>>      IsStaticMember = true;
>>    }
>>
>> @@ -1819,12 +1817,24 @@ DIE *CompileUnit::createMemberDIE(DIDeri
>>    return MemberDie;
>>  }
>>
>> -/// createStaticMemberDIE - Create new DIE for C++ static member.
>> -DIE *CompileUnit::createStaticMemberDIE(const DIDerivedType DT) {
>> +/// getOrCreateStaticMemberDIE - Create new DIE for C++ static member.
>> +DIE *CompileUnit::getOrCreateStaticMemberDIE(const DIDerivedType DT) {
>>    if (!DT.Verify())
>>      return NULL;
>>
>> -  DIE *StaticMemberDIE = new DIE(DT.getTag());
>> +  // Construct the context before querying for the existence of the DIE
>> in case
>> +  // such construction creates the DIE.
>> +  DIE *ContextDIE = getOrCreateContextDIE(resolve(DT.getContext()));
>> +  assert(ContextDIE && "Static member should belong to a non-CU
>> context.");
>> +
>> +  DIE *StaticMemberDIE = getDIE(DT);
>> +  if (StaticMemberDIE)
>> +    return StaticMemberDIE;
>> +
>> +  StaticMemberDIE = new DIE(DT.getTag());
>> +  // Add to context owner.
>> +  ContextDIE->addChild(StaticMemberDIE);
>> +
>>    DIType Ty = resolve(DT.getTypeDerivedFrom());
>>
>>    addString(StaticMemberDIE, dwarf::DW_AT_name, DT.getName());
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=192618&r1=192617&r2=192618&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Mon Oct 14
>> 15:33:57 2013
>> @@ -329,8 +329,8 @@ private:
>>    /// createMemberDIE - Create new member DIE.
>>    DIE *createMemberDIE(DIDerivedType DT);
>>
>> -  /// createStaticMemberDIE - Create new static data member DIE.
>> -  DIE *createStaticMemberDIE(DIDerivedType DT);
>> +  /// getOrCreateStaticMemberDIE - Create new static data member DIE.
>> +  DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
>>
>>    /// getLowerBoundDefault - Return the default lower bound for an
>> array. If the
>>    /// DWARF version doesn't handle the language, return -1.
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131014/7a91d8fe/attachment.html>


More information about the llvm-commits mailing list