DIEHash: Include the trailing zero byte after the children of a DIE
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 16 Oct 2013 20:29:06 +0000 (20:29 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 16 Oct 2013 20:29:06 +0000 (20:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192836 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DIEHash.cpp
unittests/CodeGen/DIEHashTest.cpp

index c56d2e64730841d00f8af2fca77dbb4d3e99a923..abc504c0581c0abef47f5b01509d5490633b2b61 100644 (file)
@@ -383,6 +383,9 @@ void DIEHash::computeHash(DIE *Die) {
                                           E = Die->getChildren().end();
        I != E; ++I)
     computeHash(*I);
+
+  // Following the last (or if there are no children), append a zero byte.
+  Hash.update((uint8_t)0);
 }
 
 /// This is based on the type signature computation given in section 7.27 of the
index 6b9a4dbc26a6fc48f1819603b710107b25ae4fe8..86358d5d31a3647f11f2b6bd22d4cb56d94b2870 100644 (file)
@@ -23,6 +23,6 @@ TEST(DIEHashData1Test, DIEHash) {
   DIEInteger Size(4);
   Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Size);
   uint64_t MD5Res = Hash.computeTypeSignature(&Die);
-  ASSERT_EQ(MD5Res, 0x540e9ff30ade3e4aULL);
+  ASSERT_EQ(MD5Res, 0x4F68EF1039F8D2BULL);
 }
 }