<div dir="ltr">GreenDragon is broken. Reverted in r304126.<div><div><br></div></div><div>-- </div><div>Mehdi</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-28 17:48 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 19:48:45 2017<br>
New Revision: 304119<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=304119&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=304119&view=rev</a><br>
Log:<br>
DebugInfo: Include .dwo file name when hashing multiple CUs in a single file<br>
<br>
This is really a workaround for ThinLTO in particular - since it can<br>
import partial CUs that may end up looking very similar/the same as<br>
the same partial import in another ThinLTO compile.<br>
<br>
An alternative fix would be to change the DICompileUnit metadata to<br>
include a "primary file" or the like - and when importing for ThinLTO<br>
set the primary file to the name of the DICompileUnit that is being<br>
imported into. This involves changing the schema and would reduce the<br>
excessive uniqueness in the hash that this change creates - allowing<br>
diagnosing of more duplicate CUs than will be caught with this change.<br>
<br>
But duplicate CUs can still be caught in non-ThinLTO builds & are mostly<br>
a nuisance rather than a particularly deliberate/effective tool for<br>
finding broken code. (arguably the hash could always include the dwo<br>
file and nothing in fission would break, I think..)<br>
<br>
Added:<br>
    llvm/trunk/test/DebugInfo/<wbr>Generic/split-dwarf-multiple-<wbr>cu-hash.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.h<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfDebug.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp?rev=304119&r1=304118&r2=304119&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/DIEHash.<wbr>cpp?rev=304119&r1=304118&r2=<wbr>304119&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.cpp Sun May 28 19:48:45 2017<br>
@@ -380,10 +380,12 @@ void DIEHash::computeHash(const DIE &Die<br>
 /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE<br>
 /// with the inclusion of the full CU and all top level CU entities.<br>
 // TODO: Initialize the type chain at 0 instead of 1 for CU signatures.<br>
-uint64_t DIEHash::computeCUSignature(<wbr>const DIE &Die) {<br>
+uint64_t DIEHash::computeCUSignature(<wbr>StringRef DWOName, const DIE &Die) {<br>
   Numbering.clear();<br>
   Numbering[&Die] = 1;<br>
<br>
+  if (!DWOName.empty())<br>
+    Hash.update(DWOName);<br>
   // Hash the DIE.<br>
   computeHash(Die);<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h?rev=304119&r1=304118&r2=304119&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/DIEHash.h?<wbr>rev=304119&r1=304118&r2=<wbr>304119&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.h (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DIEHash.h Sun May 28 19:48:45 2017<br>
@@ -36,7 +36,7 @@ public:<br>
   DIEHash(AsmPrinter *A = nullptr) : AP(A) {}<br>
<br>
   /// \brief Computes the CU signature.<br>
-  uint64_t computeCUSignature(const DIE &Die);<br>
+  uint64_t computeCUSignature(StringRef DWOName, const DIE &Die);<br>
<br>
   /// \brief Computes the type signature.<br>
   uint64_t computeTypeSignature(const DIE &Die);<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=304119&r1=304118&r2=304119&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/DwarfDebug.<wbr>cpp?rev=304119&r1=304118&r2=<wbr>304119&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 19:48:45 2017<br>
@@ -613,6 +613,13 @@ void DwarfDebug::<wbr>finalizeModuleInfo() {<br>
<br>
   finishVariableDefinitions();<br>
<br>
+  // Include the DWO file name in the hash if there's more than one CU.<br>
+  // This handles ThinLTO's situation where imported CUs may very easily be<br>
+  // duplicate with the same CU partially imported into another ThinLTO unit.<br>
+  StringRef DWOName;<br>
+  if (CUMap.size() > 1)<br>
+    DWOName = Asm->TM.Options.MCOptions.<wbr>SplitDwarfFile;<br>
+<br>
   // Handle anything that needs to be done on a per-unit basis after<br>
   // all other generation.<br>
   for (const auto &P : CUMap) {<br>
@@ -627,7 +634,8 @@ void DwarfDebug::<wbr>finalizeModuleInfo() {<br>
     auto *SkCU = TheCU.getSkeleton();<br>
     if (useSplitDwarf()) {<br>
       // Emit a unique identifier for this CU.<br>
-      uint64_t ID = DIEHash(Asm).<wbr>computeCUSignature(TheCU.<wbr>getUnitDie());<br>
+      uint64_t ID =<br>
+          DIEHash(Asm).<wbr>computeCUSignature(DWOName, TheCU.getUnitDie());<br>
       TheCU.addUInt(TheCU.<wbr>getUnitDie(), dwarf::DW_AT_GNU_dwo_id,<br>
                     dwarf::DW_FORM_data8, ID);<br>
       SkCU->addUInt(SkCU-><wbr>getUnitDie(), dwarf::DW_AT_GNU_dwo_id,<br>
<br>
Added: llvm/trunk/test/DebugInfo/<wbr>Generic/split-dwarf-multiple-<wbr>cu-hash.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/split-dwarf-multiple-cu-hash.ll?rev=304119&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>DebugInfo/Generic/split-dwarf-<wbr>multiple-cu-hash.ll?rev=<wbr>304119&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/DebugInfo/<wbr>Generic/split-dwarf-multiple-<wbr>cu-hash.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/<wbr>Generic/split-dwarf-multiple-<wbr>cu-hash.ll Sun May 28 19:48:45 2017<br>
@@ -0,0 +1,40 @@<br>
+; RUN: %llc_dwarf -split-dwarf-file=foo.dwo  %s -filetype=obj -o %T/a.o<br>
+; RUN: %llc_dwarf -split-dwarf-file=bar.dwo  %s -filetype=obj -o %T/b.o<br>
+; RUN: llvm-dwarfdump -debug-dump=info %T/a.o %T/b.o | FileCheck %s<br>
+<br>
+; CHECK: dwo_id {{.*}}([[HASH:.*]])<br>
+; CHECK-NOT: dwo_id {{.*}}([[HASH]])<br>
+<br>
+; Function Attrs: noinline nounwind uwtable<br>
+define void @_Z1av() #0 !dbg !9 {<br>
+entry:<br>
+  ret void, !dbg !12<br>
+}<br>
+<br>
+; Function Attrs: noinline nounwind uwtable<br>
+define void @_Z1bv() #0 !dbg !13 {<br>
+entry:<br>
+  ret void, !dbg !14<br>
+}<br>
+<br>
+attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-<wbr>sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-<wbr>leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="<wbr>false" "no-trapping-math"="false" "stack-protector-buffer-size"=<wbr>"8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,<wbr>+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }<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 304107) (llvm/trunk 304109)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<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 304107) (llvm/trunk 304109)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!4 = !DIFile(filename: "b.cpp", directory: "/usr/local/google/home/<wbr>blaikie/dev/scratch")<br>
+!5 = !{!"clang version 5.0.0 (trunk 304107) (llvm/trunk 304109)"}<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: "a", linkageName: "_Z1av", scope: !1, file: !1, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)<br>
+!10 = !DISubroutineType(types: !11)<br>
+!11 = !{null}<br>
+!12 = !DILocation(line: 2, column: 1, scope: !9)<br>
+!13 = distinct !DISubprogram(name: "b", linkageName: "_Z1bv", scope: !4, file: !4, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !3, variables: !2)<br>
+!14 = !DILocation(line: 2, column: 1, scope: !13)<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>