xref: /llvm-project/llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll (revision 60a2b9912514eb94f4d53dae4a727f8079c4c402)
1; XFAIL: target={{.*}}-aix{{.*}}
2; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
3; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
4; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
5
6; Generated from the following C code using
7; clang -S -emit-llvm -g col.c
8;
9; These names were carefully chosen to cause hash collisions. Each type-variable
10; pair will hash to the same value. The also happen to demonstrate a flaw in the
11; DWARF v5 hash function: A copy constructor and an assignment operator for a
12; class will always hash to the same value.
13;
14; typedef ptr_ZN4lldb7SBBlockaSERKS0_;
15; _ZN4lldb7SBBlockaSERKS0_ _ZN4lldb7SBBlockC1ERKS0_;
16; typedef ptr_ZN4lldb7SBErroraSERKS0_;
17; _ZN4lldb7SBErroraSERKS0_ _ZN4lldb7SBErrorC1ERKS0_;
18; typedef ptr_ZN4lldb7SBValueaSERKS0_;
19; _ZN4lldb7SBValueaSERKS0_ _ZN4lldb7SBValueC1ERKS0_;
20; typedef ptr_ZL11numCommutes;
21; _ZL11numCommutes _ZL11NumCommutes;
22; typedef ptr_ZL9NumRemats;
23; _ZL9NumRemats _ZL9NumReMats;
24
25; Check that we have the right amount of hashes and names.
26; CHECK: Bucket count: 5
27; CHECK: Name count: 10
28
29; Check that all the names are present in the output
30; CHECK: Bucket 0
31; CHECK:     Hash: 0xF8CF70D
32; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBBlockaSERKS0_"
33; CHECK:     Hash: 0xF8CF70D
34; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBBlockC1ERKS0_"
35; CHECK:     Hash: 0x135A482C
36; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBErroraSERKS0_"
37; CHECK:     Hash: 0x135A482C
38; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBErrorC1ERKS0_"
39; CHECK-NOT: String:
40; CHECK: Bucket 1
41; CHECK-NEXT: EMPTY
42; CHECK: Bucket 2
43; CHECK:     Hash: 0x2841B989
44; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL11numCommutes"
45; CHECK:     Hash: 0x2841B989
46; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL11NumCommutes"
47; CHECK:     Hash: 0x3E190F5F
48; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL9NumRemats"
49; CHECK:     Hash: 0x3E190F5F
50; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZL9NumReMats"
51; CHECK-NOT: String:
52; CHECK: Bucket 3
53; CHECK:     Hash: 0x2642207F
54; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBValueaSERKS0_"
55; CHECK:     Hash: 0x2642207F
56; CHECK-NEXT:String: 0x{{[0-9a-f]*}} "_ZN4lldb7SBValueC1ERKS0_"
57; CHECK-NOT: String:
58; CHECK:  Bucket 4
59; CHECK-NEXT: EMPTY
60
61; VERIFY: No errors.
62
63@_ZN4lldb7SBBlockC1ERKS0_ = common dso_local global ptr null, align 8, !dbg !0
64@_ZN4lldb7SBErrorC1ERKS0_ = common dso_local global ptr null, align 8, !dbg !6
65@_ZN4lldb7SBValueC1ERKS0_ = common dso_local global ptr null, align 8, !dbg !10
66@_ZL11NumCommutes = common dso_local global ptr null, align 8, !dbg !13
67@_ZL9NumReMats = common dso_local global ptr null, align 8, !dbg !16
68
69!llvm.dbg.cu = !{!2}
70!llvm.module.flags = !{!20, !21, !22}
71!llvm.ident = !{!23}
72
73!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
74!1 = distinct !DIGlobalVariable(name: "_ZN4lldb7SBBlockC1ERKS0_", scope: !2, file: !3, line: 1, type: !19, isLocal: false, isDefinition: true)
75!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
76!3 = !DIFile(filename: "/tmp/col.c", directory: "/tmp")
77!4 = !{}
78!5 = !{!0, !6, !10, !13, !16}
79!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
80!7 = distinct !DIGlobalVariable(name: "_ZN4lldb7SBErrorC1ERKS0_", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
81!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZN4lldb7SBErroraSERKS0_", file: !3, line: 2, baseType: !9)
82!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
83!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
84!11 = distinct !DIGlobalVariable(name: "_ZN4lldb7SBValueC1ERKS0_", scope: !2, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true)
85!12 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZN4lldb7SBValueaSERKS0_", file: !3, line: 3, baseType: !9)
86!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression())
87!14 = distinct !DIGlobalVariable(name: "_ZL11NumCommutes", scope: !2, file: !3, line: 4, type: !15, isLocal: false, isDefinition: true)
88!15 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZL11numCommutes", file: !3, line: 4, baseType: !9)
89!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression())
90!17 = distinct !DIGlobalVariable(name: "_ZL9NumReMats", scope: !2, file: !3, line: 5, type: !18, isLocal: false, isDefinition: true)
91!18 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZL9NumRemats", file: !3, line: 5, baseType: !9)
92!19 = !DIDerivedType(tag: DW_TAG_typedef, name: "_ZN4lldb7SBBlockaSERKS0_", file: !3, line: 1, baseType: !9)
93!20 = !{i32 2, !"Dwarf Version", i32 4}
94!21 = !{i32 2, !"Debug Info Version", i32 3}
95!22 = !{i32 1, !"wchar_size", i32 4}
96!23 = !{!"clang version 7.0.0 (trunk 325496) (llvm/trunk 325732)"}
97