diff options
author | Eric Christopher <echristo@gmail.com> | 2013-09-03 21:57:57 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2013-09-03 21:57:57 +0000 |
commit | 25b7adc8cecc675ff238681c0fae75cdffd4ff91 (patch) | |
tree | 341b01464ef0d7108563dd9dec4242764aea8575 /llvm/lib/CodeGen/AsmPrinter | |
parent | b86e2ad8190c8b70d2ee35bcc0faceae56e19637 (diff) | |
download | bcm5719-llvm-25b7adc8cecc675ff238681c0fae75cdffd4ff91.tar.gz bcm5719-llvm-25b7adc8cecc675ff238681c0fae75cdffd4ff91.zip |
Add a hashing routine that handles hashing types. Add a test for
hashing the contents of DW_FORM_data1 on top of a type with attributes.
llvm-svn: 189862
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp | 20 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIEHash.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp index 1581c9682da..519c8a00685 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -422,6 +422,7 @@ uint64_t DIEHash::computeDIEODRSignature(DIE *Die) { /// This is based on the type signature computation given in section 7.27 of the /// DWARF4 standard. It is an md5 hash of the flattened description of the DIE /// with the inclusion of the full CU and all top level CU entities. +// TODO: Initialize the type chain at 0 instead of 1 for CU signatures. uint64_t DIEHash::computeCUSignature(DIE *Die) { // Hash the DIE. @@ -436,3 +437,22 @@ uint64_t DIEHash::computeCUSignature(DIE *Die) { // appropriately. return *reinterpret_cast<support::ulittle64_t *>(Result + 8); } + +/// This is based on the type signature computation given in section 7.27 of the +/// DWARF4 standard. It is an md5 hash of the flattened description of the DIE +/// with the inclusion of additional forms not specifically called out in the +/// standard. +uint64_t DIEHash::computeTypeSignature(DIE *Die) { + + // Hash the DIE. + computeHash(Die); + + // Now return the result. + MD5::MD5Result Result; + Hash.final(Result); + + // ... take the least significant 8 bytes and return those. Our MD5 + // implementation always returns its results in little endian, swap bytes + // appropriately. + return *reinterpret_cast<support::ulittle64_t *>(Result + 8); +} diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h index f98b56dd73b..b792aeab6ce 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.h +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.h @@ -87,6 +87,9 @@ public: /// \brief Computes the CU signature. uint64_t computeCUSignature(DIE *Die); + /// \brief Computes the type signature. + uint64_t computeTypeSignature(DIE *Die); + // Helper routines to process parts of a DIE. private: /// \brief Adds the parent context of \param Die to the hash. |