From e9525a4ff2dc0453211a897597d65908c8c3e082 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 25 Oct 2013 20:04:25 +0000 Subject: [PATCH] DIEHash: Summary hashing of member functions llvm-svn: 193432 --- lib/CodeGen/AsmPrinter/DIEHash.cpp | 2 +- unittests/CodeGen/DIEHashTest.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/AsmPrinter/DIEHash.cpp b/lib/CodeGen/AsmPrinter/DIEHash.cpp index 18264672ed2..85761c6ec55 100644 --- a/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -413,7 +413,7 @@ void DIEHash::computeHash(const DIE &Die) { I != E; ++I) { // 7.27 Step 7 // If C is a nested type entry or a member function entry, ... - if (isType((*I)->getTag())) { + if (isType((*I)->getTag()) || (*I)->getTag() == dwarf::DW_TAG_subprogram) { StringRef Name = getDIEStringAttr(**I, dwarf::DW_AT_name); // ... and has a DW_AT_name attribute if (!Name.empty()) { diff --git a/unittests/CodeGen/DIEHashTest.cpp b/unittests/CodeGen/DIEHashTest.cpp index fb6f4b3640a..8d8fc39a30f 100644 --- a/unittests/CodeGen/DIEHashTest.cpp +++ b/unittests/CodeGen/DIEHashTest.cpp @@ -496,4 +496,22 @@ TEST(DIEHashTest, NestedType) { // The exact same hash GCC produces for this DIE. ASSERT_EQ(0xde8a3b7b43807f4aULL, MD5Res); } + +// struct { static void func(); }; +TEST(DIEHashTest, MemberFunc) { + DIE Unnamed(dwarf::DW_TAG_structure_type); + DIEInteger One(1); + Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One); + + DIE *Func = new DIE(dwarf::DW_TAG_subprogram); + DIEString FuncStr(&One, "func"); + Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr); + + Unnamed.addChild(Func); + + uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed); + + // The exact same hash GCC produces for this DIE. + ASSERT_EQ(0xd36a1b6dfb604ba0ULL, MD5Res); +} }