[llvm] r326231 - [dsymutil] Skip DW_AT_sibling attributes.

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 11:24:36 PST 2018


Author: jdevlieghere
Date: Tue Feb 27 11:24:36 2018
New Revision: 326231

URL: http://llvm.org/viewvc/llvm-project?rev=326231&view=rev
Log:
[dsymutil] Skip DW_AT_sibling attributes.

Following DW_AT_sibling attributes completely defeats the pruning pass.
Although clang doesn't generate the DW_AT_sibling attribute we should
still handle it correctly.

Differential revision: https://reviews.llvm.org/D43439

Modified:
    llvm/trunk/test/tools/dsymutil/Inputs/sibling.o
    llvm/trunk/test/tools/dsymutil/PowerPC/sibling.test
    llvm/trunk/tools/dsymutil/DwarfLinker.cpp

Modified: llvm/trunk/test/tools/dsymutil/Inputs/sibling.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/Inputs/sibling.o?rev=326231&r1=326230&r2=326231&view=diff
==============================================================================
Binary files - no diff available.

Modified: llvm/trunk/test/tools/dsymutil/PowerPC/sibling.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/PowerPC/sibling.test?rev=326231&r1=326230&r2=326231&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/PowerPC/sibling.test (original)
+++ llvm/trunk/test/tools/dsymutil/PowerPC/sibling.test Tue Feb 27 11:24:36 2018
@@ -1,14 +1,27 @@
 # Verify that we don't follow DW_AT_sibling references.
 #
 # Source:
-#   struct A { int a; } a;
-#   struct B { int b; } b;
+#   struct A { };
+#   struct B { };
+#
+#   struct C {
+#     A a;
+#   };
+#
+#   B b;
+#   C c;
+#
+# Compiled with Apple-GCC 4.0.1 (build 5370):
+#   g++ -g -c sibling.cpp -o sibling.o
 
 # RUN: llvm-dsymutil -arch ppc -f -oso-prepend-path=%p/../Inputs/ -y %s -o - | llvm-dwarfdump -debug-info - | FileCheck %s
 
-# CHECK: DW_TAG_variable
-# CHECK-NEXT: DW_AT_name ("a")
-# CHECK-NOT: DW_AT_name	("b")
+# CHECK: DW_TAG_structure_type
+# CHECK-NEXT: DW_AT_name	("A")
+# CHECK: DW_TAG_structure_type
+# CHECK-NEXT: DW_AT_name	("C")
+
+# CHECK-NOT: DW_AT_name	("B")
 
 ---
 triple:          'ppc-apple-darwin'
@@ -16,5 +29,5 @@ objects:
   - filename:        sibling.o
     timestamp:       1518197670
     symbols:
-      - { sym: _a, objAddr: 0x00000000000000cb, binAddr: 0x0000000100000FA0, size: 0x00000010 }
+      - { sym: _c, objAddr: 0x000000000000017e, binAddr: 0x0000000100000FA0, size: 0x00000010 }
 ...

Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=326231&r1=326230&r2=326231&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Tue Feb 27 11:24:36 2018
@@ -2591,7 +2591,8 @@ void DwarfLinker::keepDIEAndDependencies
   for (const auto &AttrSpec : Abbrev->attributes()) {
     DWARFFormValue Val(AttrSpec.Form);
 
-    if (!Val.isFormClass(DWARFFormValue::FC_Reference)) {
+    if (!Val.isFormClass(DWARFFormValue::FC_Reference) ||
+        AttrSpec.Attr == dwarf::DW_AT_sibling) {
       DWARFFormValue::skipValue(AttrSpec.Form, Data, &Offset,
                                 Unit.getFormParams());
       continue;
@@ -2767,7 +2768,7 @@ unsigned DwarfLinker::DIECloner::cloneDi
       resolveDIEReference(Linker, CompileUnits, Val, U, InputDIE, RefUnit);
 
   // If the referenced DIE is not found,  drop the attribute.
-  if (!RefDie)
+  if (!RefDie || AttrSpec.Attr == dwarf::DW_AT_sibling)
     return 0;
 
   unsigned Idx = RefUnit->getOrigUnit().getDIEIndex(RefDie);




More information about the llvm-commits mailing list