blob: 709d78dd5978fe8318e8e5ed1f609efda5f82e48 [file] [log] [blame]
Adrian Prantl6aa76162014-02-25 23:03:00 +00001; RUN: %llc_dwarf -O0 -filetype=obj -o %t.o %s
Adrian Prantl3f49c892014-02-25 19:57:42 +00002; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
Adrian Prantl69140d22014-02-25 22:27:14 +00003; REQUIRES: object-emission
4;
5; Test debug info for variadic function arguments.
6; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
7;
8; The ... parameter of variadic should be emitted as
9; DW_TAG_unspecified_parameters.
Adrian Prantl3f49c892014-02-25 19:57:42 +000010;
11; Normal variadic function.
Adrian Prantl69140d22014-02-25 22:27:14 +000012; void b(int c, ...);
Adrian Prantl3f49c892014-02-25 19:57:42 +000013;
14; CHECK: DW_TAG_subprogram
15; CHECK-NOT: DW_TAG
David Blaikie3c2fff32014-05-27 18:37:48 +000016; CHECK: DW_AT_name {{.*}} "a"
17; CHECK-NOT: DW_TAG
18; CHECK: DW_TAG_formal_parameter
19; CHECK-NOT: DW_TAG
20; CHECK: DW_TAG_formal_parameter
21; CHECK-NOT: DW_TAG
22; CHECK: DW_TAG_unspecified_parameters
23;
24; CHECK: DW_TAG_subprogram
25; CHECK-NOT: DW_TAG
Adrian Prantl69140d22014-02-25 22:27:14 +000026; CHECK: DW_AT_name {{.*}} "b"
27; CHECK-NOT: DW_TAG
Adrian Prantl3f49c892014-02-25 19:57:42 +000028; CHECK: DW_TAG_formal_parameter
29; CHECK-NOT: DW_TAG
David Blaikie1dd573d2014-10-23 22:27:50 +000030; CHECK: DW_TAG_variable
31; CHECK-NOT: DW_TAG
32; CHECK: DW_TAG_variable
33; CHECK-NOT: DW_TAG
Adrian Prantl3f49c892014-02-25 19:57:42 +000034; CHECK: DW_TAG_unspecified_parameters
35;
36; Variadic C++ member function.
Adrian Prantl69140d22014-02-25 22:27:14 +000037; struct A { void a(int c, ...); }
Adrian Prantl3f49c892014-02-25 19:57:42 +000038;
Adrian Prantl3f49c892014-02-25 19:57:42 +000039; Variadic function pointer.
Adrian Prantl69140d22014-02-25 22:27:14 +000040; void (*fptr)(int, ...);
Adrian Prantl3f49c892014-02-25 19:57:42 +000041;
42; CHECK: DW_TAG_subroutine_type
43; CHECK-NOT: DW_TAG
44; CHECK: DW_TAG_formal_parameter
45; CHECK-NOT: DW_TAG
46; CHECK: DW_TAG_unspecified_parameters
47;
Adrian Prantl3f49c892014-02-25 19:57:42 +000048; ModuleID = 'llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp'
Adrian Prantl3f49c892014-02-25 19:57:42 +000049
50%struct.A = type { i8 }
51
52; Function Attrs: nounwind ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000053define void @_Z1biz(i32 %c, ...) #0 !dbg !14 {
Adrian Prantl3f49c892014-02-25 19:57:42 +000054 %1 = alloca i32, align 4
55 %a = alloca %struct.A, align 1
56 %fptr = alloca void (i32, ...)*, align 8
57 store i32 %c, i32* %1, align 4
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000058 call void @llvm.dbg.declare(metadata i32* %1, metadata !21, metadata !DIExpression()), !dbg !22
59 call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !23, metadata !DIExpression()), !dbg !24
Keno Fischer81e2e9e2016-01-15 00:46:17 +000060 call void @llvm.dbg.declare(metadata void (i32, ...)** %fptr, metadata !25, metadata !DIExpression(DW_OP_deref)), !dbg !27
Adrian Prantl3f49c892014-02-25 19:57:42 +000061 store void (i32, ...)* @_Z1biz, void (i32, ...)** %fptr, align 8, !dbg !27
62 ret void, !dbg !28
63}
64
65; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000066declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Adrian Prantl3f49c892014-02-25 19:57:42 +000067
68attributes #0 = { nounwind ssp uwtable }
69attributes #1 = { nounwind readnone }
70
71!llvm.dbg.cu = !{!0}
72!llvm.module.flags = !{!18, !19}
73!llvm.ident = !{!20}
74
Adrian Prantl75819ae2016-04-15 15:57:41 +000075!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000076!1 = !DIFile(filename: "llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", directory: "radar/13690847")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000077!2 = !{}
78!3 = !{!4}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000079!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 3, size: 8, align: 8, file: !1, elements: !5, identifier: "_ZTS1A")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000080!5 = !{!6}
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +000081!6 = !DISubprogram(name: "a", linkageName: "_ZN1A1aEiz", line: 6, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 6, file: !1, scope: !4, type: !7)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000082!7 = !DISubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000083!8 = !{null, !9, !10, null}
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +000084!9 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000085!10 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Adrian Prantl75819ae2016-04-15 15:57:41 +000086!14 = distinct !DISubprogram(name: "b", linkageName: "_Z1biz", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 13, file: !1, scope: !15, type: !16, variables: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000087!15 = !DIFile(filename: "llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", directory: "radar/13690847")
88!16 = !DISubroutineType(types: !17)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000089!17 = !{null, !10, null}
90!18 = !{i32 2, !"Dwarf Version", i32 2}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000091!19 = !{i32 1, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000092!20 = !{!"clang version 3.5 "}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000093!21 = !DILocalVariable(name: "c", line: 13, arg: 1, scope: !14, file: !15, type: !10)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000094!22 = !DILocation(line: 13, scope: !14)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000095!23 = !DILocalVariable(name: "a", line: 16, scope: !14, file: !15, type: !4)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000096!24 = !DILocation(line: 16, scope: !14)
Keno Fischer81e2e9e2016-01-15 00:46:17 +000097; Manually modifed to avoid dependence on pointer size
98!25 = !DILocalVariable(name: "fptr", line: 18, scope: !14, file: !15, type: !16)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000099!26 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16)
100!27 = !DILocation(line: 18, scope: !14)
101!28 = !DILocation(line: 22, scope: !14)