mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[codeview] Include record prefix in global type hashing
The prefix includes type kind, which is important to preserve. Two different type leafs can easily have the same interior record contents as another type. We ran into this issue in PR37492 where a bitfield type record collided with a const modifier record. Their contents were bitwise identical, but their kinds were different. llvm-svn: 332664
This commit is contained in:
parent
ae9a841247
commit
5c85911f0a
@ -39,6 +39,7 @@ GloballyHashedType::hashType(ArrayRef<uint8_t> RecordData,
|
||||
SHA1 S;
|
||||
S.init();
|
||||
uint32_t Off = 0;
|
||||
S.update(RecordData.take_front(sizeof(RecordPrefix)));
|
||||
RecordData = RecordData.drop_front(sizeof(RecordPrefix));
|
||||
for (const auto &Ref : Refs) {
|
||||
// Hash any data that comes before this TiRef.
|
||||
|
@ -275,23 +275,22 @@ attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-ma
|
||||
; YAML: Version: 0
|
||||
; YAML: HashAlgorithm: 0
|
||||
; YAML: HashValues:
|
||||
; YAML: - 9E56666824DC4B12E25261D4E09E6E9DA0F4EE31
|
||||
; YAML: - FDEC3D2D96287486127C66070B248ED52E421F55
|
||||
; YAML: - 074AE5CC2D68AF9F0A3BEF23993968F7FD82CA84
|
||||
; YAML: - BF0439C1A64C9070C6A6ADB0A34D21DAD0FFC3E9
|
||||
; YAML: - CF1B3AD4A96BA628E6556FD28A222FBBEBBE140E
|
||||
; YAML: - EC50195BFE148C0DC6A87A59D49CA1D9B146DB86
|
||||
; YAML: - 123C8BA63AD23386897AB6D814A9932F03846156
|
||||
; YAML: - 0F135243878289B83835BC2DB9EE25A1D4D0DA2B
|
||||
; YAML: - 9069CA78E7450A285173431B3E52C5C25299E473
|
||||
; YAML: - ADA6E11350E9F2069D4689E3646C90D67B28DA62
|
||||
; YAML: - BD535FA9877A4DD123840AF849F3B0110EEB1D7A
|
||||
; YAML: - 8044F70193FE40B71867158C5E50F0467485FA99
|
||||
; YAML: - 558606D57A76D125B705FC6DD18EEE3C1C0C4C09
|
||||
; YAML: - A64A018D9EB1EB8015917925662C8508D81CDA68
|
||||
; YAML: - 51E89AD9992AC6F11F9E3F1665F41C53BDA8AFC4
|
||||
; YAML: - 4F1C3BCA73099EF3466AAC99CC4951767DF890F5
|
||||
; ...
|
||||
; 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"
|
||||
@ -299,14 +298,14 @@ attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-ma
|
||||
; ASM-NEXT: .long 20171205 # Magic
|
||||
; ASM-NEXT: .short 0 # Section Version
|
||||
; ASM-NEXT: .short 0 # Hash Algorithm
|
||||
; ASM-NEXT: .byte 0x9e, 0x56, 0x66, 0x68 # 0x1000 [9E56666824DC4B12E25261D4E09E6E9DA0F4EE31]
|
||||
; ASM-NEXT: .byte 0x24, 0xdc, 0x4b, 0x12
|
||||
; ASM-NEXT: .byte 0xe2, 0x52, 0x61, 0xd4
|
||||
; ASM-NEXT: .byte 0xe0, 0x9e, 0x6e, 0x9d
|
||||
; ASM-NEXT: .byte 0xa0, 0xf4, 0xee, 0x31
|
||||
; ASM-NEXT: .byte 0xfd, 0xec, 0x3d, 0x2d # 0x1001 [FDEC3D2D96287486127C66070B248ED52E421F55]
|
||||
; ASM-NEXT: .byte 0x96, 0x28, 0x74, 0x86
|
||||
; ASM-NEXT: .byte 0x12, 0x7c, 0x66, 0x07
|
||||
; ASM-NEXT: .byte 0x0b, 0x24, 0x8e, 0xd5
|
||||
; ASM-NEXT: .byte 0x2e, 0x42, 0x1f, 0x55
|
||||
; ASM-NEXT: .byte 0x07, 0x4a, 0xe5, 0xcc # 0x1002 [074AE5CC2D68AF9F0A3BEF23993968F7FD82CA84]
|
||||
; 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]
|
||||
|
63
test/DebugInfo/COFF/pr37492.ll
Normal file
63
test/DebugInfo/COFF/pr37492.ll
Normal file
@ -0,0 +1,63 @@
|
||||
; RUN: llc < %s | FileCheck %s
|
||||
|
||||
; Original C++ source:
|
||||
; struct Bits {
|
||||
; unsigned char b0 : 1;
|
||||
; unsigned char b1 : 1;
|
||||
; } bits;
|
||||
; const unsigned char *p_const;
|
||||
|
||||
; In PR37492, there was an issue in global type hashing where we forgot to
|
||||
; consider the prefix portion of a type record when hashing it. This lead to a
|
||||
; collision between this LF_BITFIELD and LF_MODIFIER record, so we only emitted
|
||||
; one under the assumption that the other was redundant. Check that we emit both.
|
||||
|
||||
; CHECK-LABEL: # BitField ({{.*}}) {
|
||||
; CHECK-NEXT: # TypeLeafKind: LF_BITFIELD (0x1205)
|
||||
; CHECK-NEXT: # Type: unsigned char (0x20)
|
||||
; CHECK-NEXT: # BitSize: 1
|
||||
; CHECK-NEXT: # BitOffset: 0
|
||||
; CHECK-NEXT: # }
|
||||
|
||||
; CHECK-LABEL: # Modifier ({{.*}}) {
|
||||
; CHECK-NEXT: # TypeLeafKind: LF_MODIFIER (0x1001)
|
||||
; CHECK-NEXT: # ModifiedType: unsigned char (0x20)
|
||||
; CHECK-NEXT: # Modifiers [ (0x1)
|
||||
; CHECK-NEXT: # Const (0x1)
|
||||
; CHECK-NEXT: # ]
|
||||
; CHECK-NEXT: # }
|
||||
|
||||
; ModuleID = 't.cpp'
|
||||
source_filename = "t.cpp"
|
||||
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-pc-windows-msvc19.13.26131"
|
||||
|
||||
%struct.Bits = type { i8 }
|
||||
|
||||
@"?bits@@3UBits@@A" = dso_local global %struct.Bits zeroinitializer, align 1, !dbg !0
|
||||
@"?p_const@@3PEBEEB" = dso_local global i8* null, align 8, !dbg !6
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!15, !16, !17, !18}
|
||||
!llvm.ident = !{!19}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "bits", linkageName: "?bits@@3UBits@@A", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
|
||||
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
|
||||
!3 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "8910833bbe8b669a3787c8f44dff1313")
|
||||
!4 = !{}
|
||||
!5 = !{!0, !6}
|
||||
!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
|
||||
!7 = distinct !DIGlobalVariable(name: "p_const", linkageName: "?p_const@@3PEBEEB", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
|
||||
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
|
||||
!9 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10)
|
||||
!10 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
|
||||
!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Bits", file: !3, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: ".?AUBits@@")
|
||||
!12 = !{!13, !14}
|
||||
!13 = !DIDerivedType(tag: DW_TAG_member, name: "b0", scope: !11, file: !3, line: 2, baseType: !10, size: 1, flags: DIFlagBitField, extraData: i64 0)
|
||||
!14 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !11, file: !3, line: 3, baseType: !10, size: 1, offset: 1, flags: DIFlagBitField, extraData: i64 0)
|
||||
!15 = !{i32 2, !"CodeView", i32 1}
|
||||
!16 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!17 = !{i32 1, !"wchar_size", i32 2}
|
||||
!18 = !{i32 7, !"PIC Level", i32 2}
|
||||
!19 = !{!"clang version 7.0.0 "}
|
@ -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: 8B2BA87CC27BF9D290A31A6070FA296AAA577E53
|
||||
CHECK-ONE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384
|
||||
CHECK-ONE: obj-hashes-2
|
||||
CHECK-ONE: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 8B2BA87CC27BF9D290A31A6070FA296AAA577E53
|
||||
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: 1522A98D88FAF71B618D97BCAC2B89A424EC4805
|
||||
CHECK-TWO: TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1
|
||||
CHECK-TWO: obj-hashes-2
|
||||
CHECK-TWO: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 1522A98D88FAF71B618D97BCAC2B89A424EC4805
|
||||
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: EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4
|
||||
CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 68A6DDB5C538D379E72E6425591A2B16352DF93D
|
||||
CHECK-THREE: obj-hashes-2
|
||||
CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4
|
||||
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: 1088AD64CEBC88D9E015058A159516AF20B79286
|
||||
CHECK-FOUR: TI: 0x1003, LocalHash: {{.*}}, GlobalHash: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51
|
||||
CHECK-FOUR: obj-hashes-2
|
||||
CHECK-FOUR: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 1088AD64CEBC88D9E015058A159516AF20B79286
|
||||
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: 7803BBDB2947EF46BEA2310D102BD08F68315506
|
||||
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: 457ABCB8AB70407594B5D72BF471B6BDECC99BC9
|
||||
CHECK-SIX: TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065
|
||||
CHECK-SIX: obj-hashes-2
|
||||
CHECK-SIX: TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 457ABCB8AB70407594B5D72BF471B6BDECC99BC9
|
||||
CHECK-SIX: TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065
|
||||
|
Loading…
Reference in New Issue
Block a user