<div dir="ltr">Do we usually name tests with names like pr12345?  Seems like we should just give it a meaningful name like ghash-record-only-differs-by-prefix.test</div><br><div class="gmail_quote"><div dir="ltr">On Thu, May 17, 2018 at 1:51 PM Reid Kleckner via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Thu May 17 13:47:22 2018<br>
New Revision: 332664<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=332664&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=332664&view=rev</a><br>
Log:<br>
[codeview] Include record prefix in global type hashing<br>
<br>
The prefix includes type kind, which is important to preserve. Two<br>
different type leafs can easily have the same interior record contents<br>
as another type.<br>
<br>
We ran into this issue in PR37492 where a bitfield type record collided<br>
with a const modifier record. Their contents were bitwise identical, but<br>
their kinds were different.<br>
<br>
Added:<br>
    llvm/trunk/test/DebugInfo/COFF/pr37492.ll<br>
Modified:<br>
    llvm/trunk/lib/DebugInfo/CodeView/TypeHashing.cpp<br>
    llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll<br>
    llvm/trunk/test/DebugInfo/PDB/obj-globalhash.test<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeHashing.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeHashing.cpp?rev=332664&r1=332663&r2=332664&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeHashing.cpp?rev=332664&r1=332663&r2=332664&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/CodeView/TypeHashing.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeHashing.cpp Thu May 17 13:47:22 2018<br>
@@ -39,6 +39,7 @@ GloballyHashedType::hashType(ArrayRef<ui<br>
   SHA1 S;<br>
   S.init();<br>
   uint32_t Off = 0;<br>
+  S.update(RecordData.take_front(sizeof(RecordPrefix)));<br>
   RecordData = RecordData.drop_front(sizeof(RecordPrefix));<br>
   for (const auto &Ref : Refs) {<br>
     // Hash any data that comes before this TiRef.<br>
<br>
Modified: llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll?rev=332664&r1=332663&r2=332664&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll?rev=332664&r1=332663&r2=332664&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/COFF/global-type-hashes.ll Thu May 17 13:47:22 2018<br>
@@ -275,23 +275,22 @@ attributes #2 = { noinline nounwind optn<br>
 ; YAML:       Version:         0<br>
 ; YAML:       HashAlgorithm:   0<br>
 ; YAML:       HashValues:<br>
-; YAML:         - 9E56666824DC4B12E25261D4E09E6E9DA0F4EE31<br>
-; YAML:         - FDEC3D2D96287486127C66070B248ED52E421F55<br>
-; YAML:         - 074AE5CC2D68AF9F0A3BEF23993968F7FD82CA84<br>
-; YAML:         - BF0439C1A64C9070C6A6ADB0A34D21DAD0FFC3E9<br>
-; YAML:         - CF1B3AD4A96BA628E6556FD28A222FBBEBBE140E<br>
-; YAML:         - EC50195BFE148C0DC6A87A59D49CA1D9B146DB86<br>
-; YAML:         - 123C8BA63AD23386897AB6D814A9932F03846156<br>
-; YAML:         - 0F135243878289B83835BC2DB9EE25A1D4D0DA2B<br>
-; YAML:         - 9069CA78E7450A285173431B3E52C5C25299E473<br>
-; YAML:         - ADA6E11350E9F2069D4689E3646C90D67B28DA62<br>
-; YAML:         - BD535FA9877A4DD123840AF849F3B0110EEB1D7A<br>
-; YAML:         - 8044F70193FE40B71867158C5E50F0467485FA99<br>
-; YAML:         - 558606D57A76D125B705FC6DD18EEE3C1C0C4C09<br>
-; YAML:         - A64A018D9EB1EB8015917925662C8508D81CDA68<br>
-; YAML:         - 51E89AD9992AC6F11F9E3F1665F41C53BDA8AFC4<br>
-; YAML:         - 4F1C3BCA73099EF3466AAC99CC4951767DF890F5<br>
-; ...<br>
+; YAML:         - 624A7FEE7323656B7F1C5A63800309EE1ED8BB5B<br>
+; YAML:         - 0EB2C87AD629AA9E5C98B7A3ED69DB1355707DF1<br>
+; YAML:         - 624E463ACE08649D0FC35F163E20CC43089ADCA6<br>
+; YAML:         - 4B712C03EDA4CB88537EBAE4005A09006A9FB389<br>
+; YAML:         - 59EC21C3D8D594FF77854ABAC324F82D24D22283<br>
+; YAML:         - DA76AFB7C767EC00BAA171FEFAA2801D95716C22<br>
+; YAML:         - 4927143F1D91A64983DDA6B6DDE23757322DB7C3<br>
+; YAML:         - DFDF871AD3841199ACD961EA57243C7A1305B4DD<br>
+; YAML:         - 20015FA1AD3D0FF3546B4428D341E2F9BE57A1C7<br>
+; YAML:         - 8DC9D77BACDD53AAE3A5AC8F41C43D3C3122DCBC<br>
+; YAML:         - 77A85205D34B9C26802849355086C2937E3F45D8<br>
+; YAML:         - 4AEF9C1D1509C0FFA2A02F86B3C28FB0F254096C<br>
+; YAML:         - 83B03F51A4BABAE1E8B560B40634944401BCC520<br>
+; YAML:         - A82772A0D760F3EB5FC7A3022A6D376F5D7A92E2<br>
+; YAML:         - 235B46C1A3E3FB71D89ED6085E8B8D38632AACD6<br>
+; YAML:         - D52F03DB055DE93F19066E93FB3BA86C5A652429<br>
<br>
<br>
 ; ASM:      .section        .debug$H,"dr"<br>
@@ -299,14 +298,14 @@ attributes #2 = { noinline nounwind optn<br>
 ; ASM-NEXT: .long   20171205                # Magic<br>
 ; ASM-NEXT: .short  0                       # Section Version<br>
 ; ASM-NEXT: .short  0                       # Hash Algorithm<br>
-; ASM-NEXT: .byte   0x9e, 0x56, 0x66, 0x68  # 0x1000 [9E56666824DC4B12E25261D4E09E6E9DA0F4EE31]<br>
-; ASM-NEXT: .byte   0x24, 0xdc, 0x4b, 0x12<br>
-; ASM-NEXT: .byte   0xe2, 0x52, 0x61, 0xd4<br>
-; ASM-NEXT: .byte   0xe0, 0x9e, 0x6e, 0x9d<br>
-; ASM-NEXT: .byte   0xa0, 0xf4, 0xee, 0x31<br>
-; ASM-NEXT: .byte   0xfd, 0xec, 0x3d, 0x2d  # 0x1001 [FDEC3D2D96287486127C66070B248ED52E421F55]<br>
-; ASM-NEXT: .byte   0x96, 0x28, 0x74, 0x86<br>
-; ASM-NEXT: .byte   0x12, 0x7c, 0x66, 0x07<br>
-; ASM-NEXT: .byte   0x0b, 0x24, 0x8e, 0xd5<br>
-; ASM-NEXT: .byte   0x2e, 0x42, 0x1f, 0x55<br>
-; ASM-NEXT: .byte   0x07, 0x4a, 0xe5, 0xcc  # 0x1002 [074AE5CC2D68AF9F0A3BEF23993968F7FD82CA84]<br>
+; ASM-NEXT: .byte   0x62, 0x4a, 0x7f, 0xee  # 0x1000 [624A7FEE7323656B7F1C5A63800309EE1ED8BB5B]<br>
+; ASM-NEXT: .byte   0x73, 0x23, 0x65, 0x6b<br>
+; ASM-NEXT: .byte   0x7f, 0x1c, 0x5a, 0x63<br>
+; ASM-NEXT: .byte   0x80, 0x03, 0x09, 0xee<br>
+; ASM-NEXT: .byte   0x1e, 0xd8, 0xbb, 0x5b<br>
+; ASM-NEXT: .byte   0x0e, 0xb2, 0xc8, 0x7a  # 0x1001 [0EB2C87AD629AA9E5C98B7A3ED69DB1355707DF1]<br>
+; ASM-NEXT: .byte   0xd6, 0x29, 0xaa, 0x9e<br>
+; ASM-NEXT: .byte   0x5c, 0x98, 0xb7, 0xa3<br>
+; ASM-NEXT: .byte   0xed, 0x69, 0xdb, 0x13<br>
+; ASM-NEXT: .byte   0x55, 0x70, 0x7d, 0xf1<br>
+; ASM-NEXT: .byte   0x62, 0x4e, 0x46, 0x3a  # 0x1002 [624E463ACE08649D0FC35F163E20CC43089ADCA6]<br>
<br>
Added: llvm/trunk/test/DebugInfo/COFF/pr37492.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pr37492.ll?rev=332664&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pr37492.ll?rev=332664&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/pr37492.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/COFF/pr37492.ll Thu May 17 13:47:22 2018<br>
@@ -0,0 +1,63 @@<br>
+; RUN: llc < %s | FileCheck %s<br>
+<br>
+; Original C++ source:<br>
+; struct Bits {<br>
+;   unsigned char b0 : 1;<br>
+;   unsigned char b1 : 1;<br>
+; } bits;<br>
+; const unsigned char *p_const;<br>
+<br>
+; In PR37492, there was an issue in global type hashing where we forgot to<br>
+; consider the prefix portion of a type record when hashing it. This lead to a<br>
+; collision between this LF_BITFIELD and LF_MODIFIER record, so we only emitted<br>
+; one under the assumption that the other was redundant. Check that we emit both.<br>
+<br>
+; CHECK-LABEL: # BitField ({{.*}}) {<br>
+; CHECK-NEXT: #   TypeLeafKind: LF_BITFIELD (0x1205)<br>
+; CHECK-NEXT: #   Type: unsigned char (0x20)<br>
+; CHECK-NEXT: #   BitSize: 1<br>
+; CHECK-NEXT: #   BitOffset: 0<br>
+; CHECK-NEXT: # }<br>
+<br>
+; CHECK-LABEL: # Modifier ({{.*}}) {<br>
+; CHECK-NEXT: #   TypeLeafKind: LF_MODIFIER (0x1001)<br>
+; CHECK-NEXT: #   ModifiedType: unsigned char (0x20)<br>
+; CHECK-NEXT: #   Modifiers [ (0x1)<br>
+; CHECK-NEXT: #     Const (0x1)<br>
+; CHECK-NEXT: #   ]<br>
+; CHECK-NEXT: # }<br>
+<br>
+; ModuleID = 't.cpp'<br>
+source_filename = "t.cpp"<br>
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"<br>
+target triple = "x86_64-pc-windows-msvc19.13.26131"<br>
+<br>
+%struct.Bits = type { i8 }<br>
+<br>
+@"?bits@@3UBits@@A" = dso_local global %struct.Bits zeroinitializer, align 1, !dbg !0<br>
+@"?p_const@@3PEBEEB" = dso_local global i8* null, align 8, !dbg !6<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!2}<br>
+!llvm.module.flags = !{!15, !16, !17, !18}<br>
+!llvm.ident = !{!19}<br>
+<br>
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())<br>
+!1 = distinct !DIGlobalVariable(name: "bits", linkageName: "?bits@@3UBits@@A", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)<br>
+!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)<br>
+!3 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "8910833bbe8b669a3787c8f44dff1313")<br>
+!4 = !{}<br>
+!5 = !{!0, !6}<br>
+!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())<br>
+!7 = distinct !DIGlobalVariable(name: "p_const", linkageName: "?p_const@@3PEBEEB", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)<br>
+!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)<br>
+!9 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10)<br>
+!10 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)<br>
+!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Bits", file: !3, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: ".?AUBits@@")<br>
+!12 = !{!13, !14}<br>
+!13 = !DIDerivedType(tag: DW_TAG_member, name: "b0", scope: !11, file: !3, line: 2, baseType: !10, size: 1, flags: DIFlagBitField, extraData: i64 0)<br>
+!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)<br>
+!15 = !{i32 2, !"CodeView", i32 1}<br>
+!16 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!17 = !{i32 1, !"wchar_size", i32 2}<br>
+!18 = !{i32 7, !"PIC Level", i32 2}<br>
+!19 = !{!"clang version 7.0.0 "}<br>
<br>
Modified: llvm/trunk/test/DebugInfo/PDB/obj-globalhash.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/obj-globalhash.test?rev=332664&r1=332663&r2=332664&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/obj-globalhash.test?rev=332664&r1=332663&r2=332664&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/PDB/obj-globalhash.test (original)<br>
+++ llvm/trunk/test/DebugInfo/PDB/obj-globalhash.test Thu May 17 13:47:22 2018<br>
@@ -14,41 +14,41 @@ RUN: cat %T/hashes-combined.out | FileCh<br>
 ; char**.  Both the local and global hashes should be the same, since the only<br>
 ; back-references are for simple types which have fixed indices.<br>
 CHECK-ONE:   obj-hashes-1<br>
-CHECK-ONE:   TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 8B2BA87CC27BF9D290A31A6070FA296AAA577E53<br>
+CHECK-ONE:   TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384<br>
 CHECK-ONE:   obj-hashes-2<br>
-CHECK-ONE:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 8B2BA87CC27BF9D290A31A6070FA296AAA577E53<br>
+CHECK-ONE:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 414E8FCAB16EC28AB86498D1A7F8CF106F39A384<br>
<br>
 ; int**.  Same as char**, both the local and global hashes should be the same.<br>
 CHECK-TWO:   obj-hashes-1<br>
-CHECK-TWO:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 1522A98D88FAF71B618D97BCAC2B89A424EC4805<br>
+CHECK-TWO:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1<br>
 CHECK-TWO:   obj-hashes-2<br>
-CHECK-TWO:   TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 1522A98D88FAF71B618D97BCAC2B89A424EC4805<br>
+CHECK-TWO:   TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 91D2E2AD5D0F20EC1A24BE2E95D0616C5962F4B1<br>
<br>
 ; int***. Different local hashes, since the referent type (int**) is not at the<br>
 ; same TypeIndex in both streams.  Same global hash, since they represent the<br>
 ; same record.<br>
 CHECK-THREE: obj-hashes-1<br>
-CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4<br>
+CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 68A6DDB5C538D379E72E6425591A2B16352DF93D<br>
 CHECK-THREE: obj-hashes-2<br>
-CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: EC11CE9F78D6BF61F8D913A9E2C98293782A7EB4<br>
+CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 68A6DDB5C538D379E72E6425591A2B16352DF93D<br>
<br>
 ; arg list (char**, int***).  Different local hashes, since the parameter types<br>
 ; both occur at different TypeIndices in their respective input streams.  Same<br>
 ; global hash, since the global hash of all referenced types is the same in<br>
 ; both streams.<br>
 CHECK-FOUR:  obj-hashes-1<br>
-CHECK-FOUR:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 1088AD64CEBC88D9E015058A159516AF20B79286<br>
+CHECK-FOUR:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51<br>
 CHECK-FOUR:  obj-hashes-2<br>
-CHECK-FOUR:  TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 1088AD64CEBC88D9E015058A159516AF20B79286<br>
+CHECK-FOUR:  TI: 0x1004, LocalHash: {{.*}}, GlobalHash: FD539365C0A8DEC0A1567C3E2F4C82E7AADB0E51<br>
<br>
 ; double**.  This is only in stream 2, as a means to throw off the indexing.<br>
 CHECK-FIVE:  obj-hashes-1<br>
 CHECK-FIVE:  obj-hashes-2<br>
-CHECK-FIVE:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 7803BBDB2947EF46BEA2310D102BD08F68315506<br>
+CHECK-FIVE:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 5BB6926CA7924D06908872FA20691EA9B88584CC<br>
<br>
 ; int** (char**, int***).  For the same logic as described in previous records,<br>
 ; these two records have the same global hash but different local hashes.<br>
 CHECK-SIX:   obj-hashes-1<br>
-CHECK-SIX:   TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 457ABCB8AB70407594B5D72BF471B6BDECC99BC9<br>
+CHECK-SIX:   TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065<br>
 CHECK-SIX:   obj-hashes-2<br>
-CHECK-SIX:   TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 457ABCB8AB70407594B5D72BF471B6BDECC99BC9<br>
+CHECK-SIX:   TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7A8576BA937B2E87BBF94A9CBFA8F993EE746065<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>