[PATCH] D29609: [dsymutil] Follow dependencies during ODR uniquing

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 15:22:48 PST 2017


alexshap created this revision.
alexshap created this object with visibility "All Users".
Herald added a subscriber: aprantl.

This diff fixes the loss of debug info in some cases when 
dsymutil doesn't follow the dependencies (via attributes) of already seen
forward-declared types.

Example:

S1.cpp:

1. 1 "S.h" 1 typedef struct S *Sptr;
2. 3 "S1.cpp" 2 Sptr ptr1;

S2.cpp:

1. 1 "S.h" 1 typedef struct S *Sptr;
2. 3 "S2.cpp" 2 struct S { int field; }; Sptr ptr2;

If one builds a library using S1.o and S2.o the debug info for the type S will be missing
(but it will be in place if one changes the order: S1 <-> S2).

In this case when the typedef Sptr is being examined (while processing S2.o) 
the method getCanonicalDIEOffset() returns non-zero and the following code is executed:

  if (AttrSpec.Form != dwarf::DW_FORM_ref_addr && UseODR && Info.Ctxt &&
          Info.Ctxt != ReferencedCU->getInfo(Info.ParentIdx).Ctxt &&
          Info.Ctxt->getCanonicalDIEOffset() && isODRAttribute(AttrSpec.Attr))
     continue;

The call of lookForDIEsToKeep is skipped and the DIE for the type S is not getting marked as kept.


Repository:
  rL LLVM

https://reviews.llvm.org/D29609

Files:
  test/tools/dsymutil/Inputs/odr-fwd-declaration/1.o
  test/tools/dsymutil/Inputs/odr-fwd-declaration/2.o
  test/tools/dsymutil/Inputs/odr-fwd-declaration/3.o
  test/tools/dsymutil/X86/odr-fwd-declaration.cpp
  tools/dsymutil/DwarfLinker.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29609.87313.patch
Type: text/x-patch
Size: 7738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170206/2507699f/attachment.bin>


More information about the llvm-commits mailing list