<p dir="ltr">I did. Thanks. </p>
<div class="gmail_quote">On Aug 13, 2013 12:59 AM, "Evgeniy Stepanov" <<a href="mailto:eugeni.stepanov@gmail.com">eugeni.stepanov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've tried to fix this in r188254. Please verify.<br>
<br>
On Tue, Aug 13, 2013 at 11:34 AM, Evgeniy Stepanov<br>
<<a href="mailto:eugeni.stepanov@gmail.com">eugeni.stepanov@gmail.com</a>> wrote:<br>
> On Tue, Aug 13, 2013 at 5:21 AM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
>> Author: echristo<br>
>> Date: Mon Aug 12 20:21:55 2013<br>
>> New Revision: 188243<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=188243&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=188243&view=rev</a><br>
>> Log:<br>
>> Add the start of DIE hashing for DWARF4 type units and split dwarf<br>
>> CUs.<br>
>><br>
>> Currently only hashes the name of CUs and the names of any children,<br>
>> but it's an obvious first step to show the framework. The testcase<br>
>> should continue to be correct, however, as it's an empty TU.<br>
>><br>
>> Added:<br>
>>     llvm/trunk/test/DebugInfo/X86/fission-hash.ll<br>
>> Modified:<br>
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp<br>
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h<br>
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
>><br>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp?rev=188243&r1=188242&r2=188243&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp?rev=188243&r1=188242&r2=188243&view=diff</a><br>

>> ==============================================================================<br>
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp (original)<br>
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.cpp Mon Aug 12 20:21:55 2013<br>
>> @@ -102,6 +102,92 @@ void DIEHash::addParentContext(DIE *Pare<br>
>>    }<br>
>>  }<br>
>><br>
>> +// Collect all of the attributes for a particular DIE in single structure.<br>
>> +void DIEHash::collectAttributes(DIE *Die, DIEAttrs Attrs) {<br>
><br>
> I wonder if you meant to pass Attrs by reference?<br>
> Otherwise this function does not seem to be doing anything useful.<br>
><br>
>> +  const SmallVectorImpl<DIEValue *> &Values = Die->getValues();<br>
>> +  const DIEAbbrev &Abbrevs = Die->getAbbrev();<br>
>> +<br>
>> +#define COLLECT_ATTR(NAME)                                                     \<br>
>> +  Attrs.NAME.Val = Values[i];                                                  \<br>
>> +  Attrs.NAME.Desc = &Abbrevs.getData()[i];<br>
>> +<br>
>> +  for (size_t i = 0, e = Values.size(); i != e; ++i) {<br>
>> +    DEBUG(dbgs() << "Attribute: "<br>
>> +                 << dwarf::AttributeString(Abbrevs.getData()[i].getAttribute())<br>
>> +                 << " added.\n");<br>
>> +    switch (Abbrevs.getData()[i].getAttribute()) {<br>
>> +    case dwarf::DW_AT_name:<br>
>> +      COLLECT_ATTR(DW_AT_name);<br>
>> +      break;<br>
>> +    default:<br>
>> +      break;<br>
>> +    }<br>
>> +  }<br>
>> +}<br>
>> +<br>
>> +// Hash an individual attribute \param Attr based on the type of attribute and<br>
>> +// the form.<br>
>> +void DIEHash::hashAttribute(AttrEntry Attr) {<br>
>> +  const DIEValue *Value = Attr.Val;<br>
>> +  const DIEAbbrevData *Desc = Attr.Desc;<br>
>> +<br>
>> +  // TODO: Add support for types.<br>
>> +<br>
>> +  // Add the letter A to the hash.<br>
>> +  addULEB128('A');<br>
>> +<br>
>> +  // Then the attribute code and form.<br>
>> +  addULEB128(Desc->getAttribute());<br>
>> +  addULEB128(Desc->getForm());<br>
>> +<br>
>> +  // TODO: Add support for additional forms.<br>
>> +  switch (Desc->getForm()) {<br>
>> +  case dwarf::DW_FORM_strp:<br>
>> +    addString(cast<DIEString>(Value)->getString());<br>
>> +    break;<br>
>> +  }<br>
>> +}<br>
>> +<br>
>> +// Go through the attributes from \param Attrs in the order specified in 7.27.4<br>
>> +// and hash them.<br>
>> +void DIEHash::hashAttributes(DIEAttrs Attrs) {<br>
>> +#define ADD_ATTR(ATTR)                                                         \<br>
>> +  {                                                                            \<br>
>> +    if (ATTR.Val != 0)                                                         \<br>
>> +      hashAttribute(ATTR);                                                     \<br>
>> +  }<br>
>> +<br>
>> +  // FIXME: Add the rest.<br>
>> +  ADD_ATTR(Attrs.DW_AT_name);<br>
>> +}<br>
>> +<br>
>> +// Add all of the attributes for \param Die to the hash.<br>
>> +void DIEHash::addAttributes(DIE *Die) {<br>
>> +  DIEAttrs Attrs;<br>
>> +  memset(&Attrs, 0, sizeof(Attrs));<br>
>> +  collectAttributes(Die, Attrs);<br>
>> +  hashAttributes(Attrs);<br>
>> +}<br>
>> +<br>
>> +// Compute the hash of a DIE. This is based on the type signature computation<br>
>> +// given in section 7.27 of the DWARF4 standard. It is the md5 hash of a<br>
>> +// flattened description of the DIE.<br>
>> +void DIEHash::computeHash(DIE *Die) {<br>
>> +<br>
>> +  // Append the letter 'D', followed by the DWARF tag of the DIE.<br>
>> +  addULEB128('D');<br>
>> +  addULEB128(Die->getTag());<br>
>> +<br>
>> +  // Add each of the attributes of the DIE.<br>
>> +  addAttributes(Die);<br>
>> +<br>
>> +  // Then hash each of the children of the DIE.<br>
>> +  for (std::vector<DIE *>::const_iterator I = Die->getChildren().begin(),<br>
>> +                                          E = Die->getChildren().end();<br>
>> +       I != E; ++I)<br>
>> +    computeHash(*I);<br>
>> +}<br>
>> +<br>
>>  /// This is based on the type signature computation given in section 7.27 of the<br>
>>  /// DWARF4 standard. It is the md5 hash of a flattened description of the DIE<br>
>>  /// with the exception that we are hashing only the context and the name of the<br>
>> @@ -129,6 +215,24 @@ uint64_t DIEHash::computeDIEODRSignature<br>
>>    MD5::MD5Result Result;<br>
>>    Hash.final(Result);<br>
>><br>
>> +  // ... take the least significant 8 bytes and return those. Our MD5<br>
>> +  // implementation always returns its results in little endian, swap bytes<br>
>> +  // appropriately.<br>
>> +  return *reinterpret_cast<support::ulittle64_t *>(Result + 8);<br>
>> +}<br>
>> +<br>
>> +/// This is based on the type signature computation given in section 7.27 of the<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>
>> +uint64_t DIEHash::computeCUSignature(DIE *Die) {<br>
>> +<br>
>> +  // Hash the DIE.<br>
>> +  computeHash(Die);<br>
>> +<br>
>> +  // Now return the result.<br>
>> +  MD5::MD5Result Result;<br>
>> +  Hash.final(Result);<br>
>> +<br>
>>    // ... take the least significant 8 bytes and return those. Our MD5<br>
>>    // implementation always returns its results in little endian, swap bytes<br>
>>    // appropriately.<br>
>><br>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h?rev=188243&r1=188242&r2=188243&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h?rev=188243&r1=188242&r2=188243&view=diff</a><br>

>> ==============================================================================<br>
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h (original)<br>
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIEHash.h Mon Aug 12 20:21:55 2013<br>
>> @@ -20,15 +20,35 @@ class CompileUnit;<br>
>>  /// \brief An object containing the capability of hashing and adding hash<br>
>>  /// attributes onto a DIE.<br>
>>  class DIEHash {<br>
>> +  // The entry for a particular attribute.<br>
>> +  struct AttrEntry {<br>
>> +    const DIEValue *Val;<br>
>> +    const DIEAbbrevData *Desc;<br>
>> +  };<br>
>> +<br>
>> +  // Collection of all attributes used in hashing a particular DIE.<br>
>> +  struct DIEAttrs {<br>
>> +    AttrEntry DW_AT_name;<br>
>> +  };<br>
>> +<br>
>>  public:<br>
>>    /// \brief Computes the ODR signature<br>
>>    uint64_t computeDIEODRSignature(DIE *Die);<br>
>><br>
>> +  /// \brief Computes the CU signature<br>
>> +  uint64_t computeCUSignature(DIE *Die);<br>
>> +<br>
>>    // Helper routines to process parts of a DIE.<br>
>> - private:<br>
>> +private:<br>
>>    /// \brief Adds the parent context of \param Die to the hash.<br>
>>    void addParentContext(DIE *Die);<br>
>> -<br>
>> +<br>
>> +  /// \brief Adds the attributes of \param Die to the hash.<br>
>> +  void addAttributes(DIE *Die);<br>
>> +<br>
>> +  /// \brief Computes the full DWARF4 7.27 hash of the DIE.<br>
>> +  void computeHash(DIE *Die);<br>
>> +<br>
>>    // Routines that add DIEValues to the hash.<br>
>>  private:<br>
>>    /// \brief Encodes and adds \param Value to the hash as a ULEB128.<br>
>> @@ -36,7 +56,17 @@ private:<br>
>><br>
>>    /// \brief Adds \param Str to the hash and includes a NULL byte.<br>
>>    void addString(StringRef Str);<br>
>> -<br>
>> +<br>
>> +  /// \brief Collects the attributes of DIE \param Die into the \param Attrs<br>
>> +  /// structure.<br>
>> +  void collectAttributes(DIE *Die, DIEAttrs Attrs);<br>
>> +<br>
>> +  /// \brief Hashes the attributes in \param Attrs in order.<br>
>> +  void hashAttributes(DIEAttrs Attrs);<br>
>> +<br>
>> +  /// \brief Hashes an individual attribute.<br>
>> +  void hashAttribute(AttrEntry Attr);<br>
>> +<br>
>>  private:<br>
>>    MD5 Hash;<br>
>>  };<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=188243&r1=188242&r2=188243&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=188243&r1=188242&r2=188243&view=diff</a><br>

>> ==============================================================================<br>
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 12 20:21:55 2013<br>
>> @@ -67,6 +67,11 @@ GenerateODRHash("generate-odr-hash", cl:<br>
>>                  cl::desc("Add an ODR hash to external type DIEs."),<br>
>>                  cl::init(false));<br>
>><br>
>> +static cl::opt<bool><br>
>> +GenerateCUHash("generate-cu-hash", cl::Hidden,<br>
>> +               cl::desc("Add the CU hash as the dwo_id."),<br>
>> +               cl::init(false));<br>
>> +<br>
>>  namespace {<br>
>>  enum DefaultOnOff {<br>
>>    Default,<br>
>> @@ -1024,14 +1029,19 @@ void DwarfDebug::finalizeModuleInfo() {<br>
>>      // If we're splitting the dwarf out now that we've got the entire<br>
>>      // CU then construct a skeleton CU based upon it.<br>
>>      if (useSplitDwarf()) {<br>
>> +      uint64_t ID = 0;<br>
>> +      if (GenerateCUHash) {<br>
>> +        DIEHash CUHash;<br>
>> +        ID = CUHash.computeCUSignature(TheCU->getCUDie());<br>
>> +      }<br>
>>        // This should be a unique identifier when we want to build .dwp files.<br>
>>        TheCU->addUInt(TheCU->getCUDie(), dwarf::DW_AT_GNU_dwo_id,<br>
>> -                     dwarf::DW_FORM_data8, 0);<br>
>> +                     dwarf::DW_FORM_data8, ID);<br>
>>        // Now construct the skeleton CU associated.<br>
>>        CompileUnit *SkCU = constructSkeletonCU(CUI->first);<br>
>>        // This should be a unique identifier when we want to build .dwp files.<br>
>>        SkCU->addUInt(SkCU->getCUDie(), dwarf::DW_AT_GNU_dwo_id,<br>
>> -                    dwarf::DW_FORM_data8, 0);<br>
>> +                    dwarf::DW_FORM_data8, ID);<br>
>>      }<br>
>>    }<br>
>><br>
>><br>
>> Added: llvm/trunk/test/DebugInfo/X86/fission-hash.ll<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/fission-hash.ll?rev=188243&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/fission-hash.ll?rev=188243&view=auto</a><br>

>> ==============================================================================<br>
>> --- llvm/trunk/test/DebugInfo/X86/fission-hash.ll (added)<br>
>> +++ llvm/trunk/test/DebugInfo/X86/fission-hash.ll Mon Aug 12 20:21:55 2013<br>
>> @@ -0,0 +1,15 @@<br>
>> +; RUN: llc -split-dwarf=Enable -generate-cu-hash -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t<br>
>> +; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck %s<br>
>> +<br>
>> +; The source is an empty file.<br>
>> +<br>
>> +; CHECK: DW_AT_GNU_dwo_id [DW_FORM_data8] (0x356a7d50a77f5177)<br>
>> +; CHECK: DW_AT_GNU_dwo_id [DW_FORM_data8] (0x356a7d50a77f5177)<br>
>> +<br>
>> +!<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
>> +!llvm.module.flags = !{!3}<br>
>> +<br>
>> +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.4 (trunk 188230) (llvm/trunk 188234)", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !2, metadata !2, metadata !2, metadata !"foo.dwo"} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/echristo/tmp/foo.c] [DW_LANG_C99]<br>

>> +!1 = metadata !{metadata !"foo.c", metadata !"/usr/local/google/home/echristo/tmp"}<br>
>> +!2 = metadata !{i32 0}<br>
>> +!3 = metadata !{i32 2, metadata !"Dwarf Version", i32 3}<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>