llvm.org GIT mirror llvm / 3f8354c
[CodeGen/AccelTable]: Handle -dwarf-linkage-names=Abstract correctly Summary: If we are not emitting a linkage name in the .debug_info sections, we should not add it into the index either. This makes sure our index is consistent with the actual debug info. I am also explicitly setting the --dwarf-linkage-names=All in the name-collsions test as that one would now fail on targets where this defaults to "Abstract" (in fact, it would have failed already if there wasn't a bug in the DWARF verifier, which I fix as well). Reviewers: probinson, aprantl, JDevlieghere Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46748 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332246 91177308-0d34-0410-b5e6-96231b3b80d8 Pavel Labath 1 year, 5 months ago
5 changed file(s) with 97 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
248248
249249 // If the linkage name is different than the name, go ahead and output
250250 // that as well into the name table.
251 if (GV->getLinkageName() != "" && GV->getName() != GV->getLinkageName())
251 if (GV->getLinkageName() != "" && GV->getName() != GV->getLinkageName() &&
252 DD->useAllLinkageNames())
252253 DD->addAccelName(GV->getLinkageName(), *VariableDIE);
253254 }
254255
392392 if (SP->getName() != "")
393393 addAccelName(SP->getName(), Die);
394394
395 // If the linkage name is different than the name, go ahead and output
396 // that as well into the name table.
397 if (SP->getLinkageName() != "" && SP->getName() != SP->getLinkageName())
395 // If the linkage name is different than the name, go ahead and output that as
396 // well into the name table. Only do that if we are going to actually emit
397 // that name.
398 if (SP->getLinkageName() != "" && SP->getName() != SP->getLinkageName() &&
399 (useAllLinkageNames() || InfoHolder.getAbstractSPDies().lookup(SP)))
398400 addAccelName(SP->getLinkageName(), Die);
399401
400402 // If this is an Objective-C selector name add it to the ObjC accelerator
11211121 "of DIE @ {2:x}: index - {3}; debug_info - {4}.\n",
11221122 NI.getUnitOffset(), EntryID, DIEOffset, Str,
11231123 make_range(EntryNames.begin(), EntryNames.end()));
1124 ++NumErrors;
11241125 }
11251126 }
11261127 handleAllErrors(EntryOr.takeError(),
0 ; REQUIRES: object-emission
1
2 ; Generate one file with all linkage names, and another with only abstract ones.
3 ; Then test both.
4 ; RUN: %llc_dwarf -accel-tables=Dwarf -dwarf-linkage-names=All -filetype=obj -o %t.All < %s
5 ; RUN: %llc_dwarf -accel-tables=Dwarf -dwarf-linkage-names=Abstract -filetype=obj -o %t.Abstract < %s
6 ; RUN: llvm-dwarfdump -debug-info -debug-names %t.All | FileCheck %s --check-prefix=ALL
7 ; RUN: llvm-dwarfdump -debug-info -debug-names %t.Abstract \
8 ; RUN: | FileCheck %s --check-prefix=ABSTRACT --implicit-check-not=_Z1gi --implicit-check-not=_ZN1n1vE
9 ; RUN: llvm-dwarfdump -debug-names -verify %t.All | FileCheck --check-prefix=VERIFY %s
10 ; RUN: llvm-dwarfdump -debug-names -verify %t.Abstract | FileCheck --check-prefix=VERIFY %s
11
12 ; We should have all three linkage names in the .debug_info and .debug_names
13 ; ALL: .debug_info contents:
14 ; ALL: DW_AT_linkage_name ("_ZN1n1vE")
15 ; ALL: DW_AT_linkage_name ("_Z1fi")
16 ; ALL: DW_AT_linkage_name ("_Z1gi")
17 ; ALL: .debug_names contents:
18 ; ALL: String: {{.*}} "_Z1fi"
19 ; ALL: String: {{.*}} "_Z1gi"
20 ; ALL: String: {{.*}} "_ZN1n1vE"
21
22 ; Only _Z1fi should be present in both sections
23 ; ABSTRACT: .debug_info contents:
24 ; ABSTRACT: DW_AT_linkage_name ("_Z1fi")
25 ; ABSTRACT: .debug_names contents:
26 ; ABSTRACT: String: {{.*}} "_Z1fi"
27
28 ; There should be no verification errors for both files.
29 ; VERIFY: No errors.
30
31 ; Input generated from the following C code using
32 ; clang -g -O2 -S -emit-llvm
33
34 ; int e(int);
35 ; inline int f(int a) { return e(a); }
36 ; int g(int a) { return f(a); }
37 ;
38 ; namespace n {
39 ; int v;
40 ; }
41
42 @_ZN1n1vE = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0
43
44 define dso_local i32 @_Z1gi(i32 %a) local_unnamed_addr !dbg !12 {
45 entry:
46 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !17
47 call void @llvm.dbg.value(metadata i32 %a, metadata !18, metadata !DIExpression()), !dbg !21
48 %call.i = tail call i32 @_Z1ei(i32 %a), !dbg !23
49 ret i32 %call.i, !dbg !24
50 }
51
52 declare dso_local i32 @_Z1ei(i32) local_unnamed_addr
53
54 ; Function Attrs: nounwind readnone speculatable
55 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
56
57 attributes #2 = { nounwind readnone speculatable }
58
59 !llvm.dbg.cu = !{!5}
60 !llvm.module.flags = !{!8, !9, !10}
61 !llvm.ident = !{!11}
62
63 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
64 !1 = distinct !DIGlobalVariable(name: "v", linkageName: "_ZN1n1vE", scope: !2, file: !3, line: 6, type: !4, isLocal: false, isDefinition: true)
65 !2 = !DINamespace(name: "n", scope: null)
66 !3 = !DIFile(filename: "/tmp/linkage-name.cc", directory: "/usr/local/google/home/labath/ll/build/dbg")
67 !4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
68 !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk 331861) (llvm/trunk 331884)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !6, globals: !7)
69 !6 = !{}
70 !7 = !{!0}
71 !8 = !{i32 2, !"Dwarf Version", i32 4}
72 !9 = !{i32 2, !"Debug Info Version", i32 3}
73 !10 = !{i32 1, !"wchar_size", i32 4}
74 !11 = !{!"clang version 7.0.0 (trunk 331861) (llvm/trunk 331884)"}
75 !12 = distinct !DISubprogram(name: "g", linkageName: "_Z1gi", scope: !3, file: !3, line: 3, type: !13, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !5, retainedNodes: !15)
76 !13 = !DISubroutineType(types: !14)
77 !14 = !{!4, !4}
78 !15 = !{!16}
79 !16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !3, line: 3, type: !4)
80 !17 = !DILocation(line: 3, column: 11, scope: !12)
81 !18 = !DILocalVariable(name: "a", arg: 1, scope: !19, file: !3, line: 2, type: !4)
82 !19 = distinct !DISubprogram(name: "f", linkageName: "_Z1fi", scope: !3, file: !3, line: 2, type: !13, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !5, retainedNodes: !20)
83 !20 = !{!18}
84 !21 = !DILocation(line: 2, column: 18, scope: !19, inlinedAt: !22)
85 !22 = distinct !DILocation(line: 3, column: 23, scope: !12)
86 !23 = !DILocation(line: 2, column: 30, scope: !19, inlinedAt: !22)
87 !24 = !DILocation(line: 3, column: 16, scope: !12)
0 ; REQUIRES: object-emission
1 ; RUN: %llc_dwarf -accel-tables=Dwarf -filetype=obj -o %t < %s
1 ; RUN: %llc_dwarf -accel-tables=Dwarf -dwarf-linkage-names=All -filetype=obj -o %t < %s
22 ; RUN: llvm-dwarfdump -debug-names %t | FileCheck %s
33 ; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s
44