<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 26, 2017 at 11:49 AM Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Wed Jul 26 11:48:32 2017<br>
New Revision: 309154<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=309154&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=309154&view=rev</a><br>
Log:<br>
Do a better job at emitting prefrabricated skeleton CUs.<br>
<br>
This is a better fix than r308708 for the problem introduced in<br>
r304020. It restores the skeleton CU testcases modified by that commit<br>
to their original form and most importantly ensures that<br>
frontend-generated skeleton CUs (such as used to point to Clang<br>
modules) come after the regular CUs. This broke for DICompileUnit<br>
nodes that don't have any immediate children because they are now<br>
constructed lazily instead of the order in which they are listed in<br>
!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a>. After this commit we still don't guarantee that order,<br>
but we do guarantee that empty skeletons come last.<br>
<br>
Shipping versions of LLDB are very sensitive to the ordering of<br>
CUs. I'll track a fix for LLDB to be more permissive separately.<br>
This fixes a test failure in the LLDB testsuite.<br>
<br>
rdar://problem/33357252<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
    llvm/trunk/test/DebugInfo/Generic/skeletoncu.ll<br>
    llvm/trunk/test/DebugInfo/dwo.ll<br>
    llvm/trunk/test/DebugInfo/skeletoncu.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=309154&r1=309153&r2=309154&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=309154&r1=309153&r2=309154&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Jul 26 11:48:32 2017<br>
@@ -520,6 +520,14 @@ sortGlobalExprs(SmallVectorImpl<DwarfCom<br>
   return GVEs;<br>
 }<br>
<br>
+static bool isEmptyCU(DICompileUnit *CUNode) {<br>
+  return CUNode->getEnumTypes().empty() &&<br>
+         CUNode->getRetainedTypes().empty() &&<br>
+         CUNode->getGlobalVariables().empty() &&<br>
+         CUNode->getImportedEntities().empty() &&<br>
+         CUNode->getMacros().empty();<br>
+}<br>
+<br>
 // Emit all Dwarf sections that should come prior to the content. Create<br>
 // global DIEs and emit initial debug info sections. This is invoked by<br>
 // the target AsmPrinter.<br>
@@ -546,10 +554,7 @@ void DwarfDebug::beginModule() {<br>
   }<br>
<br>
   for (DICompileUnit *CUNode : M->debug_compile_units()) {<br>
-    if (CUNode->getEnumTypes().empty() && CUNode->getRetainedTypes().empty() &&<br>
-        CUNode->getGlobalVariables().empty() &&<br>
-        CUNode->getImportedEntities().empty() && CUNode->getMacros().empty() &&<br>
-        !CUNode->getDWOId())<br>
+    if (isEmptyCU(CUNode))<br>
       continue;<br>
<br>
     DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode);<br>
@@ -683,6 +688,11 @@ void DwarfDebug::finalizeModuleInfo() {<br>
                         TLOF.getDwarfMacinfoSection()->getBeginSymbol());<br>
   }<br>
<br>
+  // Emit all frontend-produced Skeleton CUs, i.e., Clang modules.<br>
+  for (auto *CUNode : MMI->getModule()->debug_compile_units())<br>
+    if (CUNode->getDWOId() && isEmptyCU(CUNode))<br>
+      getOrCreateDwarfCompileUnit(CUNode);<br></blockquote><div><br>I'm not sure I understand the motivation for the 'isEmptyCU' test here - seems like it could be removed? DWOId tells you it's a skeleton, so it will be empty, right? (but even if it's not empty, is that a problem? getOrCreateDwarfCompileUnit would be a no-op in that case? (the map lookup would succeed and nothing further would be done?))<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
   // Compute DIE offsets and sizes.<br>
   InfoHolder.computeSizeAndOffsets();<br>
   if (useSplitDwarf())<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/skeletoncu.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/skeletoncu.ll?rev=309154&r1=309153&r2=309154&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/skeletoncu.ll?rev=309154&r1=309153&r2=309154&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/skeletoncu.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/skeletoncu.ll Wed Jul 26 11:48:32 2017<br>
@@ -14,4 +14,3 @@<br>
 !4 = !{i32 2, !"Debug Info Version", i32 3}<br>
 !5 = !{!6}<br>
 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br>
-<br>
<br>
Modified: llvm/trunk/test/DebugInfo/dwo.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwo.ll?rev=309154&r1=309153&r2=309154&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwo.ll?rev=309154&r1=309153&r2=309154&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/dwo.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/dwo.ll Wed Jul 26 11:48:32 2017<br>
@@ -1,17 +1,23 @@<br>
 ; RUN: %llc_dwarf %s -filetype=obj -o %t<br>
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s<br>
+; REQUIRES: default_triple<br>
+;<br>
+; CHECK: DW_TAG_compile_unit<br>
+; CHECK-NOT: dwo_id<br>
+;<br>
+; The skeleton must come second or LLDB may get confused.<br>
 ; CHECK: DW_TAG_compile_unit<br>
 ; CHECK: DW_AT_GNU_dwo_id {{.*}}abcd<br>
-; CHECK-NOT: DW_AT_GNU_dwo_name<br>
-; REQUIRES: default_triple<br>
+; CHECK: DW_AT_GNU_dwo_name {{.*}}"my.dwo"<br>
<br>
-!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!7, !0}<br>
 !llvm.module.flags = !{!3, !4}<br>
<br>
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, enums: !2, retainedTypes: !5, globals: !2, imports: !2, dwoId: 43981)<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "my.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, dwoId: 43981)<br>
 !1 = !DIFile(filename: "<stdin>", directory: "/")<br>
 !2 = !{}<br>
 !3 = !{i32 2, !"Dwarf Version", i32 4}<br>
 !4 = !{i32 2, !"Debug Info Version", i32 3}<br>
 !5 = !{!6}<br>
 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br>
+!7 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, retainedTypes: !5)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/skeletoncu.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/skeletoncu.ll?rev=309154&r1=309153&r2=309154&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/skeletoncu.ll?rev=309154&r1=309153&r2=309154&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/skeletoncu.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/skeletoncu.ll Wed Jul 26 11:48:32 2017<br>
@@ -8,11 +8,9 @@<br>
 !<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
 !llvm.module.flags = !{!3, !4}<br>
<br>
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "my.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !6, globals: !2, imports: !2, dwoId: 43981)<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "my.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, dwoId: 43981)<br>
 !1 = !DIFile(filename: "<stdin>", directory: "/")<br>
 !2 = !{}<br>
 !3 = !{i32 2, !"Dwarf Version", i32 4}<br>
 !4 = !{i32 2, !"Debug Info Version", i32 3}<br>
-!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br>
-!6 = !{!5}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>