[llvm] r191792 - Debug Info: remove duplication of DIEs when a DIE is part of the type system

David Blaikie dblaikie at gmail.com
Thu Oct 3 11:38:54 PDT 2013


On Thu, Oct 3, 2013 at 11:26 AM, Manman Ren <manman.ren at gmail.com> wrote:

>
>
>
> On Wed, Oct 2, 2013 at 5:55 PM, Eric Christopher <echristo at gmail.com>wrote:
>
>> >
>> >>
>> >> I would like to revisit this (maybe revert this) later on when type
>> units
>> >> are working.
>> >
>> >
>> > I'd rather revert this before type units (& then revisit this
>> afterwards) as
>> > it may complicate the type unit work. I think the extra benefit (using
>> > direct ref_addr, rather than signatures) of this approach over type
>> units
>> > may be implementable via an incremental improvement to type units.
>> >
>>
>> FWIW I've been following along with the thread and agree here. David
>> is actively working on type units and we should have something here
>> shortly. Let's let that work proceed and revert this for now.
>>
>
> I think we do agree that this approach has some extra benefit (using
> direct ref_addr, rather than signatures) over type units.
> The type-unit work can achieve what this approach does in removing DIE
> duplication, but using signatures rather than ref_addr.
> It may be possible to get the extra benefit via an incremental improvement
> to type units, but we are not certain about that.
>

Agreed.


>
> I also want to emphasize this patch after wrapping up CU::getDIE as David
> sugggested is not big, the list of changes can be found at the end of this
> email.
>

I don't quite understand this. The list of changes looks incomplete (the
insert*DIE functions in DwarfDebug and the maps they use, etc, are not
shown here) - are you describing this as "changes" as distinct from
"additions"? Even adding completely new code comes at a maintenance burden
that should be weighed against the value added.

& this doesn't look like how I would expect the code to look after my
suggestion (for one thing, I think I was suggesting having one map in
DwarfDebug, rather than one per kind of thing - and simply having getDIE
(and insertDIE, for that matter) delegate based on a list of known tag
types that should be cross-CU versus CU-local)


> I don't quite get the complication caused by this approach to type units.
> When we start constructing a DIE for a type MDNode, we either use the type
> unit or we use
> the standard approach  of creating a DIE, my changes touch the standard
> approach a little by moving the map from CU to DwarfDebug.
>

Yep, it might come out this cleanly, though I'm a little cautious about
putting all these things in together then trying to clean it up/evaluate
the changes appropriately.


> When referring to the type, we either use ref_signature or ref_addr or
> ref4.
>
> Even after type units start working, people can still choose to use either
> type units or ref_addr|ref4 for a period of time before their tool chains
> are updated to support type units.
> As for the tool chains, extra time may be required to set up a map from
> the type signature to the actual address in the Dwarf.
>

Certainly - as I said, I don't doubt your change has some value over type
units. There's a question as to how much value and how best to fit it in,
if we do, to the existing code.


> The performance improvement of this patch is kind of straight-forward, if
> we have X CUs refer to the same type MDNode, X copies of type DIEs will be
> created
> without this patch.
>

Yes, I agree that it has value.


> I do have some numbers collected before, I will dig that out.
>

Thanks, that'd be very helpful.

(but I'm also particularly interested in how much value this has over type
units - which is one reason I'd like to do this after type units, either
that or we'll need to add flags or somesuch to disable this optimization so
we can compare type units with and without this change)

The other problem is that removing these patches will be somewhat more
difficult after I've spent the next couple of weeks cleaning code up and
adding in type units. I think there's enough design discussion to have with
regards to how best to implement your feature that I'd rather have that
design discussion on top of type units rather than the other way around -
though it's possible we can come to a reasonable/good design in either
order.


>
> Thanks,
> Manman
>
>  15 -  insertDIE(Ty, TyDIE);
>  16 +  DD->insertTypeDIE(Ty, TyDIE);
>
>  31 -  insertDIE(SP, SPDie);
>  32 +  DD->insertSPDIE(SP, SPDie);
>
>  40 -  insertDIE(DT, StaticMemberDIE);
>  41 +  DD->insertStaticMemberDIE(DT, StaticMemberDIE);
>
>  52 +  // Process the worklist to add attributes with the correct form
> (ref_addr or
>  53 +  // ref4).
>  54 +  for (unsigned I = 0, E = DIEEntryWorklist.size(); I < E; I++) {
>  55 +    addDIEEntry(DIEEntryWorklist[I].Die,
> DIEEntryWorklist[I].Attribute,
>  56 +                dwarf::DW_FORM_ref4, DIEEntryWorklist[I].Entry);
>  57 +    assert(E == DIEEntryWorklist.size() &&
>  58 +           "We should not add to the worklist during finalization.");
>  59 +  }
>  60 +
>
>  68 +
>  69 +/// When we don't know whether the correct form is ref4 or ref_addr,
> we create
>  70 +/// a worklist item and insert it to DIEEntryWorklist.
>  71 +void DwarfDebug::addDIEEntry(DIE *Die, uint16_t Attribute, uint16_t
> Form,
>  72 +                             DIEEntry *Entry) {
>  73 +  /// Early exit when we only have a single CU.
>  74 +  if (GlobalCUIndexCount == 1 || Form != dwarf::DW_FORM_ref4) {
>  75 +    Die->addValue(Attribute, Form, Entry);
>  76 +    return;
>  77 +  }
>  78 +  DIE *DieCU = Die->checkCompileUnit();
>  79 +  DIE *EntryCU = Entry->getEntry()->checkCompileUnit();
>  80 +  if (!DieCU || !EntryCU) {
>  81 +    // Die or Entry is not added to an owner yet.
>  82 +    insertDIEEntryWorklist(Die, Attribute, Entry);
>  83 +    return;
>  84 +  }
>  85 +  Die->addValue(Attribute,
>  86 +         EntryCU == DieCU ? dwarf::DW_FORM_ref4 :
> dwarf::DW_FORM_ref_addr,
>  87 +         Entry);
>  88 +}
>
>
>
>>
>> (and no, computing the hash isn't enough to matter time wise on anything)
>>
>> -eric
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131003/73ec14cd/attachment.html>


More information about the llvm-commits mailing list