<div dir="ltr">GreenDragon is broken. Reverted in r304125.<div><br></div><div>-- </div><div>Mehdi</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-28 15:51 GMT-07:00 David Blaikie via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Sun May 28 17:51:37 2017<br>
New Revision: 304111<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=304111&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=304111&view=rev</a><br>
Log:<br>
DebugInfo: Omit an empty CU when a subprogram was moved into its use<br>
<br>
When the only use of a CU is for a subprogram that's only emitted into<br>
the using CU (to avoid cross-CU references in DWO files), avoid creating<br>
that CU at all.<br>
<br>
Added:<br>
    llvm/trunk/test/DebugInfo/<wbr>split-dwarf-omit-empty.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfDebug.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=304111&r1=304110&r2=304111&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/DwarfDebug.<wbr>cpp?rev=304111&r1=304110&r2=<wbr>304111&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfDebug.cpp Sun May 28 17:51:37 2017<br>
@@ -374,14 +374,18 @@ void DwarfDebug::<wbr>constructAbstractSubpro<br>
<br>
   // Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram<br>
   // was inlined from another compile unit.<br>
-  auto &CU = getOrCreateDwarfCompileUnit(<wbr>SP->getUnit());<br>
-  if (auto *SkelCU = CU.getSkeleton()) {<br>
-    (shareAcrossDWOCUs() ? CU : SrcCU)<br>
-        .<wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
-    if (CU.getCUNode()-><wbr>getSplitDebugInlining())<br>
-      SkelCU-><wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
-  } else {<br>
-    CU.<wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
+  if (useSplitDwarf() && !shareAcrossDWOCUs() && !SP->getUnit()-><wbr>getSplitDebugInlining())<br>
+    // Avoid building the original CU if it won't be used<br>
+    SrcCU.<wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
+  else {<br>
+    auto &CU = getOrCreateDwarfCompileUnit(<wbr>SP->getUnit());<br>
+    if (auto *SkelCU = CU.getSkeleton()) {<br>
+      (shareAcrossDWOCUs() ? CU : SrcCU)<br>
+          .<wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
+      if (CU.getCUNode()-><wbr>getSplitDebugInlining())<br>
+        SkelCU-><wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
+    } else<br>
+      CU.<wbr>constructAbstractSubprogramSco<wbr>peDIE(Scope);<br>
   }<br>
 }<br>
<br>
<br>
Added: llvm/trunk/test/DebugInfo/<wbr>split-dwarf-omit-empty.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/split-dwarf-omit-empty.ll?rev=304111&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>DebugInfo/split-dwarf-omit-<wbr>empty.ll?rev=304111&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/DebugInfo/<wbr>split-dwarf-omit-empty.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/<wbr>split-dwarf-omit-empty.ll Sun May 28 17:51:37 2017<br>
@@ -0,0 +1,52 @@<br>
+; RUN: %llc_dwarf -split-dwarf-file=foo.dwo  %s -filetype=obj -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s<br>
+<br>
+; Created from:<br>
+; a.cpp:<br>
+;   void f1();<br>
+;   inline __attribute__((always_inline)) __attribute__((used)) void f2() { f1(); }<br>
+; b.cpp:<br>
+;   void f2();<br>
+;   void f3() {<br>
+;     f2();<br>
+;   }<br>
+; $ clang++ -fno-split-dwarf-inlining {a,b}.cpp -emit-llvm -S -g<br>
+; $ llvm-link {a,b}.ll -S -o ab.ll<br>
+; Then strip out the @llvm.used global, so no out of line definition of 'f2'<br>
+; will be emitted. This emulates something more like the available_externally<br>
+; import performed by ThinLTO.<br>
+<br>
+; CHECK: Compile Unit<br>
+; CHECK-NOT: Compile Unit<br>
+<br>
+declare void @_Z2f1v()<br>
+<br>
+; Function Attrs: noinline norecurse uwtable<br>
+define i32 @main() !dbg !9 {<br>
+entry:<br>
+  call void @_Z2f1v(), !dbg !13<br>
+  ret i32 0, !dbg !18<br>
+}<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0, !3}<br>
+!llvm.ident = !{!5, !5}<br>
+!llvm.module.flags = !{!6, !7, !8}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 304054) (llvm/trunk 304080)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false)<br>
+!1 = !DIFile(filename: "a.cpp", directory: "/usr/local/google/home/<wbr>blaikie/dev/scratch")<br>
+!2 = !{}<br>
+!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 5.0.0 (trunk 304054) (llvm/trunk 304080)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false)<br>
+!4 = !DIFile(filename: "b.cpp", directory: "/usr/local/google/home/<wbr>blaikie/dev/scratch")<br>
+!5 = !{!"clang version 5.0.0 (trunk 304054) (llvm/trunk 304080)"}<br>
+!6 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!7 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!8 = !{i32 1, !"wchar_size", i32 4}<br>
+!9 = distinct !DISubprogram(name: "main", scope: !4, file: !4, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !3, variables: !2)<br>
+!10 = !DISubroutineType(types: !11)<br>
+!11 = !{!12}<br>
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br>
+!13 = !DILocation(line: 2, column: 73, scope: !14, inlinedAt: !17)<br>
+!14 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !15, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)<br>
+!15 = !DISubroutineType(types: !16)<br>
+!16 = !{null}<br>
+!17 = distinct !DILocation(line: 3, column: 3, scope: !9)<br>
+!18 = !DILocation(line: 4, column: 1, scope: !9)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>