LLVM API Documentation

DIEHash.cpp
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/DIEHash.cpp - Dwarf Hashing Framework ----------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains support for DWARF4 hashing of DIEs.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "ByteStreamer.h"
00015 #include "DIEHash.h"
00016 #include "DIE.h"
00017 #include "DwarfDebug.h"
00018 #include "llvm/ADT/ArrayRef.h"
00019 #include "llvm/ADT/StringRef.h"
00020 #include "llvm/CodeGen/AsmPrinter.h"
00021 #include "llvm/Support/Debug.h"
00022 #include "llvm/Support/Dwarf.h"
00023 #include "llvm/Support/Endian.h"
00024 #include "llvm/Support/MD5.h"
00025 #include "llvm/Support/raw_ostream.h"
00026 
00027 using namespace llvm;
00028 
00029 #define DEBUG_TYPE "dwarfdebug"
00030 
00031 /// \brief Grabs the string in whichever attribute is passed in and returns
00032 /// a reference to it.
00033 static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr) {
00034   const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
00035   const DIEAbbrev &Abbrevs = Die.getAbbrev();
00036 
00037   // Iterate through all the attributes until we find the one we're
00038   // looking for, if we can't find it return an empty string.
00039   for (size_t i = 0; i < Values.size(); ++i) {
00040     if (Abbrevs.getData()[i].getAttribute() == Attr) {
00041       DIEValue *V = Values[i];
00042       assert(isa<DIEString>(V) && "String requested. Not a string.");
00043       DIEString *S = cast<DIEString>(V);
00044       return S->getString();
00045     }
00046   }
00047   return StringRef("");
00048 }
00049 
00050 /// \brief Adds the string in \p Str to the hash. This also hashes
00051 /// a trailing NULL with the string.
00052 void DIEHash::addString(StringRef Str) {
00053   DEBUG(dbgs() << "Adding string " << Str << " to hash.\n");
00054   Hash.update(Str);
00055   Hash.update(makeArrayRef((uint8_t)'\0'));
00056 }
00057 
00058 // FIXME: The LEB128 routines are copied and only slightly modified out of
00059 // LEB128.h.
00060 
00061 /// \brief Adds the unsigned in \p Value to the hash encoded as a ULEB128.
00062 void DIEHash::addULEB128(uint64_t Value) {
00063   DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n");
00064   do {
00065     uint8_t Byte = Value & 0x7f;
00066     Value >>= 7;
00067     if (Value != 0)
00068       Byte |= 0x80; // Mark this byte to show that more bytes will follow.
00069     Hash.update(Byte);
00070   } while (Value != 0);
00071 }
00072 
00073 void DIEHash::addSLEB128(int64_t Value) {
00074   DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n");
00075   bool More;
00076   do {
00077     uint8_t Byte = Value & 0x7f;
00078     Value >>= 7;
00079     More = !((((Value == 0) && ((Byte & 0x40) == 0)) ||
00080               ((Value == -1) && ((Byte & 0x40) != 0))));
00081     if (More)
00082       Byte |= 0x80; // Mark this byte to show that more bytes will follow.
00083     Hash.update(Byte);
00084   } while (More);
00085 }
00086 
00087 /// \brief Including \p Parent adds the context of Parent to the hash..
00088 void DIEHash::addParentContext(const DIE &Parent) {
00089 
00090   DEBUG(dbgs() << "Adding parent context to hash...\n");
00091 
00092   // [7.27.2] For each surrounding type or namespace beginning with the
00093   // outermost such construct...
00094   SmallVector<const DIE *, 1> Parents;
00095   const DIE *Cur = &Parent;
00096   while (Cur->getParent()) {
00097     Parents.push_back(Cur);
00098     Cur = Cur->getParent();
00099   }
00100   assert(Cur->getTag() == dwarf::DW_TAG_compile_unit ||
00101          Cur->getTag() == dwarf::DW_TAG_type_unit);
00102 
00103   // Reverse iterate over our list to go from the outermost construct to the
00104   // innermost.
00105   for (SmallVectorImpl<const DIE *>::reverse_iterator I = Parents.rbegin(),
00106                                                       E = Parents.rend();
00107        I != E; ++I) {
00108     const DIE &Die = **I;
00109 
00110     // ... Append the letter "C" to the sequence...
00111     addULEB128('C');
00112 
00113     // ... Followed by the DWARF tag of the construct...
00114     addULEB128(Die.getTag());
00115 
00116     // ... Then the name, taken from the DW_AT_name attribute.
00117     StringRef Name = getDIEStringAttr(Die, dwarf::DW_AT_name);
00118     DEBUG(dbgs() << "... adding context: " << Name << "\n");
00119     if (!Name.empty())
00120       addString(Name);
00121   }
00122 }
00123 
00124 // Collect all of the attributes for a particular DIE in single structure.
00125 void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) {
00126   const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
00127   const DIEAbbrev &Abbrevs = Die.getAbbrev();
00128 
00129 #define COLLECT_ATTR(NAME)                                                     \
00130   case dwarf::NAME:                                                            \
00131     Attrs.NAME.Val = Values[i];                                                \
00132     Attrs.NAME.Desc = &Abbrevs.getData()[i];                                   \
00133     break
00134 
00135   for (size_t i = 0, e = Values.size(); i != e; ++i) {
00136     DEBUG(dbgs() << "Attribute: "
00137                  << dwarf::AttributeString(Abbrevs.getData()[i].getAttribute())
00138                  << " added.\n");
00139     switch (Abbrevs.getData()[i].getAttribute()) {
00140       COLLECT_ATTR(DW_AT_name);
00141       COLLECT_ATTR(DW_AT_accessibility);
00142       COLLECT_ATTR(DW_AT_address_class);
00143       COLLECT_ATTR(DW_AT_allocated);
00144       COLLECT_ATTR(DW_AT_artificial);
00145       COLLECT_ATTR(DW_AT_associated);
00146       COLLECT_ATTR(DW_AT_binary_scale);
00147       COLLECT_ATTR(DW_AT_bit_offset);
00148       COLLECT_ATTR(DW_AT_bit_size);
00149       COLLECT_ATTR(DW_AT_bit_stride);
00150       COLLECT_ATTR(DW_AT_byte_size);
00151       COLLECT_ATTR(DW_AT_byte_stride);
00152       COLLECT_ATTR(DW_AT_const_expr);
00153       COLLECT_ATTR(DW_AT_const_value);
00154       COLLECT_ATTR(DW_AT_containing_type);
00155       COLLECT_ATTR(DW_AT_count);
00156       COLLECT_ATTR(DW_AT_data_bit_offset);
00157       COLLECT_ATTR(DW_AT_data_location);
00158       COLLECT_ATTR(DW_AT_data_member_location);
00159       COLLECT_ATTR(DW_AT_decimal_scale);
00160       COLLECT_ATTR(DW_AT_decimal_sign);
00161       COLLECT_ATTR(DW_AT_default_value);
00162       COLLECT_ATTR(DW_AT_digit_count);
00163       COLLECT_ATTR(DW_AT_discr);
00164       COLLECT_ATTR(DW_AT_discr_list);
00165       COLLECT_ATTR(DW_AT_discr_value);
00166       COLLECT_ATTR(DW_AT_encoding);
00167       COLLECT_ATTR(DW_AT_enum_class);
00168       COLLECT_ATTR(DW_AT_endianity);
00169       COLLECT_ATTR(DW_AT_explicit);
00170       COLLECT_ATTR(DW_AT_is_optional);
00171       COLLECT_ATTR(DW_AT_location);
00172       COLLECT_ATTR(DW_AT_lower_bound);
00173       COLLECT_ATTR(DW_AT_mutable);
00174       COLLECT_ATTR(DW_AT_ordering);
00175       COLLECT_ATTR(DW_AT_picture_string);
00176       COLLECT_ATTR(DW_AT_prototyped);
00177       COLLECT_ATTR(DW_AT_small);
00178       COLLECT_ATTR(DW_AT_segment);
00179       COLLECT_ATTR(DW_AT_string_length);
00180       COLLECT_ATTR(DW_AT_threads_scaled);
00181       COLLECT_ATTR(DW_AT_upper_bound);
00182       COLLECT_ATTR(DW_AT_use_location);
00183       COLLECT_ATTR(DW_AT_use_UTF8);
00184       COLLECT_ATTR(DW_AT_variable_parameter);
00185       COLLECT_ATTR(DW_AT_virtuality);
00186       COLLECT_ATTR(DW_AT_visibility);
00187       COLLECT_ATTR(DW_AT_vtable_elem_location);
00188       COLLECT_ATTR(DW_AT_type);
00189     default:
00190       break;
00191     }
00192   }
00193 }
00194 
00195 void DIEHash::hashShallowTypeReference(dwarf::Attribute Attribute,
00196                                        const DIE &Entry, StringRef Name) {
00197   // append the letter 'N'
00198   addULEB128('N');
00199 
00200   // the DWARF attribute code (DW_AT_type or DW_AT_friend),
00201   addULEB128(Attribute);
00202 
00203   // the context of the tag,
00204   if (const DIE *Parent = Entry.getParent())
00205     addParentContext(*Parent);
00206 
00207   // the letter 'E',
00208   addULEB128('E');
00209 
00210   // and the name of the type.
00211   addString(Name);
00212 
00213   // Currently DW_TAG_friends are not used by Clang, but if they do become so,
00214   // here's the relevant spec text to implement:
00215   //
00216   // For DW_TAG_friend, if the referenced entry is the DW_TAG_subprogram,
00217   // the context is omitted and the name to be used is the ABI-specific name
00218   // of the subprogram (e.g., the mangled linker name).
00219 }
00220 
00221 void DIEHash::hashRepeatedTypeReference(dwarf::Attribute Attribute,
00222                                         unsigned DieNumber) {
00223   // a) If T is in the list of [previously hashed types], use the letter
00224   // 'R' as the marker
00225   addULEB128('R');
00226 
00227   addULEB128(Attribute);
00228 
00229   // and use the unsigned LEB128 encoding of [the index of T in the
00230   // list] as the attribute value;
00231   addULEB128(DieNumber);
00232 }
00233 
00234 void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
00235                            const DIE &Entry) {
00236   assert(Tag != dwarf::DW_TAG_friend && "No current LLVM clients emit friend "
00237                                         "tags. Add support here when there's "
00238                                         "a use case");
00239   // Step 5
00240   // If the tag in Step 3 is one of [the below tags]
00241   if ((Tag == dwarf::DW_TAG_pointer_type ||
00242        Tag == dwarf::DW_TAG_reference_type ||
00243        Tag == dwarf::DW_TAG_rvalue_reference_type ||
00244        Tag == dwarf::DW_TAG_ptr_to_member_type) &&
00245       // and the referenced type (via the [below attributes])
00246       // FIXME: This seems overly restrictive, and causes hash mismatches
00247       // there's a decl/def difference in the containing type of a
00248       // ptr_to_member_type, but it's what DWARF says, for some reason.
00249       Attribute == dwarf::DW_AT_type) {
00250     // ... has a DW_AT_name attribute,
00251     StringRef Name = getDIEStringAttr(Entry, dwarf::DW_AT_name);
00252     if (!Name.empty()) {
00253       hashShallowTypeReference(Attribute, Entry, Name);
00254       return;
00255     }
00256   }
00257 
00258   unsigned &DieNumber = Numbering[&Entry];
00259   if (DieNumber) {
00260     hashRepeatedTypeReference(Attribute, DieNumber);
00261     return;
00262   }
00263 
00264   // otherwise, b) use the letter 'T' as the marker, ...
00265   addULEB128('T');
00266 
00267   addULEB128(Attribute);
00268 
00269   // ... process the type T recursively by performing Steps 2 through 7, and
00270   // use the result as the attribute value.
00271   DieNumber = Numbering.size();
00272   computeHash(Entry);
00273 }
00274 
00275 // Hash all of the values in a block like set of values. This assumes that
00276 // all of the data is going to be added as integers.
00277 void DIEHash::hashBlockData(const SmallVectorImpl<DIEValue *> &Values) {
00278   for (SmallVectorImpl<DIEValue *>::const_iterator I = Values.begin(),
00279                                                    E = Values.end();
00280        I != E; ++I)
00281     Hash.update((uint64_t)cast<DIEInteger>(*I)->getValue());
00282 }
00283 
00284 // Hash the contents of a loclistptr class.
00285 void DIEHash::hashLocList(const DIELocList &LocList) {
00286   HashingByteStreamer Streamer(*this);
00287   DwarfDebug &DD = *AP->getDwarfDebug();
00288   for (const auto &Entry :
00289        DD.getDebugLocEntries()[LocList.getValue()].List)
00290     DD.emitDebugLocEntry(Streamer, Entry);
00291 }
00292 
00293 // Hash an individual attribute \param Attr based on the type of attribute and
00294 // the form.
00295 void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
00296   const DIEValue *Value = Attr.Val;
00297   const DIEAbbrevData *Desc = Attr.Desc;
00298   dwarf::Attribute Attribute = Desc->getAttribute();
00299 
00300   // Other attribute values use the letter 'A' as the marker, and the value
00301   // consists of the form code (encoded as an unsigned LEB128 value) followed by
00302   // the encoding of the value according to the form code. To ensure
00303   // reproducibility of the signature, the set of forms used in the signature
00304   // computation is limited to the following: DW_FORM_sdata, DW_FORM_flag,
00305   // DW_FORM_string, and DW_FORM_block.
00306 
00307   switch (Value->getType()) {
00308     // 7.27 Step 3
00309     // ... An attribute that refers to another type entry T is processed as
00310     // follows:
00311   case DIEValue::isEntry:
00312     hashDIEEntry(Attribute, Tag, cast<DIEEntry>(Value)->getEntry());
00313     break;
00314   case DIEValue::isInteger: {
00315     addULEB128('A');
00316     addULEB128(Attribute);
00317     switch (Desc->getForm()) {
00318     case dwarf::DW_FORM_data1:
00319     case dwarf::DW_FORM_data2:
00320     case dwarf::DW_FORM_data4:
00321     case dwarf::DW_FORM_data8:
00322     case dwarf::DW_FORM_udata:
00323     case dwarf::DW_FORM_sdata:
00324       addULEB128(dwarf::DW_FORM_sdata);
00325       addSLEB128((int64_t)cast<DIEInteger>(Value)->getValue());
00326       break;
00327     // DW_FORM_flag_present is just flag with a value of one. We still give it a
00328     // value so just use the value.
00329     case dwarf::DW_FORM_flag_present:
00330     case dwarf::DW_FORM_flag:
00331       addULEB128(dwarf::DW_FORM_flag);
00332       addULEB128((int64_t)cast<DIEInteger>(Value)->getValue());
00333       break;
00334     default:
00335       llvm_unreachable("Unknown integer form!");
00336     }
00337     break;
00338   }
00339   case DIEValue::isString:
00340     addULEB128('A');
00341     addULEB128(Attribute);
00342     addULEB128(dwarf::DW_FORM_string);
00343     addString(cast<DIEString>(Value)->getString());
00344     break;
00345   case DIEValue::isBlock:
00346   case DIEValue::isLoc:
00347   case DIEValue::isLocList:
00348     addULEB128('A');
00349     addULEB128(Attribute);
00350     addULEB128(dwarf::DW_FORM_block);
00351     if (isa<DIEBlock>(Value)) {
00352       addULEB128(cast<DIEBlock>(Value)->ComputeSize(AP));
00353       hashBlockData(cast<DIEBlock>(Value)->getValues());
00354     } else if (isa<DIELoc>(Value)) {
00355       addULEB128(cast<DIELoc>(Value)->ComputeSize(AP));
00356       hashBlockData(cast<DIELoc>(Value)->getValues());
00357     } else {
00358       // We could add the block length, but that would take
00359       // a bit of work and not add a lot of uniqueness
00360       // to the hash in some way we could test.
00361       hashLocList(*cast<DIELocList>(Value));
00362     }
00363     break;
00364     // FIXME: It's uncertain whether or not we should handle this at the moment.
00365   case DIEValue::isExpr:
00366   case DIEValue::isLabel:
00367   case DIEValue::isDelta:
00368   case DIEValue::isTypeSignature:
00369     llvm_unreachable("Add support for additional value types.");
00370   }
00371 }
00372 
00373 // Go through the attributes from \param Attrs in the order specified in 7.27.4
00374 // and hash them.
00375 void DIEHash::hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag) {
00376 #define ADD_ATTR(ATTR)                                                         \
00377   {                                                                            \
00378     if (ATTR.Val != 0)                                                         \
00379       hashAttribute(ATTR, Tag);                                                \
00380   }
00381 
00382   ADD_ATTR(Attrs.DW_AT_name);
00383   ADD_ATTR(Attrs.DW_AT_accessibility);
00384   ADD_ATTR(Attrs.DW_AT_address_class);
00385   ADD_ATTR(Attrs.DW_AT_allocated);
00386   ADD_ATTR(Attrs.DW_AT_artificial);
00387   ADD_ATTR(Attrs.DW_AT_associated);
00388   ADD_ATTR(Attrs.DW_AT_binary_scale);
00389   ADD_ATTR(Attrs.DW_AT_bit_offset);
00390   ADD_ATTR(Attrs.DW_AT_bit_size);
00391   ADD_ATTR(Attrs.DW_AT_bit_stride);
00392   ADD_ATTR(Attrs.DW_AT_byte_size);
00393   ADD_ATTR(Attrs.DW_AT_byte_stride);
00394   ADD_ATTR(Attrs.DW_AT_const_expr);
00395   ADD_ATTR(Attrs.DW_AT_const_value);
00396   ADD_ATTR(Attrs.DW_AT_containing_type);
00397   ADD_ATTR(Attrs.DW_AT_count);
00398   ADD_ATTR(Attrs.DW_AT_data_bit_offset);
00399   ADD_ATTR(Attrs.DW_AT_data_location);
00400   ADD_ATTR(Attrs.DW_AT_data_member_location);
00401   ADD_ATTR(Attrs.DW_AT_decimal_scale);
00402   ADD_ATTR(Attrs.DW_AT_decimal_sign);
00403   ADD_ATTR(Attrs.DW_AT_default_value);
00404   ADD_ATTR(Attrs.DW_AT_digit_count);
00405   ADD_ATTR(Attrs.DW_AT_discr);
00406   ADD_ATTR(Attrs.DW_AT_discr_list);
00407   ADD_ATTR(Attrs.DW_AT_discr_value);
00408   ADD_ATTR(Attrs.DW_AT_encoding);
00409   ADD_ATTR(Attrs.DW_AT_enum_class);
00410   ADD_ATTR(Attrs.DW_AT_endianity);
00411   ADD_ATTR(Attrs.DW_AT_explicit);
00412   ADD_ATTR(Attrs.DW_AT_is_optional);
00413   ADD_ATTR(Attrs.DW_AT_location);
00414   ADD_ATTR(Attrs.DW_AT_lower_bound);
00415   ADD_ATTR(Attrs.DW_AT_mutable);
00416   ADD_ATTR(Attrs.DW_AT_ordering);
00417   ADD_ATTR(Attrs.DW_AT_picture_string);
00418   ADD_ATTR(Attrs.DW_AT_prototyped);
00419   ADD_ATTR(Attrs.DW_AT_small);
00420   ADD_ATTR(Attrs.DW_AT_segment);
00421   ADD_ATTR(Attrs.DW_AT_string_length);
00422   ADD_ATTR(Attrs.DW_AT_threads_scaled);
00423   ADD_ATTR(Attrs.DW_AT_upper_bound);
00424   ADD_ATTR(Attrs.DW_AT_use_location);
00425   ADD_ATTR(Attrs.DW_AT_use_UTF8);
00426   ADD_ATTR(Attrs.DW_AT_variable_parameter);
00427   ADD_ATTR(Attrs.DW_AT_virtuality);
00428   ADD_ATTR(Attrs.DW_AT_visibility);
00429   ADD_ATTR(Attrs.DW_AT_vtable_elem_location);
00430   ADD_ATTR(Attrs.DW_AT_type);
00431 
00432   // FIXME: Add the extended attributes.
00433 }
00434 
00435 // Add all of the attributes for \param Die to the hash.
00436 void DIEHash::addAttributes(const DIE &Die) {
00437   DIEAttrs Attrs = {};
00438   collectAttributes(Die, Attrs);
00439   hashAttributes(Attrs, Die.getTag());
00440 }
00441 
00442 void DIEHash::hashNestedType(const DIE &Die, StringRef Name) {
00443   // 7.27 Step 7
00444   // ... append the letter 'S',
00445   addULEB128('S');
00446 
00447   // the tag of C,
00448   addULEB128(Die.getTag());
00449 
00450   // and the name.
00451   addString(Name);
00452 }
00453 
00454 // Compute the hash of a DIE. This is based on the type signature computation
00455 // given in section 7.27 of the DWARF4 standard. It is the md5 hash of a
00456 // flattened description of the DIE.
00457 void DIEHash::computeHash(const DIE &Die) {
00458   // Append the letter 'D', followed by the DWARF tag of the DIE.
00459   addULEB128('D');
00460   addULEB128(Die.getTag());
00461 
00462   // Add each of the attributes of the DIE.
00463   addAttributes(Die);
00464 
00465   // Then hash each of the children of the DIE.
00466   for (auto &C : Die.getChildren()) {
00467     // 7.27 Step 7
00468     // If C is a nested type entry or a member function entry, ...
00469     if (isType(C->getTag()) || C->getTag() == dwarf::DW_TAG_subprogram) {
00470       StringRef Name = getDIEStringAttr(*C, dwarf::DW_AT_name);
00471       // ... and has a DW_AT_name attribute
00472       if (!Name.empty()) {
00473         hashNestedType(*C, Name);
00474         continue;
00475       }
00476     }
00477     computeHash(*C);
00478   }
00479 
00480   // Following the last (or if there are no children), append a zero byte.
00481   Hash.update(makeArrayRef((uint8_t)'\0'));
00482 }
00483 
00484 /// This is based on the type signature computation given in section 7.27 of the
00485 /// DWARF4 standard. It is the md5 hash of a flattened description of the DIE
00486 /// with the exception that we are hashing only the context and the name of the
00487 /// type.
00488 uint64_t DIEHash::computeDIEODRSignature(const DIE &Die) {
00489 
00490   // Add the contexts to the hash. We won't be computing the ODR hash for
00491   // function local types so it's safe to use the generic context hashing
00492   // algorithm here.
00493   // FIXME: If we figure out how to account for linkage in some way we could
00494   // actually do this with a slight modification to the parent hash algorithm.
00495   if (const DIE *Parent = Die.getParent())
00496     addParentContext(*Parent);
00497 
00498   // Add the current DIE information.
00499 
00500   // Add the DWARF tag of the DIE.
00501   addULEB128(Die.getTag());
00502 
00503   // Add the name of the type to the hash.
00504   addString(getDIEStringAttr(Die, dwarf::DW_AT_name));
00505 
00506   // Now get the result.
00507   MD5::MD5Result Result;
00508   Hash.final(Result);
00509 
00510   // ... take the least significant 8 bytes and return those. Our MD5
00511   // implementation always returns its results in little endian, swap bytes
00512   // appropriately.
00513   return *reinterpret_cast<support::ulittle64_t *>(Result + 8);
00514 }
00515 
00516 /// This is based on the type signature computation given in section 7.27 of the
00517 /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE
00518 /// with the inclusion of the full CU and all top level CU entities.
00519 // TODO: Initialize the type chain at 0 instead of 1 for CU signatures.
00520 uint64_t DIEHash::computeCUSignature(const DIE &Die) {
00521   Numbering.clear();
00522   Numbering[&Die] = 1;
00523 
00524   // Hash the DIE.
00525   computeHash(Die);
00526 
00527   // Now return the result.
00528   MD5::MD5Result Result;
00529   Hash.final(Result);
00530 
00531   // ... take the least significant 8 bytes and return those. Our MD5
00532   // implementation always returns its results in little endian, swap bytes
00533   // appropriately.
00534   return *reinterpret_cast<support::ulittle64_t *>(Result + 8);
00535 }
00536 
00537 /// This is based on the type signature computation given in section 7.27 of the
00538 /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE
00539 /// with the inclusion of additional forms not specifically called out in the
00540 /// standard.
00541 uint64_t DIEHash::computeTypeSignature(const DIE &Die) {
00542   Numbering.clear();
00543   Numbering[&Die] = 1;
00544 
00545   if (const DIE *Parent = Die.getParent())
00546     addParentContext(*Parent);
00547 
00548   // Hash the DIE.
00549   computeHash(Die);
00550 
00551   // Now return the result.
00552   MD5::MD5Result Result;
00553   Hash.final(Result);
00554 
00555   // ... take the least significant 8 bytes and return those. Our MD5
00556   // implementation always returns its results in little endian, swap bytes
00557   // appropriately.
00558   return *reinterpret_cast<support::ulittle64_t *>(Result + 8);
00559 }