mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:40:38 +00:00
Resubmit [pdb] Change /DEBUG:GHASH to emit 8 byte hashes."
This fixes the remaining failing tests, so resubmitting with no functional change. llvm-svn: 332676
This commit is contained in:
parent
fa2757ca10
commit
4e29440373
@ -58,7 +58,10 @@ struct LocallyHashedType {
|
||||
}
|
||||
};
|
||||
|
||||
enum class GlobalTypeHashAlg : uint16_t { SHA1 = 0 };
|
||||
enum class GlobalTypeHashAlg : uint16_t {
|
||||
SHA1 = 0, // standard 20-byte SHA1 hash
|
||||
SHA1_8 // last 8-bytes of standard SHA1 hash
|
||||
};
|
||||
|
||||
/// A globally hashed type represents a hash value that is sufficient to
|
||||
/// uniquely identify a record across multiple type streams or type sequences.
|
||||
@ -77,10 +80,10 @@ struct GloballyHashedType {
|
||||
GloballyHashedType(StringRef H)
|
||||
: GloballyHashedType(ArrayRef<uint8_t>(H.bytes_begin(), H.bytes_end())) {}
|
||||
GloballyHashedType(ArrayRef<uint8_t> H) {
|
||||
assert(H.size() == 20);
|
||||
::memcpy(Hash.data(), H.data(), 20);
|
||||
assert(H.size() == 8);
|
||||
::memcpy(Hash.data(), H.data(), 8);
|
||||
}
|
||||
std::array<uint8_t, 20> Hash;
|
||||
std::array<uint8_t, 8> 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
|
||||
|
@ -32,10 +32,10 @@ namespace CodeViewYAML {
|
||||
struct GlobalHash {
|
||||
GlobalHash() = default;
|
||||
explicit GlobalHash(StringRef S) : Hash(S) {
|
||||
assert(S.size() == 20 && "Invalid hash size!");
|
||||
assert(S.size() == 8 && "Invalid hash size!");
|
||||
}
|
||||
explicit GlobalHash(ArrayRef<uint8_t> S) : Hash(S) {
|
||||
assert(S.size() == 20 && "Invalid hash size!");
|
||||
assert(S.size() == 8 && "Invalid hash size!");
|
||||
}
|
||||
yaml::BinaryRef Hash;
|
||||
};
|
||||
|
@ -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), 2);
|
||||
OS.EmitIntValue(uint16_t(GlobalTypeHashAlg::SHA1_8), 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() % 20 == 0);
|
||||
assert(GHR.Hash.size() == 8);
|
||||
StringRef S(reinterpret_cast<const char *>(GHR.Hash.data()),
|
||||
GHR.Hash.size());
|
||||
OS.EmitBinaryData(S);
|
||||
|
@ -18,10 +18,10 @@ using namespace llvm::codeview;
|
||||
LocallyHashedType DenseMapInfo<LocallyHashedType>::Empty{0, {}};
|
||||
LocallyHashedType DenseMapInfo<LocallyHashedType>::Tombstone{hash_code(-1), {}};
|
||||
|
||||
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}};
|
||||
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}};
|
||||
|
||||
GloballyHashedType DenseMapInfo<GloballyHashedType>::Empty{EmptyHash};
|
||||
GloballyHashedType DenseMapInfo<GloballyHashedType>::Tombstone{TombstoneHash};
|
||||
@ -71,5 +71,5 @@ GloballyHashedType::hashType(ArrayRef<uint8_t> RecordData,
|
||||
auto TrailingBytes = RecordData.drop_front(Off);
|
||||
S.update(TrailingBytes);
|
||||
|
||||
return {S.final()};
|
||||
return {S.final().take_back(8)};
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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"
|
||||
@ -46,16 +48,17 @@ StringRef ScalarTraits<GlobalHash>::input(StringRef Scalar, void *Ctx,
|
||||
|
||||
DebugHSection llvm::CodeViewYAML::fromDebugH(ArrayRef<uint8_t> DebugH) {
|
||||
assert(DebugH.size() >= 8);
|
||||
assert((DebugH.size() - 8) % 20 == 0);
|
||||
assert((DebugH.size() - 8) % 8 == 0);
|
||||
|
||||
BinaryStreamReader Reader(DebugH, llvm::support::little);
|
||||
DebugHSection DHS;
|
||||
cantFail(Reader.readInteger(DHS.Magic));
|
||||
cantFail(Reader.readInteger(DHS.Version));
|
||||
cantFail(Reader.readInteger(DHS.HashAlgorithm));
|
||||
|
||||
while (Reader.bytesRemaining() != 0) {
|
||||
ArrayRef<uint8_t> S;
|
||||
cantFail(Reader.readBytes(S, 20));
|
||||
cantFail(Reader.readBytes(S, 8));
|
||||
DHS.Hashes.emplace_back(S);
|
||||
}
|
||||
assert(Reader.bytesRemaining() == 0);
|
||||
@ -64,19 +67,20 @@ DebugHSection llvm::CodeViewYAML::fromDebugH(ArrayRef<uint8_t> DebugH) {
|
||||
|
||||
ArrayRef<uint8_t> llvm::CodeViewYAML::toDebugH(const DebugHSection &DebugH,
|
||||
BumpPtrAllocator &Alloc) {
|
||||
uint32_t Size = 8 + 20 * DebugH.Hashes.size();
|
||||
uint32_t Size = 8 + 8 * DebugH.Hashes.size();
|
||||
uint8_t *Data = Alloc.Allocate<uint8_t>(Size);
|
||||
MutableArrayRef<uint8_t> Buffer(Data, Size);
|
||||
BinaryStreamWriter Writer(Buffer, llvm::support::little);
|
||||
|
||||
cantFail(Writer.writeInteger(DebugH.Magic));
|
||||
cantFail(Writer.writeInteger(DebugH.Version));
|
||||
cantFail(Writer.writeInteger(DebugH.HashAlgorithm));
|
||||
SmallString<20> Hash;
|
||||
SmallString<8> Hash;
|
||||
for (const auto &H : DebugH.Hashes) {
|
||||
Hash.clear();
|
||||
raw_svector_ostream OS(Hash);
|
||||
H.Hash.writeAsBinary(OS);
|
||||
assert((Hash.size() == 20) && "Invalid hash size!");
|
||||
assert((Hash.size() == 8) && "Invalid hash size!");
|
||||
cantFail(Writer.writeFixedString(Hash));
|
||||
}
|
||||
assert(Writer.bytesRemaining() == 0);
|
||||
|
@ -273,39 +273,34 @@ attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-ma
|
||||
; YAML: Alignment: 4
|
||||
; YAML: GlobalHashes:
|
||||
; YAML: Version: 0
|
||||
; YAML: HashAlgorithm: 0
|
||||
; YAML: HashAlgorithm: 1
|
||||
; YAML: HashValues:
|
||||
; 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
|
||||
; YAML: - 800309EE1ED8BB5B
|
||||
; YAML: - 5397319F1CC14E2C
|
||||
; YAML: - DF04AA3125BBC50E
|
||||
; YAML: - 95CEBA304A2C4493
|
||||
; YAML: - C324F82D24D22283
|
||||
; YAML: - 74698BE366891D3D
|
||||
; YAML: - DDE23757322DB7C3
|
||||
; YAML: - 3C458A5105FEA7C1
|
||||
; YAML: - D341E2F9BE57A1C7
|
||||
; YAML: - 243F76AED6D8FB79
|
||||
; YAML: - B038D36C0C67EEEA
|
||||
; YAML: - C0A51CE268B50087
|
||||
; YAML: - 0634944401BCC520
|
||||
; YAML: - 8CFC595FACFE1AB2
|
||||
; YAML: - F1795EA10053AC52
|
||||
; YAML: - 17D3CDC3384402DD
|
||||
; ...
|
||||
|
||||
|
||||
; ASM: .section .debug$H,"dr"
|
||||
; ASM-NEXT: .p2align 2
|
||||
; ASM-NEXT: .long 20171205 # Magic
|
||||
; ASM-NEXT: .short 0 # Section Version
|
||||
; 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: .short 1 # Hash Algorithm
|
||||
; ASM-NEXT: .byte 0x80, 0x03, 0x09, 0xee # 0x1000 [800309EE1ED8BB5B]
|
||||
; 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]
|
||||
; ASM-NEXT: .byte 0x53, 0x97, 0x31, 0x9f # 0x1001 [5397319F1CC14E2C]
|
||||
; ASM-NEXT: .byte 0x1c, 0xc1, 0x4e, 0x2c
|
||||
; ASM-NEXT: .byte 0xdf, 0x04, 0xaa, 0x31 # 0x1002 [DF04AA3125BBC50E]
|
||||
|
@ -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: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384
|
||||
CHECK-ONE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: A7F8CF106F39A384
|
||||
CHECK-ONE: obj-hashes-2
|
||||
CHECK-ONE: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384
|
||||
CHECK-ONE: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: A7F8CF106F39A384
|
||||
|
||||
; 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: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1
|
||||
CHECK-TWO: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 95D0616C5962F4B1
|
||||
CHECK-TWO: obj-hashes-2
|
||||
CHECK-TWO: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1
|
||||
CHECK-TWO: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 95D0616C5962F4B1
|
||||
|
||||
; 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: 68A6DDB5C538D379E72E6425591A2B16352DF93D
|
||||
CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 48D95F14F6176F4F
|
||||
CHECK-THREE: obj-hashes-2
|
||||
CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 68A6DDB5C538D379E72E6425591A2B16352DF93D
|
||||
CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 48D95F14F6176F4F
|
||||
|
||||
; 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: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51
|
||||
CHECK-FOUR: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 99410CD14F5EE80D
|
||||
CHECK-FOUR: obj-hashes-2
|
||||
CHECK-FOUR: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51
|
||||
CHECK-FOUR: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 99410CD14F5EE80D
|
||||
|
||||
; 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: 5BB6926CA7924D06908872FA20691EA9B88584CC
|
||||
CHECK-FIVE: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 20691EA9B88584CC
|
||||
|
||||
; 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: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065
|
||||
CHECK-SIX: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 7ACF479173341AC1
|
||||
CHECK-SIX: obj-hashes-2
|
||||
CHECK-SIX: TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065
|
||||
CHECK-SIX: TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7ACF479173341AC1
|
||||
|
@ -21,13 +21,13 @@ sections:
|
||||
Alignment: 4
|
||||
GlobalHashes:
|
||||
Version: 0
|
||||
HashAlgorithm: 0
|
||||
HashAlgorithm: 1
|
||||
HashValues:
|
||||
- 1522A98D88FAF71B618D97BCAC2B89A424EC4805
|
||||
- 8B2BA87CC27BF9D290A31A6070FA296AAA577E53
|
||||
- EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4
|
||||
- 1088AD64CEBC88D9E015058A159516AF20B79286
|
||||
- 457ABCB8AB70407594B5D72BF471B6BDECC99BC9
|
||||
- AC2B89A424EC4805
|
||||
- 70FA296AAA577E53
|
||||
- E2C98293782A7EB4
|
||||
- 159516AF20B79286
|
||||
- F471B6BDECC99BC9
|
||||
symbols:
|
||||
- Name: '.debug$T'
|
||||
Value: 0
|
||||
@ -74,13 +74,13 @@ symbols:
|
||||
# CHECK: Alignment: 4
|
||||
# CHECK: GlobalHashes:
|
||||
# CHECK: Version: 0
|
||||
# CHECK: HashAlgorithm: 0
|
||||
# CHECK: HashAlgorithm: 1
|
||||
# CHECK: HashValues:
|
||||
# CHECK: - 1522A98D88FAF71B618D97BCAC2B89A424EC4805
|
||||
# CHECK: - 8B2BA87CC27BF9D290A31A6070FA296AAA577E53
|
||||
# CHECK: - EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4
|
||||
# CHECK: - 1088AD64CEBC88D9E015058A159516AF20B79286
|
||||
# CHECK: - 457ABCB8AB70407594B5D72BF471B6BDECC99BC9
|
||||
# CHECK: - AC2B89A424EC4805
|
||||
# CHECK: - 70FA296AAA577E53
|
||||
# CHECK: - E2C98293782A7EB4
|
||||
# CHECK: - 159516AF20B79286
|
||||
# CHECK: - F471B6BDECC99BC9
|
||||
# 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 0000006c 0000000000000000 DATA
|
||||
# HEADERS: 1 .debug$H 00000030 0000000000000000 DATA
|
||||
|
Loading…
Reference in New Issue
Block a user