DIEHash.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. //===-- llvm/CodeGen/DIEHash.cpp - Dwarf Hashing Framework ----------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains support for DWARF4 hashing of DIEs.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "ByteStreamer.h"
  14. #include "DIEHash.h"
  15. #include "DwarfDebug.h"
  16. #include "llvm/ADT/ArrayRef.h"
  17. #include "llvm/ADT/StringRef.h"
  18. #include "llvm/CodeGen/AsmPrinter.h"
  19. #include "llvm/CodeGen/DIE.h"
  20. #include "llvm/Support/Debug.h"
  21. #include "llvm/Support/Dwarf.h"
  22. #include "llvm/Support/Endian.h"
  23. #include "llvm/Support/MD5.h"
  24. #include "llvm/Support/raw_ostream.h"
  25. using namespace llvm;
  26. #define DEBUG_TYPE "dwarfdebug"
  27. /// \brief Grabs the string in whichever attribute is passed in and returns
  28. /// a reference to it.
  29. static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr) {
  30. // Iterate through all the attributes until we find the one we're
  31. // looking for, if we can't find it return an empty string.
  32. for (const auto &V : Die.values())
  33. if (V.getAttribute() == Attr)
  34. return V.getDIEString().getString();
  35. return StringRef("");
  36. }
  37. /// \brief Adds the string in \p Str to the hash. This also hashes
  38. /// a trailing NULL with the string.
  39. void DIEHash::addString(StringRef Str) {
  40. DEBUG(dbgs() << "Adding string " << Str << " to hash.\n");
  41. Hash.update(Str);
  42. Hash.update(makeArrayRef((uint8_t)'\0'));
  43. }
  44. // FIXME: The LEB128 routines are copied and only slightly modified out of
  45. // LEB128.h.
  46. /// \brief Adds the unsigned in \p Value to the hash encoded as a ULEB128.
  47. void DIEHash::addULEB128(uint64_t Value) {
  48. DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n");
  49. do {
  50. uint8_t Byte = Value & 0x7f;
  51. Value >>= 7;
  52. if (Value != 0)
  53. Byte |= 0x80; // Mark this byte to show that more bytes will follow.
  54. Hash.update(Byte);
  55. } while (Value != 0);
  56. }
  57. void DIEHash::addSLEB128(int64_t Value) {
  58. DEBUG(dbgs() << "Adding ULEB128 " << Value << " to hash.\n");
  59. bool More;
  60. do {
  61. uint8_t Byte = Value & 0x7f;
  62. Value >>= 7;
  63. More = !((((Value == 0) && ((Byte & 0x40) == 0)) ||
  64. ((Value == -1) && ((Byte & 0x40) != 0))));
  65. if (More)
  66. Byte |= 0x80; // Mark this byte to show that more bytes will follow.
  67. Hash.update(Byte);
  68. } while (More);
  69. }
  70. /// \brief Including \p Parent adds the context of Parent to the hash..
  71. void DIEHash::addParentContext(const DIE &Parent) {
  72. DEBUG(dbgs() << "Adding parent context to hash...\n");
  73. // [7.27.2] For each surrounding type or namespace beginning with the
  74. // outermost such construct...
  75. SmallVector<const DIE *, 1> Parents;
  76. const DIE *Cur = &Parent;
  77. while (Cur->getParent()) {
  78. Parents.push_back(Cur);
  79. Cur = Cur->getParent();
  80. }
  81. assert(Cur->getTag() == dwarf::DW_TAG_compile_unit ||
  82. Cur->getTag() == dwarf::DW_TAG_type_unit);
  83. // Reverse iterate over our list to go from the outermost construct to the
  84. // innermost.
  85. for (SmallVectorImpl<const DIE *>::reverse_iterator I = Parents.rbegin(),
  86. E = Parents.rend();
  87. I != E; ++I) {
  88. const DIE &Die = **I;
  89. // ... Append the letter "C" to the sequence...
  90. addULEB128('C');
  91. // ... Followed by the DWARF tag of the construct...
  92. addULEB128(Die.getTag());
  93. // ... Then the name, taken from the DW_AT_name attribute.
  94. StringRef Name = getDIEStringAttr(Die, dwarf::DW_AT_name);
  95. DEBUG(dbgs() << "... adding context: " << Name << "\n");
  96. if (!Name.empty())
  97. addString(Name);
  98. }
  99. }
  100. // Collect all of the attributes for a particular DIE in single structure.
  101. void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) {
  102. #define COLLECT_ATTR(NAME) \
  103. case dwarf::NAME: \
  104. Attrs.NAME = V; \
  105. break
  106. for (const auto &V : Die.values()) {
  107. DEBUG(dbgs() << "Attribute: "
  108. << dwarf::AttributeString(V.getAttribute())
  109. << " added.\n");
  110. switch (V.getAttribute()) {
  111. COLLECT_ATTR(DW_AT_name);
  112. COLLECT_ATTR(DW_AT_accessibility);
  113. COLLECT_ATTR(DW_AT_address_class);
  114. COLLECT_ATTR(DW_AT_allocated);
  115. COLLECT_ATTR(DW_AT_artificial);
  116. COLLECT_ATTR(DW_AT_associated);
  117. COLLECT_ATTR(DW_AT_binary_scale);
  118. COLLECT_ATTR(DW_AT_bit_offset);
  119. COLLECT_ATTR(DW_AT_bit_size);
  120. COLLECT_ATTR(DW_AT_bit_stride);
  121. COLLECT_ATTR(DW_AT_byte_size);
  122. COLLECT_ATTR(DW_AT_byte_stride);
  123. COLLECT_ATTR(DW_AT_const_expr);
  124. COLLECT_ATTR(DW_AT_const_value);
  125. COLLECT_ATTR(DW_AT_containing_type);
  126. COLLECT_ATTR(DW_AT_count);
  127. COLLECT_ATTR(DW_AT_data_bit_offset);
  128. COLLECT_ATTR(DW_AT_data_location);
  129. COLLECT_ATTR(DW_AT_data_member_location);
  130. COLLECT_ATTR(DW_AT_decimal_scale);
  131. COLLECT_ATTR(DW_AT_decimal_sign);
  132. COLLECT_ATTR(DW_AT_default_value);
  133. COLLECT_ATTR(DW_AT_digit_count);
  134. COLLECT_ATTR(DW_AT_discr);
  135. COLLECT_ATTR(DW_AT_discr_list);
  136. COLLECT_ATTR(DW_AT_discr_value);
  137. COLLECT_ATTR(DW_AT_encoding);
  138. COLLECT_ATTR(DW_AT_enum_class);
  139. COLLECT_ATTR(DW_AT_endianity);
  140. COLLECT_ATTR(DW_AT_explicit);
  141. COLLECT_ATTR(DW_AT_is_optional);
  142. COLLECT_ATTR(DW_AT_location);
  143. COLLECT_ATTR(DW_AT_lower_bound);
  144. COLLECT_ATTR(DW_AT_mutable);
  145. COLLECT_ATTR(DW_AT_ordering);
  146. COLLECT_ATTR(DW_AT_picture_string);
  147. COLLECT_ATTR(DW_AT_prototyped);
  148. COLLECT_ATTR(DW_AT_small);
  149. COLLECT_ATTR(DW_AT_segment);
  150. COLLECT_ATTR(DW_AT_string_length);
  151. COLLECT_ATTR(DW_AT_threads_scaled);
  152. COLLECT_ATTR(DW_AT_upper_bound);
  153. COLLECT_ATTR(DW_AT_use_location);
  154. COLLECT_ATTR(DW_AT_use_UTF8);
  155. COLLECT_ATTR(DW_AT_variable_parameter);
  156. COLLECT_ATTR(DW_AT_virtuality);
  157. COLLECT_ATTR(DW_AT_visibility);
  158. COLLECT_ATTR(DW_AT_vtable_elem_location);
  159. COLLECT_ATTR(DW_AT_type);
  160. default:
  161. break;
  162. }
  163. }
  164. }
  165. void DIEHash::hashShallowTypeReference(dwarf::Attribute Attribute,
  166. const DIE &Entry, StringRef Name) {
  167. // append the letter 'N'
  168. addULEB128('N');
  169. // the DWARF attribute code (DW_AT_type or DW_AT_friend),
  170. addULEB128(Attribute);
  171. // the context of the tag,
  172. if (const DIE *Parent = Entry.getParent())
  173. addParentContext(*Parent);
  174. // the letter 'E',
  175. addULEB128('E');
  176. // and the name of the type.
  177. addString(Name);
  178. // Currently DW_TAG_friends are not used by Clang, but if they do become so,
  179. // here's the relevant spec text to implement:
  180. //
  181. // For DW_TAG_friend, if the referenced entry is the DW_TAG_subprogram,
  182. // the context is omitted and the name to be used is the ABI-specific name
  183. // of the subprogram (e.g., the mangled linker name).
  184. }
  185. void DIEHash::hashRepeatedTypeReference(dwarf::Attribute Attribute,
  186. unsigned DieNumber) {
  187. // a) If T is in the list of [previously hashed types], use the letter
  188. // 'R' as the marker
  189. addULEB128('R');
  190. addULEB128(Attribute);
  191. // and use the unsigned LEB128 encoding of [the index of T in the
  192. // list] as the attribute value;
  193. addULEB128(DieNumber);
  194. }
  195. void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
  196. const DIE &Entry) {
  197. assert(Tag != dwarf::DW_TAG_friend && "No current LLVM clients emit friend "
  198. "tags. Add support here when there's "
  199. "a use case");
  200. // Step 5
  201. // If the tag in Step 3 is one of [the below tags]
  202. if ((Tag == dwarf::DW_TAG_pointer_type ||
  203. Tag == dwarf::DW_TAG_reference_type ||
  204. Tag == dwarf::DW_TAG_rvalue_reference_type ||
  205. Tag == dwarf::DW_TAG_ptr_to_member_type) &&
  206. // and the referenced type (via the [below attributes])
  207. // FIXME: This seems overly restrictive, and causes hash mismatches
  208. // there's a decl/def difference in the containing type of a
  209. // ptr_to_member_type, but it's what DWARF says, for some reason.
  210. Attribute == dwarf::DW_AT_type) {
  211. // ... has a DW_AT_name attribute,
  212. StringRef Name = getDIEStringAttr(Entry, dwarf::DW_AT_name);
  213. if (!Name.empty()) {
  214. hashShallowTypeReference(Attribute, Entry, Name);
  215. return;
  216. }
  217. }
  218. unsigned &DieNumber = Numbering[&Entry];
  219. if (DieNumber) {
  220. hashRepeatedTypeReference(Attribute, DieNumber);
  221. return;
  222. }
  223. // otherwise, b) use the letter 'T' as the marker, ...
  224. addULEB128('T');
  225. addULEB128(Attribute);
  226. // ... process the type T recursively by performing Steps 2 through 7, and
  227. // use the result as the attribute value.
  228. DieNumber = Numbering.size();
  229. computeHash(Entry);
  230. }
  231. // Hash all of the values in a block like set of values. This assumes that
  232. // all of the data is going to be added as integers.
  233. void DIEHash::hashBlockData(const DIE::const_value_range &Values) {
  234. for (const auto &V : Values)
  235. Hash.update((uint64_t)V.getDIEInteger().getValue());
  236. }
  237. // Hash the contents of a loclistptr class.
  238. void DIEHash::hashLocList(const DIELocList &LocList) {
  239. HashingByteStreamer Streamer(*this);
  240. DwarfDebug &DD = *AP->getDwarfDebug();
  241. const DebugLocStream &Locs = DD.getDebugLocs();
  242. for (const auto &Entry : Locs.getEntries(Locs.getList(LocList.getValue())))
  243. DD.emitDebugLocEntry(Streamer, Entry);
  244. }
  245. // Hash an individual attribute \param Attr based on the type of attribute and
  246. // the form.
  247. void DIEHash::hashAttribute(DIEValue Value, dwarf::Tag Tag) {
  248. dwarf::Attribute Attribute = Value.getAttribute();
  249. // Other attribute values use the letter 'A' as the marker, and the value
  250. // consists of the form code (encoded as an unsigned LEB128 value) followed by
  251. // the encoding of the value according to the form code. To ensure
  252. // reproducibility of the signature, the set of forms used in the signature
  253. // computation is limited to the following: DW_FORM_sdata, DW_FORM_flag,
  254. // DW_FORM_string, and DW_FORM_block.
  255. switch (Value.getType()) {
  256. case DIEValue::isNone:
  257. llvm_unreachable("Expected valid DIEValue");
  258. // 7.27 Step 3
  259. // ... An attribute that refers to another type entry T is processed as
  260. // follows:
  261. case DIEValue::isEntry:
  262. hashDIEEntry(Attribute, Tag, Value.getDIEEntry().getEntry());
  263. break;
  264. case DIEValue::isInteger: {
  265. addULEB128('A');
  266. addULEB128(Attribute);
  267. switch (Value.getForm()) {
  268. case dwarf::DW_FORM_data1:
  269. case dwarf::DW_FORM_data2:
  270. case dwarf::DW_FORM_data4:
  271. case dwarf::DW_FORM_data8:
  272. case dwarf::DW_FORM_udata:
  273. case dwarf::DW_FORM_sdata:
  274. addULEB128(dwarf::DW_FORM_sdata);
  275. addSLEB128((int64_t)Value.getDIEInteger().getValue());
  276. break;
  277. // DW_FORM_flag_present is just flag with a value of one. We still give it a
  278. // value so just use the value.
  279. case dwarf::DW_FORM_flag_present:
  280. case dwarf::DW_FORM_flag:
  281. addULEB128(dwarf::DW_FORM_flag);
  282. addULEB128((int64_t)Value.getDIEInteger().getValue());
  283. break;
  284. default:
  285. llvm_unreachable("Unknown integer form!");
  286. }
  287. break;
  288. }
  289. case DIEValue::isString:
  290. addULEB128('A');
  291. addULEB128(Attribute);
  292. addULEB128(dwarf::DW_FORM_string);
  293. addString(Value.getDIEString().getString());
  294. break;
  295. case DIEValue::isBlock:
  296. case DIEValue::isLoc:
  297. case DIEValue::isLocList:
  298. addULEB128('A');
  299. addULEB128(Attribute);
  300. addULEB128(dwarf::DW_FORM_block);
  301. if (Value.getType() == DIEValue::isBlock) {
  302. addULEB128(Value.getDIEBlock().ComputeSize(AP));
  303. hashBlockData(Value.getDIEBlock().values());
  304. } else if (Value.getType() == DIEValue::isLoc) {
  305. addULEB128(Value.getDIELoc().ComputeSize(AP));
  306. hashBlockData(Value.getDIELoc().values());
  307. } else {
  308. // We could add the block length, but that would take
  309. // a bit of work and not add a lot of uniqueness
  310. // to the hash in some way we could test.
  311. hashLocList(Value.getDIELocList());
  312. }
  313. break;
  314. // FIXME: It's uncertain whether or not we should handle this at the moment.
  315. case DIEValue::isExpr:
  316. case DIEValue::isLabel:
  317. case DIEValue::isDelta:
  318. case DIEValue::isTypeSignature:
  319. llvm_unreachable("Add support for additional value types.");
  320. }
  321. }
  322. // Go through the attributes from \param Attrs in the order specified in 7.27.4
  323. // and hash them.
  324. void DIEHash::hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag) {
  325. #define ADD_ATTR(ATTR) \
  326. { \
  327. if (ATTR) \
  328. hashAttribute(ATTR, Tag); \
  329. }
  330. ADD_ATTR(Attrs.DW_AT_name);
  331. ADD_ATTR(Attrs.DW_AT_accessibility);
  332. ADD_ATTR(Attrs.DW_AT_address_class);
  333. ADD_ATTR(Attrs.DW_AT_allocated);
  334. ADD_ATTR(Attrs.DW_AT_artificial);
  335. ADD_ATTR(Attrs.DW_AT_associated);
  336. ADD_ATTR(Attrs.DW_AT_binary_scale);
  337. ADD_ATTR(Attrs.DW_AT_bit_offset);
  338. ADD_ATTR(Attrs.DW_AT_bit_size);
  339. ADD_ATTR(Attrs.DW_AT_bit_stride);
  340. ADD_ATTR(Attrs.DW_AT_byte_size);
  341. ADD_ATTR(Attrs.DW_AT_byte_stride);
  342. ADD_ATTR(Attrs.DW_AT_const_expr);
  343. ADD_ATTR(Attrs.DW_AT_const_value);
  344. ADD_ATTR(Attrs.DW_AT_containing_type);
  345. ADD_ATTR(Attrs.DW_AT_count);
  346. ADD_ATTR(Attrs.DW_AT_data_bit_offset);
  347. ADD_ATTR(Attrs.DW_AT_data_location);
  348. ADD_ATTR(Attrs.DW_AT_data_member_location);
  349. ADD_ATTR(Attrs.DW_AT_decimal_scale);
  350. ADD_ATTR(Attrs.DW_AT_decimal_sign);
  351. ADD_ATTR(Attrs.DW_AT_default_value);
  352. ADD_ATTR(Attrs.DW_AT_digit_count);
  353. ADD_ATTR(Attrs.DW_AT_discr);
  354. ADD_ATTR(Attrs.DW_AT_discr_list);
  355. ADD_ATTR(Attrs.DW_AT_discr_value);
  356. ADD_ATTR(Attrs.DW_AT_encoding);
  357. ADD_ATTR(Attrs.DW_AT_enum_class);
  358. ADD_ATTR(Attrs.DW_AT_endianity);
  359. ADD_ATTR(Attrs.DW_AT_explicit);
  360. ADD_ATTR(Attrs.DW_AT_is_optional);
  361. ADD_ATTR(Attrs.DW_AT_location);
  362. ADD_ATTR(Attrs.DW_AT_lower_bound);
  363. ADD_ATTR(Attrs.DW_AT_mutable);
  364. ADD_ATTR(Attrs.DW_AT_ordering);
  365. ADD_ATTR(Attrs.DW_AT_picture_string);
  366. ADD_ATTR(Attrs.DW_AT_prototyped);
  367. ADD_ATTR(Attrs.DW_AT_small);
  368. ADD_ATTR(Attrs.DW_AT_segment);
  369. ADD_ATTR(Attrs.DW_AT_string_length);
  370. ADD_ATTR(Attrs.DW_AT_threads_scaled);
  371. ADD_ATTR(Attrs.DW_AT_upper_bound);
  372. ADD_ATTR(Attrs.DW_AT_use_location);
  373. ADD_ATTR(Attrs.DW_AT_use_UTF8);
  374. ADD_ATTR(Attrs.DW_AT_variable_parameter);
  375. ADD_ATTR(Attrs.DW_AT_virtuality);
  376. ADD_ATTR(Attrs.DW_AT_visibility);
  377. ADD_ATTR(Attrs.DW_AT_vtable_elem_location);
  378. ADD_ATTR(Attrs.DW_AT_type);
  379. // FIXME: Add the extended attributes.
  380. }
  381. // Add all of the attributes for \param Die to the hash.
  382. void DIEHash::addAttributes(const DIE &Die) {
  383. DIEAttrs Attrs = {};
  384. collectAttributes(Die, Attrs);
  385. hashAttributes(Attrs, Die.getTag());
  386. }
  387. void DIEHash::hashNestedType(const DIE &Die, StringRef Name) {
  388. // 7.27 Step 7
  389. // ... append the letter 'S',
  390. addULEB128('S');
  391. // the tag of C,
  392. addULEB128(Die.getTag());
  393. // and the name.
  394. addString(Name);
  395. }
  396. // Compute the hash of a DIE. This is based on the type signature computation
  397. // given in section 7.27 of the DWARF4 standard. It is the md5 hash of a
  398. // flattened description of the DIE.
  399. void DIEHash::computeHash(const DIE &Die) {
  400. // Append the letter 'D', followed by the DWARF tag of the DIE.
  401. addULEB128('D');
  402. addULEB128(Die.getTag());
  403. // Add each of the attributes of the DIE.
  404. addAttributes(Die);
  405. // Then hash each of the children of the DIE.
  406. for (auto &C : Die.children()) {
  407. // 7.27 Step 7
  408. // If C is a nested type entry or a member function entry, ...
  409. if (isType(C.getTag()) || C.getTag() == dwarf::DW_TAG_subprogram) {
  410. StringRef Name = getDIEStringAttr(C, dwarf::DW_AT_name);
  411. // ... and has a DW_AT_name attribute
  412. if (!Name.empty()) {
  413. hashNestedType(C, Name);
  414. continue;
  415. }
  416. }
  417. computeHash(C);
  418. }
  419. // Following the last (or if there are no children), append a zero byte.
  420. Hash.update(makeArrayRef((uint8_t)'\0'));
  421. }
  422. /// This is based on the type signature computation given in section 7.27 of the
  423. /// DWARF4 standard. It is the md5 hash of a flattened description of the DIE
  424. /// with the exception that we are hashing only the context and the name of the
  425. /// type.
  426. uint64_t DIEHash::computeDIEODRSignature(const DIE &Die) {
  427. // Add the contexts to the hash. We won't be computing the ODR hash for
  428. // function local types so it's safe to use the generic context hashing
  429. // algorithm here.
  430. // FIXME: If we figure out how to account for linkage in some way we could
  431. // actually do this with a slight modification to the parent hash algorithm.
  432. if (const DIE *Parent = Die.getParent())
  433. addParentContext(*Parent);
  434. // Add the current DIE information.
  435. // Add the DWARF tag of the DIE.
  436. addULEB128(Die.getTag());
  437. // Add the name of the type to the hash.
  438. addString(getDIEStringAttr(Die, dwarf::DW_AT_name));
  439. // Now get the result.
  440. MD5::MD5Result Result;
  441. Hash.final(Result);
  442. // ... take the least significant 8 bytes and return those. Our MD5
  443. // implementation always returns its results in little endian, swap bytes
  444. // appropriately.
  445. return support::endian::read64le(Result + 8);
  446. }
  447. /// This is based on the type signature computation given in section 7.27 of the
  448. /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE
  449. /// with the inclusion of the full CU and all top level CU entities.
  450. // TODO: Initialize the type chain at 0 instead of 1 for CU signatures.
  451. uint64_t DIEHash::computeCUSignature(const DIE &Die) {
  452. Numbering.clear();
  453. Numbering[&Die] = 1;
  454. // Hash the DIE.
  455. computeHash(Die);
  456. // Now return the result.
  457. MD5::MD5Result Result;
  458. Hash.final(Result);
  459. // ... take the least significant 8 bytes and return those. Our MD5
  460. // implementation always returns its results in little endian, swap bytes
  461. // appropriately.
  462. return support::endian::read64le(Result + 8);
  463. }
  464. /// This is based on the type signature computation given in section 7.27 of the
  465. /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE
  466. /// with the inclusion of additional forms not specifically called out in the
  467. /// standard.
  468. uint64_t DIEHash::computeTypeSignature(const DIE &Die) {
  469. Numbering.clear();
  470. Numbering[&Die] = 1;
  471. if (const DIE *Parent = Die.getParent())
  472. addParentContext(*Parent);
  473. // Hash the DIE.
  474. computeHash(Die);
  475. // Now return the result.
  476. MD5::MD5Result Result;
  477. Hash.final(Result);
  478. // ... take the least significant 8 bytes and return those. Our MD5
  479. // implementation always returns its results in little endian, swap bytes
  480. // appropriately.
  481. return support::endian::read64le(Result + 8);
  482. }