mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
DIEHash: Include the type's context in the type hash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -466,6 +466,9 @@ uint64_t DIEHash::computeCUSignature(DIE *Die) {
|
|||||||
/// standard.
|
/// standard.
|
||||||
uint64_t DIEHash::computeTypeSignature(DIE *Die) {
|
uint64_t DIEHash::computeTypeSignature(DIE *Die) {
|
||||||
|
|
||||||
|
if (DIE *Parent = Die->getParent())
|
||||||
|
addParentContext(Parent);
|
||||||
|
|
||||||
// Hash the DIE.
|
// Hash the DIE.
|
||||||
computeHash(Die);
|
computeHash(Die);
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
TEST(DIEHashData1Test, DIEHash) {
|
TEST(Data1, DIEHash) {
|
||||||
DIEHash Hash;
|
DIEHash Hash;
|
||||||
DIE Die(dwarf::DW_TAG_base_type);
|
DIE Die(dwarf::DW_TAG_base_type);
|
||||||
DIEInteger Size(4);
|
DIEInteger Size(4);
|
||||||
@@ -26,19 +26,68 @@ TEST(DIEHashData1Test, DIEHash) {
|
|||||||
ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
|
ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DIEHashTrivialTypeTest, DIEHash) {
|
TEST(TrivialType, DIEHash) {
|
||||||
// A complete, but simple, type containing no members and defined on the first
|
// A complete, but simple, type containing no members and defined on the first
|
||||||
// line of a file.
|
// line of a file.
|
||||||
DIE FooType(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
FooType.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
||||||
|
|
||||||
// Line and file number are ignored.
|
// Line and file number are ignored.
|
||||||
FooType.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
||||||
FooType.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
||||||
uint64_t MD5Res = DIEHash().computeTypeSignature(&FooType);
|
uint64_t MD5Res = DIEHash().computeTypeSignature(&Unnamed);
|
||||||
|
|
||||||
// The exact same hash GCC produces for this DIE.
|
// The exact same hash GCC produces for this DIE.
|
||||||
ASSERT_EQ(0x715305ce6cfd9ad1ULL, MD5Res);
|
ASSERT_EQ(0x715305ce6cfd9ad1ULL, MD5Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NamedType, DIEHash) {
|
||||||
|
// A complete named type containing no members and defined on the first line
|
||||||
|
// of a file.
|
||||||
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
|
DIEInteger One(1);
|
||||||
|
DIEString FooStr(&One, "foo");
|
||||||
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
||||||
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
||||||
|
|
||||||
|
// Line and file number are ignored.
|
||||||
|
Foo.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
||||||
|
Foo.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
||||||
|
uint64_t MD5Res = DIEHash().computeTypeSignature(&Foo);
|
||||||
|
|
||||||
|
// The exact same hash GCC produces for this DIE.
|
||||||
|
ASSERT_EQ(0xd566dbd2ca5265ffULL, MD5Res);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(NamespacedType, DIEHash) {
|
||||||
|
// A complete named type containing no members and defined on the first line
|
||||||
|
// of a file.
|
||||||
|
DIE CU(dwarf::DW_TAG_compile_unit);
|
||||||
|
|
||||||
|
DIE *Space = new DIE(dwarf::DW_TAG_namespace);
|
||||||
|
DIEInteger One(1);
|
||||||
|
DIEString SpaceStr(&One, "space");
|
||||||
|
Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &SpaceStr);
|
||||||
|
// DW_AT_declaration is ignored.
|
||||||
|
Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
||||||
|
// sibling?
|
||||||
|
|
||||||
|
DIE *Foo = new DIE(dwarf::DW_TAG_structure_type);
|
||||||
|
DIEString FooStr(&One, "foo");
|
||||||
|
Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
||||||
|
Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
||||||
|
|
||||||
|
// Line and file number are ignored.
|
||||||
|
Foo->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
||||||
|
Foo->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
||||||
|
|
||||||
|
Space->addChild(Foo);
|
||||||
|
CU.addChild(Space);
|
||||||
|
|
||||||
|
uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
|
||||||
|
|
||||||
|
// The exact same hash GCC produces for this DIE.
|
||||||
|
ASSERT_EQ(0x7b80381fd17f1e33ULL, MD5Res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user