Skip to content

Commit dad4907

Browse files
committedDec 2, 2016
[DWARF] Put linkage-name on abstract origin even when there's a declaration.
In r266692, we made it possible to emit linkage names for just inlined functions, putting the attribute on the abstract origin. Make sure we don't think the linkage-name was already emitted on a declaration. Differential Revision: http://reviews.llvm.org/D27320 llvm-svn: 288450
1 parent 444e6f3 commit dad4907

File tree

2 files changed

+97
-36
lines changed

2 files changed

+97
-36
lines changed
 

‎llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,9 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
11501150
assert(DeclDie && "This DIE should've already been constructed when the "
11511151
"definition DIE was created in "
11521152
"getOrCreateSubprogramDIE");
1153-
DeclLinkageName = SPDecl->getLinkageName();
1153+
// Look at the Decl's linkage name only if we emitted it.
1154+
if (DD->useAllLinkageNames())
1155+
DeclLinkageName = SPDecl->getLinkageName();
11541156
unsigned DeclID =
11551157
getOrCreateSourceID(SPDecl->getFilename(), SPDecl->getDirectory());
11561158
unsigned DefID = getOrCreateSourceID(SP->getFilename(), SP->getDirectory());

‎llvm/test/DebugInfo/Generic/linkage-name-abstract.ll

+94-35
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,115 @@
1818
; void f3() {
1919
; f2();
2020
; }
21+
;
22+
; struct F4 {
23+
; __attribute__((always_inline)) void f5();
24+
; };
25+
; void F4::f5() {
26+
; f1();
27+
; }
28+
; void f6() {
29+
; F4::f5();
30+
; }
2131

22-
; Show that there's only one linkage_name.
23-
; ONENAME: {{DW_AT(_MIPS)?_linkage_name}}
32+
; Show that the only linkage names are for the inlined functions,
33+
; because those are the ones with an abstract origin.
34+
; ONENAME-NOT: {{DW_AT(_MIPS)?_linkage_name}}
35+
; ONENAME: {{DW_AT(_MIPS)?_linkage_name}} {{.*}} "_Z2f2v"
2436
; ONENAME-NOT: {{DW_AT(_MIPS)?_linkage_name}}
37+
; ONENAME: {{DW_AT(_MIPS)?_linkage_name}} {{.*}} "_ZN2F42f5Ev"
38+
; ONENAME-NOT: {{DW_AT(_MIPS)?_linkage_name}}
39+
40+
; For f2() we see the definition pointing to an abstract origin DIE,
41+
; which in turn is where the linkage_name is; and then there's
42+
; an inlined_subroutine pointing back to the abstract origin.
43+
; The order of these DIEs is not important of course, just the links.
44+
; REF: DW_TAG_subprogram
45+
; REF-NOT: {{DW_TAG|NULL}}
46+
; REF: DW_AT_abstract_origin {{.*}} {[[F2:0x.*]]} "_Z2f2v"
47+
; REF: [[F2]]: DW_TAG_subprogram
48+
; REF-NEXT: linkage_name {{.*}} "_Z2f2v"
49+
; REF: DW_TAG_inlined_subroutine
50+
; REF-NOT: {{DW_TAG|NULL}}
51+
; REF: DW_AT_abstract_origin {{.*}} {[[F2]]}
52+
53+
; For F4::f5(), first we see the in-class declaration,
54+
; then the definition, abstract origin, and the inlined_subroutine.
55+
; REF: DW_TAG_structure_type
56+
; REF-NEXT: DW_AT_name {{.*}} "F4"
57+
; REF-NOT: {{DW_TAG|NULL}}
58+
; REF: [[F5_DECL:0x.*]]: DW_TAG_subprogram
59+
; REF-NEXT: DW_AT_name {{.*}} "f5"
60+
; REF: DW_TAG_subprogram
61+
; REF-NOT: {{DW_TAG|NULL}}
62+
; REF: DW_AT_abstract_origin {{.*}} {[[F5_ABS:0x.*]]} "_ZN2F42f5Ev"
63+
; REF: [[F5_ABS]]: DW_TAG_subprogram
64+
; REF-NOT: {{DW_TAG|NULL}}
65+
; REF: linkage_name {{.*}} "_ZN2F42f5Ev"
66+
; REF-NEXT: DW_AT_specification {{.*}} {[[F5_DECL]]}
67+
; REF: DW_TAG_inlined_subroutine
68+
; REF-NOT: {{DW_TAG|NULL}}
69+
; REF: DW_AT_abstract_origin {{.*}} {[[F5_ABS]]}
2570

26-
; Locate the subprogram DIE with the linkage name.
27-
; Show that the inlined_subroutine refers to it.
28-
; REF: DW_TAG_subprogram
29-
; REF: [[FOO:0x.*]]: DW_TAG_subprogram
30-
; REF-NOT: {{DW_TAG|NULL}}
31-
; REF: {{DW_AT(_MIPS)?_linkage_name}}
32-
; REF: DW_TAG_inlined_subroutine
33-
; REF-NOT: {{DW_TAG|NULL}}
34-
; REF: DW_AT_abstract_origin {{.*}} {[[FOO]]}
3571

3672
; Function Attrs: alwaysinline uwtable
37-
define void @_Z2f2v() #0 !dbg !4 {
73+
define void @_Z2f2v() #0 !dbg !6 {
3874
entry:
39-
call void @_Z2f1v(), !dbg !11
40-
ret void, !dbg !12
75+
call void @_Z2f1v(), !dbg !9
76+
ret void, !dbg !10
4177
}
4278

4379
declare void @_Z2f1v()
4480

4581
; Function Attrs: uwtable
46-
define void @_Z2f3v() #2 !dbg !7 {
82+
define void @_Z2f3v() !dbg !11 {
83+
entry:
84+
call void @_Z2f1v(), !dbg !12
85+
ret void, !dbg !14
86+
}
87+
88+
; Function Attrs: alwaysinline uwtable
89+
define void @_ZN2F42f5Ev() #0 align 2 !dbg !15 {
90+
entry:
91+
call void @_Z2f1v(), !dbg !19
92+
ret void, !dbg !20
93+
}
94+
95+
; Function Attrs: uwtable
96+
define void @_Z2f6v() !dbg !21 {
4797
entry:
48-
call void @_Z2f1v(), !dbg !13
49-
ret void, !dbg !15
98+
call void @_Z2f1v(), !dbg !22
99+
ret void, !dbg !24
50100
}
51101

52-
attributes #0 = { alwaysinline uwtable }
53-
attributes #2 = { uwtable }
102+
attributes #0 = { alwaysinline }
54103

55104
!llvm.dbg.cu = !{!0}
56-
!llvm.module.flags = !{!8, !9}
57-
!llvm.ident = !{!10}
105+
!llvm.module.flags = !{!3, !4}
106+
!llvm.ident = !{!5}
58107

59-
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 265282)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
60-
!1 = !DIFile(filename: "linkage-name-abstract.cpp", directory: "/home/probinson/projects/scratch")
108+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 4.0.0 (trunk 288231)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
109+
!1 = !DIFile(filename: "linkage-name-abstract-static.cpp", directory: "/home/probinson/projects/scratch")
61110
!2 = !{}
62-
!4 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
63-
!5 = !DISubroutineType(types: !6)
64-
!6 = !{null}
65-
!7 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
66-
!8 = !{i32 2, !"Dwarf Version", i32 4}
67-
!9 = !{i32 2, !"Debug Info Version", i32 3}
68-
!10 = !{!"clang version 3.9.0 (trunk 265282)"}
69-
!11 = !DILocation(line: 3, column: 3, scope: !4)
70-
!12 = !DILocation(line: 4, column: 1, scope: !4)
71-
!13 = !DILocation(line: 3, column: 3, scope: !4, inlinedAt: !14)
72-
!14 = distinct !DILocation(line: 6, column: 3, scope: !7)
73-
!15 = !DILocation(line: 7, column: 1, scope: !7)
111+
!3 = !{i32 2, !"Dwarf Version", i32 4}
112+
!4 = !{i32 2, !"Debug Info Version", i32 3}
113+
!5 = !{!"clang version 4.0.0 (trunk 288231)"}
114+
!6 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
115+
!7 = !DISubroutineType(types: !8)
116+
!8 = !{null}
117+
!9 = !DILocation(line: 3, column: 3, scope: !6)
118+
!10 = !DILocation(line: 4, column: 1, scope: !6)
119+
!11 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 5, type: !7, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
120+
!12 = !DILocation(line: 3, column: 3, scope: !6, inlinedAt: !13)
121+
!13 = distinct !DILocation(line: 6, column: 3, scope: !11)
122+
!14 = !DILocation(line: 7, column: 1, scope: !11)
123+
!15 = distinct !DISubprogram(name: "f5", linkageName: "_ZN2F42f5Ev", scope: !16, file: !1, line: 12, type: !7, isLocal: false, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !18, variables: !2)
124+
!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "F4", file: !1, line: 9, size: 8, elements: !17, identifier: "_ZTS2F4")
125+
!17 = !{!18}
126+
!18 = !DISubprogram(name: "f5", linkageName: "_ZN2F42f5Ev", scope: !16, file: !1, line: 10, type: !7, isLocal: false, isDefinition: false, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false)
127+
!19 = !DILocation(line: 13, column: 3, scope: !15)
128+
!20 = !DILocation(line: 14, column: 1, scope: !15)
129+
!21 = distinct !DISubprogram(name: "f6", linkageName: "_Z2f6v", scope: !1, file: !1, line: 15, type: !7, isLocal: false, isDefinition: true, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
130+
!22 = !DILocation(line: 13, column: 3, scope: !15, inlinedAt: !23)
131+
!23 = distinct !DILocation(line: 16, column: 3, scope: !21)
132+
!24 = !DILocation(line: 17, column: 1, scope: !21)

0 commit comments

Comments
 (0)
Please sign in to comment.