llvm.org GIT mirror llvm / 35989a7
Address review comments for r202188. This is refactoring / simplifying code, updating comments and enabling the testcase on non-x86 platforms. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202199 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 6 years ago
5 changed file(s) with 115 addition(s) and 122 deletion(s). Raw diff Collapse all Expand all
402402 DIArray Args = SPTy.getTypeArray();
403403 uint16_t SPTag = SPTy.getTag();
404404 if (SPTag == dwarf::DW_TAG_subroutine_type)
405 // FIXME: Use DwarfUnit::constructSubprogramArguments() here.
406 for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
407 DIType ATy(Args.getElement(i));
408 if (ATy.isUnspecifiedParameter()) {
409 assert(i == N-1 && "ellipsis must be the last argument");
410 SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie);
411 } else {
412 DIE *Arg =
413 SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
414 SPCU->addType(Arg, ATy);
415 if (ATy.isArtificial())
416 SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
417 if (ATy.isObjectPointer())
418 SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
419 }
420 }
405 SPCU->constructSubprogramArguments(*SPDie, Args);
421406 DIE *SPDeclDie = SPDie;
422407 SPDie = SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram,
423408 *SPCU->getUnitDie());
597582 ObjectPointer = Arg;
598583 }
599584
600 // Create the unspecified parameter that marks a function as variadic.
585 // If this is a variadic function, add an unspecified parameter.
601586 DISubprogram SP(Scope->getScopeNode());
602 assert(SP.Verify());
603587 DIArray FnArgs = SP.getType().getTypeArray();
604588 if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) {
605589 DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
11401140
11411141 /// constructSubprogramArguments - Construct function argument DIEs.
11421142 void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
1143 for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
1144 DIDescriptor Ty = Args.getElement(i);
1145 if (Ty.isUnspecifiedParameter()) {
1146 assert(i == N-1 && "ellipsis must be the last argument");
1147 createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
1148 } else {
1149 DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
1150 addType(Arg, DIType(Ty));
1151 if (DIType(Ty).isArtificial())
1152 addFlag(Arg, dwarf::DW_AT_artificial);
1153 }
1143 for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
1144 DIDescriptor Ty = Args.getElement(i);
1145 if (Ty.isUnspecifiedParameter()) {
1146 assert(i == N-1 && "Unspecified parameter must be the last argument");
1147 createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
1148 } else {
1149 DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
1150 addType(Arg, DIType(Ty));
1151 if (DIType(Ty).isArtificial())
1152 addFlag(Arg, dwarf::DW_AT_artificial);
11541153 }
1154 }
11551155 }
11561156
11571157 /// constructTypeDIE - Construct type DIE from DICompositeType.
451451 /// constructVariableDIE - Construct a DIE for the given DbgVariable.
452452 DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
453453
454 /// constructSubprogramArguments - Construct function argument DIEs.
455 void constructSubprogramArguments(DIE &Buffer, DIArray Args);
456
454457 /// Create a DIE with the given Tag, add the DIE to its parent, and
455458 /// call insertDIE if MD is not null.
456459 DIE *createAndAddDIE(unsigned Tag, DIE &Parent,
475478 DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
476479
477480 private:
478 /// constructSubprogramArguments - Construct function argument DIEs.
479 void constructSubprogramArguments(DIE &Buffer, DIArray Args);
480
481481 /// constructTypeDIE - Construct basic type die from DIBasicType.
482482 void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
483483
+0
-90
test/DebugInfo/X86/varargs.ll less more
None ; RUN: llc -O0 -filetype=obj -o %t.o %s
1 ; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
2 ;
3 ; Normal variadic function.
4 ;
5 ; CHECK: DW_TAG_subprogram
6 ; CHECK-NOT: DW_TAG
7 ; CHECK: DW_TAG_formal_parameter
8 ; CHECK-NOT: DW_TAG
9 ; CHECK: DW_TAG_unspecified_parameters
10 ;
11 ; Variadic C++ member function.
12 ;
13 ; CHECK: DW_TAG_subprogram
14 ; CHECK-NOT: DW_TAG
15 ; CHECK: DW_TAG_formal_parameter
16 ; CHECK-NOT: DW_TAG
17 ; CHECK: DW_TAG_formal_parameter
18 ; CHECK-NOT: DW_TAG
19 ; CHECK: DW_TAG_unspecified_parameters
20 ;
21 ; Variadic function pointer.
22 ;
23 ; CHECK: DW_TAG_subroutine_type
24 ; CHECK-NOT: DW_TAG
25 ; CHECK: DW_TAG_formal_parameter
26 ; CHECK-NOT: DW_TAG
27 ; CHECK: DW_TAG_unspecified_parameters
28 ;
29 ; Test debug info for variadic function arguments.
30 ; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
31 ;
32 ; ModuleID = 'llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp'
33 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
34 target triple = "x86_64-apple-macosx10.9.0"
35
36 %struct.A = type { i8 }
37
38 ; Function Attrs: nounwind ssp uwtable
39 define void @_Z1biz(i32 %c, ...) #0 {
40 %1 = alloca i32, align 4
41 %a = alloca %struct.A, align 1
42 %fptr = alloca void (i32, ...)*, align 8
43 store i32 %c, i32* %1, align 4
44 call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !21), !dbg !22
45 call void @llvm.dbg.declare(metadata !{%struct.A* %a}, metadata !23), !dbg !24
46 call void @llvm.dbg.declare(metadata !{void (i32, ...)** %fptr}, metadata !25), !dbg !27
47 store void (i32, ...)* @_Z1biz, void (i32, ...)** %fptr, align 8, !dbg !27
48 ret void, !dbg !28
49 }
50
51 ; Function Attrs: nounwind readnone
52 declare void @llvm.dbg.declare(metadata, metadata) #1
53
54 attributes #0 = { nounwind ssp uwtable }
55 attributes #1 = { nounwind readnone }
56
57 !llvm.dbg.cu = !{!0}
58 !llvm.module.flags = !{!18, !19}
59 !llvm.ident = !{!20}
60
61 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5 ", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !13, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp] [DW_LANG_C_plus_plus]
62 !1 = metadata !{metadata !"llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", metadata !"radar/13690847"}
63 !2 = metadata !{}
64 !3 = metadata !{metadata !4}
65 !4 = metadata !{i32 786451, metadata !1, null, metadata !"A", i32 3, i64 8, i64 8, i32 0, i32 0, null, metadata !5, i32 0, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 3, size 8, align 8, offset 0] [def] [from ]
66 !5 = metadata !{metadata !6}
67 !6 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"a", metadata !"a", metadata !"_ZN1A1aEiz", i32 6, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !12, i32 6} ; [ DW_TAG_subprogram ] [line 6] [a]
68 !7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
69 !8 = metadata !{null, metadata !9, metadata !10, metadata !11}
70 !9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
71 !10 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
72 !11 = metadata !{i32 786456}
73 !12 = metadata !{i32 786468}
74 !13 = metadata !{metadata !14}
75 !14 = metadata !{i32 786478, metadata !1, metadata !15, metadata !"b", metadata !"b", metadata !"_Z1biz", i32 13, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32, ...)* @_Z1biz, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [b]
76 !15 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp]
77 !16 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !17, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
78 !17 = metadata !{null, metadata !10, metadata !11}
79 !18 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
80 !19 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
81 !20 = metadata !{metadata !"clang version 3.5 "}
82 !21 = metadata !{i32 786689, metadata !14, metadata !"c", metadata !15, i32 16777229, metadata !10, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [c] [line 13]
83 !22 = metadata !{i32 13, i32 0, metadata !14, null}
84 !23 = metadata !{i32 786688, metadata !14, metadata !"a", metadata !15, i32 16, metadata !4, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 16]
85 !24 = metadata !{i32 16, i32 0, metadata !14, null}
86 !25 = metadata !{i32 786688, metadata !14, metadata !"fptr", metadata !15, i32 18, metadata !26, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [fptr] [line 18]
87 !26 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !16} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
88 !27 = metadata !{i32 18, i32 0, metadata !14, null}
89 !28 = metadata !{i32 22, i32 0, metadata !14, null}
0 ; RUN: llc -O0 -filetype=obj -o %t.o %s
1 ; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
2 ; REQUIRES: object-emission
3 ;
4 ; Test debug info for variadic function arguments.
5 ; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
6 ;
7 ; The ... parameter of variadic should be emitted as
8 ; DW_TAG_unspecified_parameters.
9 ;
10 ; Normal variadic function.
11 ; void b(int c, ...);
12 ;
13 ; CHECK: DW_TAG_subprogram
14 ; CHECK-NOT: DW_TAG
15 ; CHECK: DW_AT_name {{.*}} "b"
16 ; CHECK-NOT: DW_TAG
17 ; CHECK: DW_TAG_formal_parameter
18 ; CHECK-NOT: DW_TAG
19 ; CHECK: DW_TAG_unspecified_parameters
20 ;
21 ; Variadic C++ member function.
22 ; struct A { void a(int c, ...); }
23 ;
24 ; CHECK: DW_TAG_subprogram
25 ; CHECK-NOT: DW_TAG
26 ; CHECK: DW_AT_name {{.*}} "a"
27 ; CHECK-NOT: DW_TAG
28 ; CHECK: DW_TAG_formal_parameter
29 ; CHECK-NOT: DW_TAG
30 ; CHECK: DW_TAG_formal_parameter
31 ; CHECK-NOT: DW_TAG
32 ; CHECK: DW_TAG_unspecified_parameters
33 ;
34 ; Variadic function pointer.
35 ; void (*fptr)(int, ...);
36 ;
37 ; CHECK: DW_TAG_subroutine_type
38 ; CHECK-NOT: DW_TAG
39 ; CHECK: DW_TAG_formal_parameter
40 ; CHECK-NOT: DW_TAG
41 ; CHECK: DW_TAG_unspecified_parameters
42 ;
43 ; ModuleID = 'llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp'
44
45 %struct.A = type { i8 }
46
47 ; Function Attrs: nounwind ssp uwtable
48 define void @_Z1biz(i32 %c, ...) #0 {
49 %1 = alloca i32, align 4
50 %a = alloca %struct.A, align 1
51 %fptr = alloca void (i32, ...)*, align 8
52 store i32 %c, i32* %1, align 4
53 call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !21), !dbg !22
54 call void @llvm.dbg.declare(metadata !{%struct.A* %a}, metadata !23), !dbg !24
55 call void @llvm.dbg.declare(metadata !{void (i32, ...)** %fptr}, metadata !25), !dbg !27
56 store void (i32, ...)* @_Z1biz, void (i32, ...)** %fptr, align 8, !dbg !27
57 ret void, !dbg !28
58 }
59
60 ; Function Attrs: nounwind readnone
61 declare void @llvm.dbg.declare(metadata, metadata) #1
62
63 attributes #0 = { nounwind ssp uwtable }
64 attributes #1 = { nounwind readnone }
65
66 !llvm.dbg.cu = !{!0}
67 !llvm.module.flags = !{!18, !19}
68 !llvm.ident = !{!20}
69
70 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5 ", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !13, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp] [DW_LANG_C_plus_plus]
71 !1 = metadata !{metadata !"llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", metadata !"radar/13690847"}
72 !2 = metadata !{}
73 !3 = metadata !{metadata !4}
74 !4 = metadata !{i32 786451, metadata !1, null, metadata !"A", i32 3, i64 8, i64 8, i32 0, i32 0, null, metadata !5, i32 0, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 3, size 8, align 8, offset 0] [def] [from ]
75 !5 = metadata !{metadata !6}
76 !6 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1A", metadata !"a", metadata !"a", metadata !"_ZN1A1aEiz", i32 6, metadata !7, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !12, i32 6} ; [ DW_TAG_subprogram ] [line 6] [a]
77 !7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
78 !8 = metadata !{null, metadata !9, metadata !10, metadata !11}
79 !9 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
80 !10 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
81 !11 = metadata !{i32 786456}
82 !12 = metadata !{i32 786468}
83 !13 = metadata !{metadata !14}
84 !14 = metadata !{i32 786478, metadata !1, metadata !15, metadata !"b", metadata !"b", metadata !"_Z1biz", i32 13, metadata !16, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32, ...)* @_Z1biz, null, null, metadata !2, i32 13} ; [ DW_TAG_subprogram ] [line 13] [def] [b]
85 !15 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp]
86 !16 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !17, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
87 !17 = metadata !{null, metadata !10, metadata !11}
88 !18 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
89 !19 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
90 !20 = metadata !{metadata !"clang version 3.5 "}
91 !21 = metadata !{i32 786689, metadata !14, metadata !"c", metadata !15, i32 16777229, metadata !10, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [c] [line 13]
92 !22 = metadata !{i32 13, i32 0, metadata !14, null}
93 !23 = metadata !{i32 786688, metadata !14, metadata !"a", metadata !15, i32 16, metadata !4, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 16]
94 !24 = metadata !{i32 16, i32 0, metadata !14, null}
95 !25 = metadata !{i32 786688, metadata !14, metadata !"fptr", metadata !15, i32 18, metadata !26, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [fptr] [line 18]
96 !26 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !16} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
97 !27 = metadata !{i32 18, i32 0, metadata !14, null}
98 !28 = metadata !{i32 22, i32 0, metadata !14, null}