This revision was automatically updated to reflect the committed changes.
aganea marked 2 inline comments as done.
Closed by commit rG49e483d3d62f: [CodeView] Replace GHASH hasher by BLAKE3 
(authored by aganea).
Herald added a reviewer: MaskRay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D137101?vs=472098&id=476698#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137101/new/

https://reviews.llvm.org/D137101

Files:
  clang/docs/ReleaseNotes.rst
  lld/COFF/DebugTypes.cpp
  lld/docs/ReleaseNotes.rst
  llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
  llvm/test/DebugInfo/COFF/global-type-hashes.ll
  llvm/test/DebugInfo/PDB/obj-globalhash.test

Index: llvm/test/DebugInfo/PDB/obj-globalhash.test
===================================================================
--- llvm/test/DebugInfo/PDB/obj-globalhash.test
+++ llvm/test/DebugInfo/PDB/obj-globalhash.test
@@ -14,41 +14,41 @@
 ; 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: A7F8CF106F39A384
+CHECK-ONE:   TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 912CE718D99C2F74
 CHECK-ONE:   obj-hashes-2
-CHECK-ONE:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: A7F8CF106F39A384
+CHECK-ONE:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 912CE718D99C2F74
 
 ; 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: 95D0616C5962F4B1
+CHECK-TWO:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 20DAD105A7C67E1D
 CHECK-TWO:   obj-hashes-2
-CHECK-TWO:   TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 95D0616C5962F4B1
+CHECK-TWO:   TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 20DAD105A7C67E1D
 
 ; 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: 48D95F14F6176F4F
+CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 09CBAD68AF5C7998
 CHECK-THREE: obj-hashes-2
-CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 48D95F14F6176F4F
+CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 09CBAD68AF5C7998
 
 ; 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: 99410CD14F5EE80D
+CHECK-FOUR:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: B6A17FFA392FDF6E
 CHECK-FOUR:  obj-hashes-2
-CHECK-FOUR:  TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 99410CD14F5EE80D
+CHECK-FOUR:  TI: 0x1004, LocalHash: {{.*}}, GlobalHash: B6A17FFA392FDF6E
 
 ; 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: 20691EA9B88584CC
+CHECK-FIVE:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 357B0B78DBFB83B4
 
 ; 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: 7ACF479173341AC1
+CHECK-SIX:   TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 8356432DE786E196
 CHECK-SIX:   obj-hashes-2
-CHECK-SIX:   TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7ACF479173341AC1
+CHECK-SIX:   TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 8356432DE786E196
Index: llvm/test/DebugInfo/COFF/global-type-hashes.ll
===================================================================
--- llvm/test/DebugInfo/COFF/global-type-hashes.ll
+++ llvm/test/DebugInfo/COFF/global-type-hashes.ll
@@ -21,129 +21,142 @@
 
 ; ModuleID = 'foo.cpp'
 source_filename = "foo.cpp"
-target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32"
 target triple = "i686-pc-windows-msvc19.11.25547"
 
 %struct.Foo = type { i32, i32 }
 
-$"\01??0Foo@@QAE@HH@Z" = comdat any
+$"??0Foo@@QAE@HH@Z" = comdat any
 
-$"\01?method@Foo@@QAEHXZ" = comdat any
+$"?method@Foo@@QAEHXZ" = comdat any
 
-; Function Attrs: noinline norecurse nounwind optnone
-define i32 @main(i32 %argc, i8** %argv) #0 !dbg !8 {
+; Function Attrs: mustprogress noinline norecurse nounwind optnone
+define dso_local noundef i32 @main(i32 noundef %argc, ptr noundef %argv) #0 !dbg !8 {
 entry:
   %retval = alloca i32, align 4
-  %argv.addr = alloca i8**, align 4
+  %argv.addr = alloca ptr, align 4
   %argc.addr = alloca i32, align 4
   %F = alloca %struct.Foo, align 4
-  store i32 0, i32* %retval, align 4
-  store i8** %argv, i8*** %argv.addr, align 4
-  call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !16, metadata !DIExpression()), !dbg !17
-  store i32 %argc, i32* %argc.addr, align 4
-  call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !18, metadata !DIExpression()), !dbg !17
-  call void @llvm.dbg.declare(metadata %struct.Foo* %F, metadata !19, metadata !DIExpression()), !dbg !31
-  %0 = load i32, i32* %argc.addr, align 4, !dbg !31
-  %1 = load i32, i32* %argc.addr, align 4, !dbg !31
-  %call = call x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@HH@Z"(%struct.Foo* %F, i32 %0, i32 %1), !dbg !31
-  %call1 = call x86_thiscallcc i32 @"\01?method@Foo@@QAEHXZ"(%struct.Foo* %F), !dbg !32
-  ret i32 %call1, !dbg !32
+  store i32 0, ptr %retval, align 4
+  store ptr %argv, ptr %argv.addr, align 4
+  call void @llvm.dbg.declare(metadata ptr %argv.addr, metadata !17, metadata !DIExpression()), !dbg !18
+  store i32 %argc, ptr %argc.addr, align 4
+  call void @llvm.dbg.declare(metadata ptr %argc.addr, metadata !19, metadata !DIExpression()), !dbg !20
+  call void @llvm.dbg.declare(metadata ptr %F, metadata !21, metadata !DIExpression()), !dbg !33
+  %0 = load i32, ptr %argc.addr, align 4, !dbg !34
+  %1 = load i32, ptr %argc.addr, align 4, !dbg !35
+  %call = call x86_thiscallcc noundef ptr @"??0Foo@@QAE@HH@Z"(ptr noundef nonnull align 4 dereferenceable(8) %F, i32 noundef %0, i32 noundef %1), !dbg !33
+  %call1 = call x86_thiscallcc noundef i32 @"?method@Foo@@QAEHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %F), !dbg !36
+  ret i32 %call1, !dbg !37
 }
 
-; Function Attrs: nounwind readnone speculatable
+; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
 
 ; Function Attrs: noinline nounwind optnone
-define linkonce_odr x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@HH@Z"(%struct.Foo* returned %this, i32 %x, i32 %y) unnamed_addr #2 comdat align 2 !dbg !33 {
+define linkonce_odr dso_local x86_thiscallcc noundef ptr @"??0Foo@@QAE@HH@Z"(ptr noundef nonnull returned align 4 dereferenceable(8) %this, i32 noundef %x, i32 noundef %y) unnamed_addr #2 comdat align 2 !dbg !38 {
 entry:
   %y.addr = alloca i32, align 4
   %x.addr = alloca i32, align 4
-  %this.addr = alloca %struct.Foo*, align 4
-  store i32 %y, i32* %y.addr, align 4
-  call void @llvm.dbg.declare(metadata i32* %y.addr, metadata !34, metadata !DIExpression()), !dbg !35
-  store i32 %x, i32* %x.addr, align 4
-  call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !36, metadata !DIExpression()), !dbg !35
-  store %struct.Foo* %this, %struct.Foo** %this.addr, align 4
-  call void @llvm.dbg.declare(metadata %struct.Foo** %this.addr, metadata !37, metadata !DIExpression()), !dbg !39
-  %this1 = load %struct.Foo*, %struct.Foo** %this.addr, align 4
-  %X = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 0, !dbg !35
-  %0 = load i32, i32* %x.addr, align 4, !dbg !35
-  store i32 %0, i32* %X, align 4, !dbg !35
-  %Y = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 1, !dbg !35
-  %1 = load i32, i32* %y.addr, align 4, !dbg !35
-  store i32 %1, i32* %Y, align 4, !dbg !35
-  ret %struct.Foo* %this1, !dbg !35
+  %this.addr = alloca ptr, align 4
+  store i32 %y, ptr %y.addr, align 4
+  call void @llvm.dbg.declare(metadata ptr %y.addr, metadata !39, metadata !DIExpression()), !dbg !40
+  store i32 %x, ptr %x.addr, align 4
+  call void @llvm.dbg.declare(metadata ptr %x.addr, metadata !41, metadata !DIExpression()), !dbg !42
+  store ptr %this, ptr %this.addr, align 4
+  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !43, metadata !DIExpression()), !dbg !45
+  %this1 = load ptr, ptr %this.addr, align 4
+  %X = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 0, !dbg !46
+  %0 = load i32, ptr %x.addr, align 4, !dbg !47
+  store i32 %0, ptr %X, align 4, !dbg !46
+  %Y = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 1, !dbg !48
+  %1 = load i32, ptr %y.addr, align 4, !dbg !49
+  store i32 %1, ptr %Y, align 4, !dbg !48
+  ret ptr %this1, !dbg !50
 }
 
-; Function Attrs: noinline nounwind optnone
-define linkonce_odr x86_thiscallcc i32 @"\01?method@Foo@@QAEHXZ"(%struct.Foo* %this) #2 comdat align 2 !dbg !40 {
+; Function Attrs: mustprogress noinline nounwind optnone
+define linkonce_odr dso_local x86_thiscallcc noundef i32 @"?method@Foo@@QAEHXZ"(ptr noundef nonnull align 4 dereferenceable(8) %this) #3 comdat align 2 !dbg !51 {
 entry:
-  %this.addr = alloca %struct.Foo*, align 4
-  store %struct.Foo* %this, %struct.Foo** %this.addr, align 4
-  call void @llvm.dbg.declare(metadata %struct.Foo** %this.addr, metadata !41, metadata !DIExpression()), !dbg !42
-  %this1 = load %struct.Foo*, %struct.Foo** %this.addr, align 4
-  %X = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 0, !dbg !43
-  %0 = load i32, i32* %X, align 4, !dbg !43
-  %Y = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 1, !dbg !43
-  %1 = load i32, i32* %Y, align 4, !dbg !43
-  %add = add nsw i32 %0, %1, !dbg !43
-  ret i32 %add, !dbg !43
+  %this.addr = alloca ptr, align 4
+  store ptr %this, ptr %this.addr, align 4
+  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !52, metadata !DIExpression()), !dbg !53
+  %this1 = load ptr, ptr %this.addr, align 4
+  %X = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 0, !dbg !54
+  %0 = load i32, ptr %X, align 4, !dbg !54
+  %Y = getelementptr inbounds %struct.Foo, ptr %this1, i32 0, i32 1, !dbg !55
+  %1 = load i32, ptr %Y, align 4, !dbg !55
+  %add = add nsw i32 %0, %1, !dbg !56
+  ret i32 %add, !dbg !57
 }
 
-attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone speculatable }
-attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #0 = { mustprogress noinline norecurse nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
+attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
+attributes #2 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
+attributes #3 = { mustprogress noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
 
 !llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5, !6, !100}
+!llvm.module.flags = !{!2, !3, !4, !5, !6}
 !llvm.ident = !{!7}
 
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
-!1 = !DIFile(filename: "<stdin>", directory: "D:\5Csrc\5Cllvmbuild\5Cclang\5CDebug\5Cx86", checksumkind: CSK_MD5, checksum: "6279449503d9075c38e615e8387667c3")
-!2 = !{}
-!3 = !{i32 1, !"NumRegisterParameters", i32 0}
-!4 = !{i32 2, !"CodeView", i32 1}
-!100 = !{i32 2, !"CodeViewGHash", i32 1}
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 16.0.0 (https://github.com/llvm/llvm-project.git a784de783af5096e593c5e214c2c78215fe303f5)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "<stdin>", directory: "C:\\git\\llvm-project", checksumkind: CSK_MD5, checksum: "d54692241b2727e6ae75e9d429c51680")
+!2 = !{i32 1, !"NumRegisterParameters", i32 0}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"CodeViewGHash", i32 1}
 !5 = !{i32 2, !"Debug Info Version", i32 3}
 !6 = !{i32 1, !"wchar_size", i32 2}
-!7 = !{!"clang version 6.0.0 "}
-!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 8, type: !10, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
-!9 = !DIFile(filename: "foo.cpp", directory: "D:\5Csrc\5Cllvmbuild\5Cclang\5CDebug\5Cx86", checksumkind: CSK_MD5, checksum: "6279449503d9075c38e615e8387667c3")
+!7 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project.git a784de783af5096e593c5e214c2c78215fe303f5)"}
+!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 7, type: !10, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !16)
+!9 = !DIFile(filename: "foo.cpp", directory: "C:\\git\\llvm-project", checksumkind: CSK_MD5, checksum: "d54692241b2727e6ae75e9d429c51680")
 !10 = !DISubroutineType(types: !11)
 !11 = !{!12, !12, !13}
 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32)
 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
-!16 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 8, type: !13)
-!17 = !DILocation(line: 8, scope: !8)
-!18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 8, type: !12)
-!19 = !DILocalVariable(name: "F", scope: !8, file: !9, line: 9, type: !20)
-!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !9, line: 1, size: 64, elements: !21, identifier: ".?AUFoo@@")
-!21 = !{!22, !23, !24, !28}
-!22 = !DIDerivedType(tag: DW_TAG_member, name: "X", scope: !20, file: !9, line: 4, baseType: !12, size: 32)
-!23 = !DIDerivedType(tag: DW_TAG_member, name: "Y", scope: !20, file: !9, line: 5, baseType: !12, size: 32, offset: 32)
-!24 = !DISubprogram(name: "Foo", scope: !20, file: !9, line: 2, type: !25, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
-!25 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !26)
-!26 = !{null, !27, !12, !12}
-!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
-!28 = !DISubprogram(name: "method", linkageName: "\01?method@Foo@@QAEHXZ", scope: !20, file: !9, line: 3, type: !29, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false)
-!29 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !30)
-!30 = !{!12, !27}
-!31 = !DILocation(line: 9, scope: !8)
-!32 = !DILocation(line: 10, scope: !8)
-!33 = distinct !DISubprogram(name: "Foo", linkageName: "\01??0Foo@@QAE@HH@Z", scope: !20, file: !9, line: 2, type: !25, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !24, retainedNodes: !2)
-!34 = !DILocalVariable(name: "y", arg: 3, scope: !33, file: !9, line: 2, type: !12)
-!35 = !DILocation(line: 2, scope: !33)
-!36 = !DILocalVariable(name: "x", arg: 2, scope: !33, file: !9, line: 2, type: !12)
-!37 = !DILocalVariable(name: "this", arg: 1, scope: !33, type: !38, flags: DIFlagArtificial | DIFlagObjectPointer)
-!38 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 32)
-!39 = !DILocation(line: 0, scope: !33)
-!40 = distinct !DISubprogram(name: "method", linkageName: "\01?method@Foo@@QAEHXZ", scope: !20, file: !9, line: 3, type: !29, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !28, retainedNodes: !2)
-!41 = !DILocalVariable(name: "this", arg: 1, scope: !40, type: !38, flags: DIFlagArtificial | DIFlagObjectPointer)
-!42 = !DILocation(line: 0, scope: !40)
-!43 = !DILocation(line: 3, scope: !40)
+!16 = !{}
+!17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 7, type: !13)
+!18 = !DILocation(line: 7, column: 27, scope: !8)
+!19 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 7, type: !12)
+!20 = !DILocation(line: 7, column: 14, scope: !8)
+!21 = !DILocalVariable(name: "F", scope: !8, file: !9, line: 8, type: !22)
+!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !9, line: 1, size: 64, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !23, identifier: ".?AUFoo@@")
+!23 = !{!24, !25, !26, !30}
+!24 = !DIDerivedType(tag: DW_TAG_member, name: "X", scope: !22, file: !9, line: 4, baseType: !12, size: 32)
+!25 = !DIDerivedType(tag: DW_TAG_member, name: "Y", scope: !22, file: !9, line: 5, baseType: !12, size: 32, offset: 32)
+!26 = !DISubprogram(name: "Foo", scope: !22, file: !9, line: 2, type: !27, scopeLine: 2, flags: DIFlagPrototyped, spFlags: 0)
+!27 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !28)
+!28 = !{null, !29, !12, !12}
+!29 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
+!30 = !DISubprogram(name: "method", linkageName: "?method@Foo@@QAEHXZ", scope: !22, file: !9, line: 3, type: !31, scopeLine: 3, flags: DIFlagPrototyped, spFlags: 0)
+!31 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !32)
+!32 = !{!12, !29}
+!33 = !DILocation(line: 8, column: 7, scope: !8)
+!34 = !DILocation(line: 8, column: 10, scope: !8)
+!35 = !DILocation(line: 8, column: 16, scope: !8)
+!36 = !DILocation(line: 9, column: 12, scope: !8)
+!37 = !DILocation(line: 9, column: 3, scope: !8)
+!38 = distinct !DISubprogram(name: "Foo", linkageName: "??0Foo@@QAE@HH@Z", scope: !22, file: !9, line: 2, type: !27, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !26, retainedNodes: !16)
+!39 = !DILocalVariable(name: "y", arg: 3, scope: !38, file: !9, line: 2, type: !12)
+!40 = !DILocation(line: 2, column: 18, scope: !38)
+!41 = !DILocalVariable(name: "x", arg: 2, scope: !38, file: !9, line: 2, type: !12)
+!42 = !DILocation(line: 2, column: 11, scope: !38)
+!43 = !DILocalVariable(name: "this", arg: 1, scope: !38, type: !44, flags: DIFlagArtificial | DIFlagObjectPointer)
+!44 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32)
+!45 = !DILocation(line: 0, scope: !38)
+!46 = !DILocation(line: 2, column: 23, scope: !38)
+!47 = !DILocation(line: 2, column: 25, scope: !38)
+!48 = !DILocation(line: 2, column: 29, scope: !38)
+!49 = !DILocation(line: 2, column: 31, scope: !38)
+!50 = !DILocation(line: 2, column: 35, scope: !38)
+!51 = distinct !DISubprogram(name: "method", linkageName: "?method@Foo@@QAEHXZ", scope: !22, file: !9, line: 3, type: !31, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !30, retainedNodes: !16)
+!52 = !DILocalVariable(name: "this", arg: 1, scope: !51, type: !44, flags: DIFlagArtificial | DIFlagObjectPointer)
+!53 = !DILocation(line: 0, scope: !51)
+!54 = !DILocation(line: 3, column: 25, scope: !51)
+!55 = !DILocation(line: 3, column: 29, scope: !51)
+!56 = !DILocation(line: 3, column: 27, scope: !51)
+!57 = !DILocation(line: 3, column: 18, scope: !51)
 
 
 ; YAML: --- !COFF
@@ -197,7 +210,7 @@
 ; YAML:           ClassType:       4100
 ; YAML:           ThisType:        4101
 ; YAML:           CallConv:        ThisCall
-; YAML:           Options:         [ None ]
+; YAML:           Options:         [ None, Constructor ]
 ; YAML:           ParameterCount:  2
 ; YAML:           ArgumentList:    4102
 ; YAML:           ThisPointerAdjustment: 0
@@ -243,7 +256,7 @@
 ; YAML:       - Kind:            LF_STRUCTURE
 ; YAML:         Class:
 ; YAML:           MemberCount:     4
-; YAML:           Options:         [ None, HasUniqueName ]
+; YAML:           Options:         [ None, HasConstructorOrDestructor, HasUniqueName ]
 ; YAML:           FieldList:       4106
 ; YAML:           Name:            Foo
 ; YAML:           UniqueName:      '.?AUFoo@@'
@@ -253,7 +266,7 @@
 ; YAML:       - Kind:            LF_STRING_ID
 ; YAML:         StringId:
 ; YAML:           Id:              0
-; YAML:           String:          'D:\src\llvmbuild\clang\Debug\x86\foo.cpp'
+; YAML:           String:          'C:\git\llvm-project\foo.cpp'
 ; YAML:       - Kind:            LF_UDT_SRC_LINE
 ; YAML:         UdtSourceLine:
 ; YAML:           UDT:             4107
@@ -264,49 +277,66 @@
 ; YAML:           ClassType:       4100
 ; YAML:           FunctionType:    4103
 ; YAML:           Name:            Foo
+; YAML:       - Kind:            LF_POINTER
+; YAML:         Pointer:
+; YAML:           ReferentType:    4100
+; YAML:           Attrs:           32778
 ; YAML:       - Kind:            LF_MFUNC_ID
 ; YAML:         MemberFuncId:
 ; YAML:           ClassType:       4100
 ; YAML:           FunctionType:    4105
 ; YAML:           Name:            method
+; YAML:       - Kind:            LF_STRING_ID
+; YAML:         StringId:
+; YAML:           Id:              0
+; YAML:           String:          'C:\git\llvm-project'
+; YAML:       - Kind:            LF_STRING_ID
+; YAML:         StringId:
+; YAML:           Id:              0
+; YAML:           String:          '<stdin>'
+; YAML:       - Kind:            LF_STRING_ID
+; YAML:         StringId:
+; YAML:           Id:              0
+; YAML:           String:          ''
+; YAML:       - Kind:            LF_BUILDINFO
+; YAML:         BuildInfo:
+; YAML:           ArgIndices:      [ 4113, 0, 4114, 4115, 0 ]
 ; YAML:   - Name:            '.debug$H'
 ; YAML:     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
 ; YAML:     Alignment:       4
 ; YAML:     GlobalHashes:
 ; YAML:       Version:         0
-; YAML:       HashAlgorithm:   1
+; YAML:       HashAlgorithm:   2
 ; YAML:       HashValues:
-; YAML:         - 800309EE1ED8BB5B
-; YAML:         - 5397319F1CC14E2C
-; YAML:         - DF04AA3125BBC50E
-; YAML:         - 95CEBA304A2C4493
-; YAML:         - C324F82D24D22283
-; YAML:         - BB039258F2425BCF
-; YAML:         - DDE23757322DB7C3
-; YAML:         - 44D3ED149C981B2A
-; YAML:         - D341E2F9BE57A1C7
-; YAML:         - DD327744BE6783A4
-; YAML:         - 5B17837C70325869
-; YAML:         - 375C55CDF44B4147
-; YAML:         - 0634944401BCC520
-; YAML:         - 6CC0AFB95FA2BFF2
-; YAML:         - D016F92E5C009314
-; YAML:         - 74698BE366891D3D
-; YAML:         - 4470750F2E319329
-; YAML:         - 0FB556FD1FAB66D7
-; YAML:         - 5970EFB4874D0F3F
-; YAML:         - D8EF11198C33843F
-; YAML:         - D81F744D7366282B
-; ...
-
+; YAML:         - 0FDF2CE06172DBE8
+; YAML:         - B5E1C8329B9F4E7F
+; YAML:         - 1EE1398011AA4BE1
+; YAML:         - B682FB0B006CEC2E
+; YAML:         - 8F2D2AE45F6E79E8
+; YAML:         - 1747FDF05D25DDEE
+; YAML:         - EAA738703837EBAE
+; YAML:         - 07B9EF65EBA94121
+; YAML:         - AFF81B6AE460D908
+; YAML:         - 90DFD798AF84402C
+; YAML:         - B9DDCF9F86BABE9E
+; YAML:         - D1E2E5CAA3B96825
+; YAML:         - 10994F943B4E46F3
+; YAML:         - 4E2B6BC0E79F4271
+; YAML:         - 72A4762DBB2AF2E4
+; YAML:         - 1891CC40E9028AE7
+; YAML:         - 1E6104ECC17E43DE
+; YAML:         - 174CF4A3F5448049
+; YAML:         - 5349856AF14E2246
+; YAML:         - 55A48E0466FDCDA6
+; YAML:         - 886A1B73D31E9877
 
 ; 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   0x80, 0x03, 0x09, 0xee  # 0x1000 [800309EE1ED8BB5B]
-; ASM-NEXT: .byte   0x1e, 0xd8, 0xbb, 0x5b
-; 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]
+; ASM-NEXT: .short  2                       # Hash Algorithm
+; ASM-NEXT: .byte   0x0f, 0xdf, 0x2c, 0xe0  # 0x1000 [0FDF2CE06172DBE8]
+; ASM-NEXT: .byte   0x61, 0x72, 0xdb, 0xe8
+; ASM-NEXT: .byte   0xb5, 0xe1, 0xc8, 0x32  # 0x1001 [B5E1C8329B9F4E7F]
+; ASM-NEXT: .byte   0x9b, 0x9f, 0x4e, 0x7f
+; ASM-NEXT: .byte   0x1e, 0xe1, 0x39, 0x80  # 0x1002 [1EE1398011AA4BE1]
\ No newline at end of file
Index: llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
===================================================================
--- llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
+++ llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
@@ -9,7 +9,7 @@
 #include "llvm/DebugInfo/CodeView/TypeHashing.h"
 
 #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
-#include "llvm/Support/SHA1.h"
+#include "llvm/Support/BLAKE3.h"
 
 using namespace llvm;
 using namespace llvm::codeview;
@@ -35,7 +35,7 @@
                              ArrayRef<GloballyHashedType> PreviousIds) {
   SmallVector<TiReference, 4> Refs;
   discoverTypeIndices(RecordData, Refs);
-  SHA1 S;
+  TruncatedBLAKE3<8> S;
   S.init();
   uint32_t Off = 0;
   S.update(RecordData.take_front(sizeof(RecordPrefix)));
@@ -76,6 +76,5 @@
   auto TrailingBytes = RecordData.drop_front(Off);
   S.update(TrailingBytes);
 
-  std::array<uint8_t, 20> Hash = S.final();
-  return {ArrayRef<uint8_t>(Hash).take_back(8)};
+  return {S.final()};
 }
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -760,7 +760,7 @@
   OS.AddComment("Section Version");
   OS.emitInt16(0);
   OS.AddComment("Hash Algorithm");
-  OS.emitInt16(uint16_t(GlobalTypeHashAlg::SHA1_8));
+  OS.emitInt16(uint16_t(GlobalTypeHashAlg::BLAKE3));
 
   TypeIndex TI(TypeIndex::FirstNonSimpleIndex);
   for (const auto &GHR : TypeTable.hashes()) {
Index: llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
===================================================================
--- llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -61,7 +61,8 @@
 
 enum class GlobalTypeHashAlg : uint16_t {
   SHA1 = 0, // standard 20-byte SHA1 hash
-  SHA1_8    // last 8-bytes of standard SHA1 hash
+  SHA1_8,   // last 8-bytes of standard SHA1 hash
+  BLAKE3,   // truncated 8-bytes BLAKE3
 };
 
 /// A globally hashed type represents a hash value that is sufficient to
Index: lld/docs/ReleaseNotes.rst
===================================================================
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -43,6 +43,8 @@
 * The linker command line entry in ``S_ENVBLOCK`` of the PDB is now stripped
   from input files, to align with MSVC behavior.
   (`D137723 <https://reviews.llvm.org/D137723>`_)
+* Switched from SHA1 to BLAKE3 for PDB type hashing / ``-gcodeview-ghash``
+  (`D137101 <https://reviews.llvm.org/D137101>`_)
 
 MinGW Improvements
 ------------------
Index: lld/COFF/DebugTypes.cpp
===================================================================
--- lld/COFF/DebugTypes.cpp
+++ lld/COFF/DebugTypes.cpp
@@ -275,7 +275,7 @@
   debugH = debugH.drop_front(sizeof(object::debug_h_header));
   return header->Magic == COFF::DEBUG_HASHES_SECTION_MAGIC &&
          header->Version == 0 &&
-         header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::SHA1_8) &&
+         header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::BLAKE3) &&
          (debugH.size() % 8 == 0);
 }
 
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -519,6 +519,8 @@
   ``/guard:cf,nochecks`` in clang-cl) for enabling Control Flow Guard checks
   and generation of address-taken function table.
 
+- Switched from SHA1 to BLAKE3 for PDB type hashing / ``-gcodeview-ghash``
+
 AIX Support
 -----------
 * When using ``-shared``, the clang driver now invokes llvm-nm to create an
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D137101: [CodeView... Alexandre Ganea via Phabricator via cfe-commits

Reply via email to