llvm.org GIT mirror llvm / 4c97b94
DebugInfo: Add ability to not emit DW_AT_vtable_elem_location for virtual functions. A virtual index of -1u indicates that the subprogram's virtual index is unrepresentable (for example, when using the relative vtable ABI), so do not emit a DW_AT_vtable_elem_location attribute for it. Differential Revision: http://reviews.llvm.org/D18236 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263765 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 4 years ago
6 changed file(s) with 105 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
557557 /// \param isDefinition True if this is a function definition.
558558 /// \param Virtuality Attributes describing virtualness. e.g. pure
559559 /// virtual function.
560 /// \param VTableIndex Index no of this method in virtual table.
560 /// \param VTableIndex Index no of this method in virtual table, or -1u if
561 /// unrepresentable.
561562 /// \param VTableHolder Type that holds vtable.
562563 /// \param Flags e.g. is this function prototyped or not.
563564 /// This flags are used to emit dwarf attributes.
33523352 return TokError("expected DWARF virtuality code");
33533353
33543354 unsigned Virtuality = dwarf::getVirtuality(Lex.getStrVal());
3355 if (!Virtuality)
3355 if (Virtuality == dwarf::DW_VIRTUALITY_invalid)
33563356 return TokError("invalid DWARF virtuality code" + Twine(" '") +
33573357 Lex.getStrVal() + "'");
33583358 assert(Virtuality <= Result.Max && "Expected valid DWARF virtuality code");
12171217 unsigned VK = SP->getVirtuality();
12181218 if (VK) {
12191219 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1220 DIELoc *Block = getDIELoc();
1221 addUInt(*Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1222 addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1223 addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
1220 if (SP->getVirtualIndex() != -1u) {
1221 DIELoc *Block = getDIELoc();
1222 addUInt(*Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1223 addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1224 addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
1225 }
12241226 ContainingTypeMap.insert(
12251227 std::make_pair(&SPDie, resolve(SP->getContainingType())));
12261228 }
16681668 Printer.printMetadata("containingType", N->getRawContainingType());
16691669 Printer.printDwarfEnum("virtuality", N->getVirtuality(),
16701670 dwarf::VirtualityString);
1671 Printer.printInt("virtualIndex", N->getVirtualIndex());
1671 if (N->getVirtuality() != dwarf::DW_VIRTUALITY_none ||
1672 N->getVirtualIndex() != 0)
1673 Printer.printInt("virtualIndex", N->getVirtualIndex(), false);
16721674 Printer.printDIFlags("flags", N->getFlags());
16731675 Printer.printBool("isOptimized", N->isOptimized());
16741676 Printer.printMetadata("templateParams", N->getRawTemplateParams());
55 ret void
66 }
77
8 ; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
9 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
8 ; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11}
9 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11}
1010
1111 !0 = !{null}
1212 !1 = distinct !DICompositeType(tag: DW_TAG_structure_type)
3030 flags: DIFlagPrototyped, isOptimized: true,
3131 templateParams: !5, declaration: !8, variables: !6)
3232
33 !10 = !{i32 1, !"Debug Info Version", i32 3}
34 !llvm.module.flags = !{!10}
33 ; CHECK: !10 = distinct !DISubprogram
34 ; CHECK-SAME: virtualIndex: 0,
35 !10 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
36 file: !2, line: 7, type: !3, isLocal: true,
37 isDefinition: true, scopeLine: 8, containingType: !4,
38 virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 0,
39 flags: DIFlagPrototyped, isOptimized: true,
40 templateParams: !5, declaration: !8, variables: !6)
41
42 ; CHECK: !11 = distinct !DISubprogram
43 ; CHECK-NOT: virtualIndex
44 !11 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
45 file: !2, line: 7, type: !3, isLocal: true,
46 isDefinition: true, scopeLine: 8, containingType: !4,
47 virtuality: DW_VIRTUALITY_none,
48 flags: DIFlagPrototyped, isOptimized: true,
49 templateParams: !5, declaration: !8, variables: !6)
50
51 !12 = !{i32 1, !"Debug Info Version", i32 3}
52 !llvm.module.flags = !{!12}
0 ; REQUIRES: object-emission
1
2 ; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
3 ; RUN: llvm-dwarfdump %t | FileCheck %s
4
5 ; Generated from the following C++ source code:
6 ;
7 ; struct A {
8 ; virtual void f();
9 ; virtual void g();
10 ; };
11 ;
12 ; void A::f() {}
13 ; void A::g() {}
14 ;
15 ; and manually edited to set virtualIndex attribute on the A::g subprogram to
16 ; 4294967295.
17
18 ; CHECK: DW_TAG_subprogram [
19 ; CHECK: DW_AT_vtable_elem_location [DW_FORM_exprloc] (<0x2> 10 00 )
20
21 ; CHECK: DW_TAG_subprogram [
22 ; CHECK-NOT: DW_AT_vtable_elem_location
23
24 %struct.A = type { i32 (...)** }
25
26 @_ZTV1A = unnamed_addr constant [4 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.A*)* @_ZN1A1fEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1gEv to i8*)], align 8
27
28 define void @_ZN1A1fEv(%struct.A* %this) unnamed_addr !dbg !18 {
29 ret void
30 }
31
32 define void @_ZN1A1gEv(%struct.A* %this) unnamed_addr !dbg !19 {
33 ret void
34 }
35
36 !llvm.dbg.cu = !{!0}
37 !llvm.module.flags = !{!20, !21}
38 !llvm.ident = !{!22}
39
40 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !17)
41 !1 = !DIFile(filename: "x", directory: "x")
42 !2 = !{}
43 !3 = !{!4}
44 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 1, size: 64, align: 64, elements: !5, vtableHolder: !"_ZTS1A", identifier: "_ZTS1A")
45 !5 = !{!6, !12, !16}
46 !6 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$A", scope: !1, file: !1, baseType: !7, size: 64, flags: DIFlagArtificial)
47 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
48 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: !9, size: 64)
49 !9 = !DISubroutineType(types: !10)
50 !10 = !{!11}
51 !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
52 !12 = !DISubprogram(name: "f", linkageName: "_ZN1A1fEv", scope: !"_ZTS1A", file: !1, line: 2, type: !13, isLocal: false, isDefinition: false, scopeLine: 2, containingType: !"_ZTS1A", virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, flags: DIFlagPrototyped, isOptimized: false)
53 !13 = !DISubroutineType(types: !14)
54 !14 = !{null, !15}
55 !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !"_ZTS1A", size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
56 !16 = !DISubprogram(name: "g", linkageName: "_ZN1A1gEv", scope: !"_ZTS1A", file: !1, line: 3, type: !13, isLocal: false, isDefinition: false, scopeLine: 3, containingType: !"_ZTS1A", virtuality: DW_VIRTUALITY_virtual, virtualIndex: 4294967295, flags: DIFlagPrototyped, isOptimized: false)
57 !17 = !{!18, !19}
58 !18 = distinct !DISubprogram(name: "f", linkageName: "_ZN1A1fEv", scope: !"_ZTS1A", file: !1, line: 6, type: !13, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, declaration: !12, variables: !2)
59 !19 = distinct !DISubprogram(name: "g", linkageName: "_ZN1A1gEv", scope: !"_ZTS1A", file: !1, line: 7, type: !13, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, declaration: !16, variables: !2)
60 !20 = !{i32 2, !"Dwarf Version", i32 4}
61 !21 = !{i32 2, !"Debug Info Version", i32 3}
62 !22 = !{!"clang version 3.9.0 (trunk 263469) (llvm/trunk 263156)"}
63 !23 = !DILocalVariable(name: "this", arg: 1, scope: !18, type: !24, flags: DIFlagArtificial | DIFlagObjectPointer)
64 !24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !"_ZTS1A", size: 64, align: 64)
65 !25 = !DIExpression()
66 !26 = !DILocation(line: 0, scope: !18)
67 !27 = !DILocation(line: 6, column: 14, scope: !18)
68 !28 = !DILocalVariable(name: "this", arg: 1, scope: !19, type: !24, flags: DIFlagArtificial | DIFlagObjectPointer)
69 !29 = !DILocation(line: 0, scope: !19)
70 !30 = !DILocation(line: 7, column: 14, scope: !19)