diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h | 11 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/TypeHashing.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp | 20 | ||||
-rw-r--r-- | llvm/test/DebugInfo/COFF/global-type-hashes.ll | 53 | ||||
-rw-r--r-- | llvm/test/DebugInfo/PDB/obj-globalhash.test | 22 | ||||
-rw-r--r-- | llvm/test/ObjectYAML/CodeView/sections.yaml | 22 |
7 files changed, 67 insertions, 74 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h index 0be466fdecb..74133753370 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h @@ -58,10 +58,7 @@ struct LocallyHashedType { } }; -enum class GlobalTypeHashAlg : uint16_t { - SHA1 = 0, // standard 20-byte SHA1 hash - SHA1_8 // last 8-bytes of standard SHA1 hash -}; +enum class GlobalTypeHashAlg : uint16_t { SHA1 = 0 }; /// A globally hashed type represents a hash value that is sufficient to /// uniquely identify a record across multiple type streams or type sequences. @@ -80,10 +77,10 @@ struct GloballyHashedType { GloballyHashedType(StringRef H) : GloballyHashedType(ArrayRef<uint8_t>(H.bytes_begin(), H.bytes_end())) {} GloballyHashedType(ArrayRef<uint8_t> H) { - assert(H.size() == 8); - ::memcpy(Hash.data(), H.data(), 8); + assert(H.size() == 20); + ::memcpy(Hash.data(), H.data(), 20); } - std::array<uint8_t, 8> Hash; + std::array<uint8_t, 20> Hash; /// Given a sequence of bytes representing a record, compute a global hash for /// this record. Due to the nature of global hashes incorporating the hashes diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 2dcfbf48a32..ef279417b7e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -589,7 +589,7 @@ void CodeViewDebug::emitTypeGlobalHashes() { OS.AddComment("Section Version"); OS.EmitIntValue(0, 2); OS.AddComment("Hash Algorithm"); - OS.EmitIntValue(uint16_t(GlobalTypeHashAlg::SHA1_8), 2); + OS.EmitIntValue(uint16_t(GlobalTypeHashAlg::SHA1), 2); TypeIndex TI(TypeIndex::FirstNonSimpleIndex); for (const auto &GHR : TypeTable.hashes()) { @@ -602,7 +602,7 @@ void CodeViewDebug::emitTypeGlobalHashes() { OS.AddComment(Comment); ++TI; } - assert(GHR.Hash.size() == 8); + assert(GHR.Hash.size() % 20 == 0); StringRef S(reinterpret_cast<const char *>(GHR.Hash.data()), GHR.Hash.size()); OS.EmitBinaryData(S); diff --git a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp index a51770959ac..c2f8cd5466a 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp @@ -18,9 +18,10 @@ using namespace llvm::codeview; LocallyHashedType DenseMapInfo<LocallyHashedType>::Empty{0, {}}; LocallyHashedType DenseMapInfo<LocallyHashedType>::Tombstone{hash_code(-1), {}}; -static std::array<uint8_t, 8> EmptyHash = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -static std::array<uint8_t, 8> TombstoneHash = { - {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; +static std::array<uint8_t, 20> EmptyHash; +static std::array<uint8_t, 20> TombstoneHash = { + {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; GloballyHashedType DenseMapInfo<GloballyHashedType>::Empty{EmptyHash}; GloballyHashedType DenseMapInfo<GloballyHashedType>::Tombstone{TombstoneHash}; @@ -70,5 +71,5 @@ GloballyHashedType::hashType(ArrayRef<uint8_t> RecordData, auto TrailingBytes = RecordData.drop_front(Off); S.update(TrailingBytes); - return {S.final().take_back(8)}; + return {S.final()}; } diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp index a55c3c2ce67..bbbd7c06772 100644 --- a/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp +++ b/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp @@ -13,8 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/ObjectYAML/CodeViewYAMLTypeHashing.h" - -#include "llvm/BinaryFormat/COFF.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamWriter.h" @@ -48,20 +46,16 @@ StringRef ScalarTraits<GlobalHash>::input(StringRef Scalar, void *Ctx, DebugHSection llvm::CodeViewYAML::fromDebugH(ArrayRef<uint8_t> DebugH) { assert(DebugH.size() >= 8); - assert((DebugH.size() - 8) % 8 == 0); + assert((DebugH.size() - 8) % 20 == 0); BinaryStreamReader Reader(DebugH, llvm::support::little); DebugHSection DHS; cantFail(Reader.readInteger(DHS.Magic)); cantFail(Reader.readInteger(DHS.Version)); cantFail(Reader.readInteger(DHS.HashAlgorithm)); - assert(DHS.Magic == COFF::DEBUG_SECTION_MAGIC && "Invalid .debug$H section!"); - assert(DHS.Version == 1 && "Invalid .debug$H version!"); - assert(DHS.HashAlgorithm == 1 && "Invalid .debug$H algorithm!"); - while (Reader.bytesRemaining() != 0) { ArrayRef<uint8_t> S; - cantFail(Reader.readBytes(S, 8)); + cantFail(Reader.readBytes(S, 20)); DHS.Hashes.emplace_back(S); } assert(Reader.bytesRemaining() == 0); @@ -70,23 +64,19 @@ DebugHSection llvm::CodeViewYAML::fromDebugH(ArrayRef<uint8_t> DebugH) { ArrayRef<uint8_t> llvm::CodeViewYAML::toDebugH(const DebugHSection &DebugH, BumpPtrAllocator &Alloc) { - uint32_t Size = 8 + 8 * DebugH.Hashes.size(); + uint32_t Size = 8 + 20 * DebugH.Hashes.size(); uint8_t *Data = Alloc.Allocate<uint8_t>(Size); MutableArrayRef<uint8_t> Buffer(Data, Size); BinaryStreamWriter Writer(Buffer, llvm::support::little); - assert(DebugH.Magic == COFF::DEBUG_SECTION_MAGIC && "Invalid .debug$H section!"); - assert(DebugH.Version == 1 && "Invalid .debug$H version!"); - assert(DebugH.HashAlgorithm == 1 && "Invalid .debug$H algorithm!"); - cantFail(Writer.writeInteger(DebugH.Magic)); cantFail(Writer.writeInteger(DebugH.Version)); cantFail(Writer.writeInteger(DebugH.HashAlgorithm)); - SmallString<8> Hash; + SmallString<20> Hash; for (const auto &H : DebugH.Hashes) { Hash.clear(); raw_svector_ostream OS(Hash); H.Hash.writeAsBinary(OS); - assert((Hash.size() == 8) && "Invalid hash size!"); + assert((Hash.size() == 20) && "Invalid hash size!"); cantFail(Writer.writeFixedString(Hash)); } assert(Writer.bytesRemaining() == 0); diff --git a/llvm/test/DebugInfo/COFF/global-type-hashes.ll b/llvm/test/DebugInfo/COFF/global-type-hashes.ll index 2a7fc76528b..99006a34543 100644 --- a/llvm/test/DebugInfo/COFF/global-type-hashes.ll +++ b/llvm/test/DebugInfo/COFF/global-type-hashes.ll @@ -273,34 +273,39 @@ attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-ma ; YAML: Alignment: 4 ; YAML: GlobalHashes: ; YAML: Version: 0 -; YAML: HashAlgorithm: 1 +; YAML: HashAlgorithm: 0 ; YAML: HashValues: -; YAML: - E09E6E9DA0F4EE31 -; YAML: - AC3421E42389A5FD -; YAML: - 09DDDA6CB66C9F23 -; YAML: - 01B4ACFA70BEACA1 -; YAML: - 8A222FBBEBBE140E -; YAML: - 4497C6AE188A6220 -; YAML: - 14A9932F03846156 -; YAML: - CBC539F8C18B2D2D -; YAML: - 3E52C5C25299E473 -; YAML: - 8FEE74F5141FCC22 -; YAML: - DF48EB0A8ED58F85 -; YAML: - 8EE98BB0F291CBF8 -; YAML: - D18EEE3C1C0C4C09 -; YAML: - 67C712E2108F482A -; YAML: - 23945F2B63311976 -; YAML: - 7F1CACD4255A7ADF -; ... +; YAML: - 624A7FEE7323656B7F1C5A63800309EE1ED8BB5B +; YAML: - 0EB2C87AD629AA9E5C98B7A3ED69DB1355707DF1 +; YAML: - 624E463ACE08649D0FC35F163E20CC43089ADCA6 +; YAML: - 4B712C03EDA4CB88537EBAE4005A09006A9FB389 +; YAML: - 59EC21C3D8D594FF77854ABAC324F82D24D22283 +; YAML: - DA76AFB7C767EC00BAA171FEFAA2801D95716C22 +; YAML: - 4927143F1D91A64983DDA6B6DDE23757322DB7C3 +; YAML: - DFDF871AD3841199ACD961EA57243C7A1305B4DD +; YAML: - 20015FA1AD3D0FF3546B4428D341E2F9BE57A1C7 +; YAML: - 8DC9D77BACDD53AAE3A5AC8F41C43D3C3122DCBC +; YAML: - 77A85205D34B9C26802849355086C2937E3F45D8 +; YAML: - 4AEF9C1D1509C0FFA2A02F86B3C28FB0F254096C +; YAML: - 83B03F51A4BABAE1E8B560B40634944401BCC520 +; YAML: - A82772A0D760F3EB5FC7A3022A6D376F5D7A92E2 +; YAML: - 235B46C1A3E3FB71D89ED6085E8B8D38632AACD6 +; YAML: - D52F03DB055DE93F19066E93FB3BA86C5A652429 ; ASM: .section .debug$H,"dr" ; ASM-NEXT: .p2align 2 ; ASM-NEXT: .long 20171205 # Magic ; ASM-NEXT: .short 0 # Section Version -; ASM-NEXT: .short 1 # Hash Algorithm -; ASM-NEXT: .byte 0xe0, 0x9e, 0x6e, 0x9d # 0x1000 [E09E6E9DA0F4EE31] -; ASM-NEXT: .byte 0xa0, 0xf4, 0xee, 0x31 -; ASM-NEXT: .byte 0xac, 0x34, 0x21, 0xe4 # 0x1001 [AC3421E42389A5FD] -; ASM-NEXT: .byte 0x23, 0x89, 0xa5, 0xfd -; ASM-NEXT: .byte 0x09, 0xdd, 0xda, 0x6c # 0x1002 [09DDDA6CB66C9F23] +; ASM-NEXT: .short 0 # Hash Algorithm +; ASM-NEXT: .byte 0x62, 0x4a, 0x7f, 0xee # 0x1000 [624A7FEE7323656B7F1C5A63800309EE1ED8BB5B] +; ASM-NEXT: .byte 0x73, 0x23, 0x65, 0x6b +; ASM-NEXT: .byte 0x7f, 0x1c, 0x5a, 0x63 +; ASM-NEXT: .byte 0x80, 0x03, 0x09, 0xee +; ASM-NEXT: .byte 0x1e, 0xd8, 0xbb, 0x5b +; ASM-NEXT: .byte 0x0e, 0xb2, 0xc8, 0x7a # 0x1001 [0EB2C87AD629AA9E5C98B7A3ED69DB1355707DF1] +; ASM-NEXT: .byte 0xd6, 0x29, 0xaa, 0x9e +; ASM-NEXT: .byte 0x5c, 0x98, 0xb7, 0xa3 +; ASM-NEXT: .byte 0xed, 0x69, 0xdb, 0x13 +; ASM-NEXT: .byte 0x55, 0x70, 0x7d, 0xf1 +; ASM-NEXT: .byte 0x62, 0x4e, 0x46, 0x3a # 0x1002 [624E463ACE08649D0FC35F163E20CC43089ADCA6] diff --git a/llvm/test/DebugInfo/PDB/obj-globalhash.test b/llvm/test/DebugInfo/PDB/obj-globalhash.test index 343081ab224..770eae2704a 100644 --- a/llvm/test/DebugInfo/PDB/obj-globalhash.test +++ b/llvm/test/DebugInfo/PDB/obj-globalhash.test @@ -14,41 +14,41 @@ RUN: cat %T/hashes-combined.out | FileCheck --check-prefix=CHECK-SIX %s ; char**. Both the local and global hashes should be the same, since the only ; back-references are for simple types which have fixed indices. CHECK-ONE: obj-hashes-1 -CHECK-ONE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 70FA296AAA577E53 +CHECK-ONE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384 CHECK-ONE: obj-hashes-2 -CHECK-ONE: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 70FA296AAA577E53 +CHECK-ONE: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384 ; int**. Same as char**, both the local and global hashes should be the same. CHECK-TWO: obj-hashes-1 -CHECK-TWO: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: AC2B89A424EC4805 +CHECK-TWO: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1 CHECK-TWO: obj-hashes-2 -CHECK-TWO: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: AC2B89A424EC4805 +CHECK-TWO: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1 ; int***. Different local hashes, since the referent type (int**) is not at the ; same TypeIndex in both streams. Same global hash, since they represent the ; same record. CHECK-THREE: obj-hashes-1 -CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 9D6275A3E1B37A7D +CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 68A6DDB5C538D379E72E6425591A2B16352DF93D CHECK-THREE: obj-hashes-2 -CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 9D6275A3E1B37A7D +CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 68A6DDB5C538D379E72E6425591A2B16352DF93D ; arg list (char**, int***). Different local hashes, since the parameter types ; both occur at different TypeIndices in their respective input streams. Same ; global hash, since the global hash of all referenced types is the same in ; both streams. CHECK-FOUR: obj-hashes-1 -CHECK-FOUR: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: C82DFD641EB22940 +CHECK-FOUR: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51 CHECK-FOUR: obj-hashes-2 -CHECK-FOUR: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: C82DFD641EB22940 +CHECK-FOUR: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51 ; double**. This is only in stream 2, as a means to throw off the indexing. CHECK-FIVE: obj-hashes-1 CHECK-FIVE: obj-hashes-2 -CHECK-FIVE: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 102BD08F68315506 +CHECK-FIVE: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 5BB6926CA7924D06908872FA20691EA9B88584CC ; int** (char**, int***). For the same logic as described in previous records, ; these two records have the same global hash but different local hashes. CHECK-SIX: obj-hashes-1 -CHECK-SIX: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 526C704BC7D94D40 +CHECK-SIX: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065 CHECK-SIX: obj-hashes-2 -CHECK-SIX: TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 526C704BC7D94D40 +CHECK-SIX: TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065 diff --git a/llvm/test/ObjectYAML/CodeView/sections.yaml b/llvm/test/ObjectYAML/CodeView/sections.yaml index e06879ddae6..7a58f88029f 100644 --- a/llvm/test/ObjectYAML/CodeView/sections.yaml +++ b/llvm/test/ObjectYAML/CodeView/sections.yaml @@ -23,11 +23,11 @@ sections: Version: 0 HashAlgorithm: 0 HashValues: - - AC2B89A424EC4805 - - 70FA296AAA577E53 - - E2C98293782A7EB4 - - 159516AF20B79286 - - F471B6BDECC99BC9 + - 1522A98D88FAF71B618D97BCAC2B89A424EC4805 + - 8B2BA87CC27BF9D290A31A6070FA296AAA577E53 + - EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4 + - 1088AD64CEBC88D9E015058A159516AF20B79286 + - 457ABCB8AB70407594B5D72BF471B6BDECC99BC9 symbols: - Name: '.debug$T' Value: 0 @@ -76,11 +76,11 @@ symbols: # CHECK: Version: 0 # CHECK: HashAlgorithm: 0 # CHECK: HashValues: -# CHECK: - AC2B89A424EC4805 -# CHECK: - 70FA296AAA577E53 -# CHECK: - E2C98293782A7EB4 -# CHECK: - 159516AF20B79286 -# CHECK: - F471B6BDECC99BC9 +# CHECK: - 1522A98D88FAF71B618D97BCAC2B89A424EC4805 +# CHECK: - 8B2BA87CC27BF9D290A31A6070FA296AAA577E53 +# CHECK: - EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4 +# CHECK: - 1088AD64CEBC88D9E015058A159516AF20B79286 +# CHECK: - 457ABCB8AB70407594B5D72BF471B6BDECC99BC9 # CHECK: symbols: # CHECK: - Name: '.debug$T' # CHECK: Value: 0 @@ -109,4 +109,4 @@ symbols: # CHECK: ... # HEADERS: 0 .debug$T 00000040 0000000000000000 DATA -# HEADERS: 1 .debug$H 00000030 0000000000000000 DATA +# HEADERS: 1 .debug$H 0000006c 0000000000000000 DATA |