[llvm] r203983 - Debug info: Unique types before emitting them to DWARF, where applicable.

Manman Ren manman.ren at gmail.com
Mon Mar 17 10:32:56 PDT 2014


On Mon, Mar 17, 2014 at 9:53 AM, Adrian Prantl <aprantl at apple.com> wrote:

>
> On Mar 17, 2014, at 0:16, Eric Christopher <echristo at gmail.com> wrote:
>
> > I've been reading the thread and I'm still uncertain what logic you
> > think is going on here - also the testcase isn't clear as to what
> > behavior you've changed there.
> >
> > Could you explain more with the testcase what you're expecting to be
> > uniqued here?
> >
>
> Sure! Suppose we have two files that declare the same class (abbreviated,
> the full source code is in the comments in the test case):
>
> $cat a.cpp
> class A {
>  int data;
> };
>
> void bar() {
>   A a;
> }
>
> $ cat b.cpp
> class A {
>   int data;
> };
>
> $ clang "-cc1" "-triple" "x86_64-apple-macosx10.9.0" "-emit-llvm"  "-o"
> "a.ll" -gdwarf-2 "-x" "c++" "a.cpp" &&  clang-3.5 "-cc1" "-triple"
> "x86_64-apple-macosx10.9.0" "-emit-llvm"  "-o" "b.ll" -gdwarf-2 "-x" "c++"
> "b.cpp" && llvm-link a.ll b.ll -S -o t.ll && llc -filetype=obj -O0 < t.ll >
> t.o && dwarfdump t.o
>
> We end up with two DW_TAG_member type DIEs (and two DW_TAG_classes)
> because their MDNodes are different, as they have a different decl_line and
> decl_file. The normal DIRef-based uniquing doesn't work here, because they
> are emitted from the list of retained types in the compile unit, and the
> list of retained types can't use DIRefs because then we would loose those
> MDNodes, since nothing is pointing to them any more.
>

This commit is to solve the issue of emitting two class DIEs for the two
DW_TAG_classes with the same type identifier, and commit r203982 is to
unique the two DW_TAG_members, right? The two class DIEs are generated
because we emit one class DIE when visiting retained types of each CU.

Thanks,
Manman


r203983 counters this by uniting every type before emitting it, but as
> Manman pointed out, it is sufficient to do this for every retained type.
>
> -- adrian
>
> > On Fri, Mar 14, 2014 at 4:08 PM, Adrian Prantl <aprantl at apple.com>
> wrote:
> >> Author: adrian
> >> Date: Fri Mar 14 18:08:29 2014
> >> New Revision: 203983
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=203983&view=rev
> >> Log:
> >> Debug info: Unique types before emitting them to DWARF, where
> applicable.
> >>
> >> Modified:
> >>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> >>    llvm/trunk/test/Linker/type-unique-odr-a.ll
> >>
> >> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=203983&r1=203982&r2=203983&view=diff
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
> >> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Mar 14 18:08:29
> 2014
> >> @@ -958,6 +958,9 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const
> >>   DIE *ContextDIE = getOrCreateContextDIE(Context);
> >>   assert(ContextDIE);
> >>
> >> +  // Unique the type. This is a noop if the type has no unique
> identifier.
> >> +  Ty = DIType(resolve(Ty.getRef()));
> >> +
> >>   DIE *TyDIE = getDIE(Ty);
> >>   if (TyDIE)
> >>     return TyDIE;
> >>
> >> Modified: llvm/trunk/test/Linker/type-unique-odr-a.ll
> >> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/type-unique-odr-a.ll?rev=203983&r1=203982&r2=203983&view=diff
> >>
> ==============================================================================
> >> --- llvm/trunk/test/Linker/type-unique-odr-a.ll (original)
> >> +++ llvm/trunk/test/Linker/type-unique-odr-a.ll Fri Mar 14 18:08:29 2014
> >> @@ -28,6 +28,10 @@
> >> ; CHECK-NEXT:   DW_AT_MIPS_linkage_name {{.*}} "_ZL3barv"
> >> ; CHECK:      DW_TAG_class_type
> >> ; CHECK-NEXT:   DW_AT_name {{.*}} "A"
> >> +; CHECK-NOT:  DW_TAG
> >> +; CHECK:      DW_TAG_member
> >> +; CHECK-NEXT:   DW_AT_name {{.*}} "data"
> >> +; CHECK-NOT:  DW_TAG
> >> ; CHECK:      DW_TAG_subprogram
> >> ; CHECK-NEXT:   DW_AT_MIPS_linkage_name {{.*}} "_ZN1A6getFooEv"
> >> ; CHECK-NEXT:   DW_AT_name {{.*}} "getFoo"
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
> _______________________________________________
> 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/20140317/b0044d9c/attachment.html>


More information about the llvm-commits mailing list