xref: /aosp_15_r20/external/llvm/test/DebugInfo/Generic/varargs.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: %llc_dwarf -O0 -filetype=obj -o %t.o %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker; REQUIRES: object-emission
4*9880d681SAndroid Build Coastguard Worker;
5*9880d681SAndroid Build Coastguard Worker; Test debug info for variadic function arguments.
6*9880d681SAndroid Build Coastguard Worker; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
7*9880d681SAndroid Build Coastguard Worker;
8*9880d681SAndroid Build Coastguard Worker; The ... parameter of variadic should be emitted as
9*9880d681SAndroid Build Coastguard Worker; DW_TAG_unspecified_parameters.
10*9880d681SAndroid Build Coastguard Worker;
11*9880d681SAndroid Build Coastguard Worker; Normal variadic function.
12*9880d681SAndroid Build Coastguard Worker; void b(int c, ...);
13*9880d681SAndroid Build Coastguard Worker;
14*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
15*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
16*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name {{.*}} "a"
17*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
18*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_formal_parameter
19*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
20*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_formal_parameter
21*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
22*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_unspecified_parameters
23*9880d681SAndroid Build Coastguard Worker;
24*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
25*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
26*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name {{.*}} "b"
27*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
28*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_formal_parameter
29*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
30*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_variable
31*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
32*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_variable
33*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
34*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_unspecified_parameters
35*9880d681SAndroid Build Coastguard Worker;
36*9880d681SAndroid Build Coastguard Worker; Variadic C++ member function.
37*9880d681SAndroid Build Coastguard Worker; struct A { void a(int c, ...); }
38*9880d681SAndroid Build Coastguard Worker;
39*9880d681SAndroid Build Coastguard Worker; Variadic function pointer.
40*9880d681SAndroid Build Coastguard Worker; void (*fptr)(int, ...);
41*9880d681SAndroid Build Coastguard Worker;
42*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subroutine_type
43*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
44*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_formal_parameter
45*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
46*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_unspecified_parameters
47*9880d681SAndroid Build Coastguard Worker;
48*9880d681SAndroid Build Coastguard Worker; ModuleID = 'llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp'
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Worker%struct.A = type { i8 }
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind ssp uwtable
53*9880d681SAndroid Build Coastguard Workerdefine void @_Z1biz(i32 %c, ...) #0 !dbg !14 {
54*9880d681SAndroid Build Coastguard Worker  %1 = alloca i32, align 4
55*9880d681SAndroid Build Coastguard Worker  %a = alloca %struct.A, align 1
56*9880d681SAndroid Build Coastguard Worker  %fptr = alloca void (i32, ...)*, align 8
57*9880d681SAndroid Build Coastguard Worker  store i32 %c, i32* %1, align 4
58*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %1, metadata !21, metadata !DIExpression()), !dbg !22
59*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !23, metadata !DIExpression()), !dbg !24
60*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata void (i32, ...)** %fptr, metadata !25, metadata !DIExpression(DW_OP_deref)), !dbg !27
61*9880d681SAndroid Build Coastguard Worker  store void (i32, ...)* @_Z1biz, void (i32, ...)** %fptr, align 8, !dbg !27
62*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !28
63*9880d681SAndroid Build Coastguard Worker}
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
66*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind ssp uwtable }
69*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
72*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!18, !19}
73*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!20}
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Worker!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)
76*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", directory: "radar/13690847")
77*9880d681SAndroid Build Coastguard Worker!2 = !{}
78*9880d681SAndroid Build Coastguard Worker!3 = !{!4}
79*9880d681SAndroid Build Coastguard Worker!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 3, size: 8, align: 8, file: !1, elements: !5, identifier: "_ZTS1A")
80*9880d681SAndroid Build Coastguard Worker!5 = !{!6}
81*9880d681SAndroid Build Coastguard Worker!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)
82*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8)
83*9880d681SAndroid Build Coastguard Worker!8 = !{null, !9, !10, null}
84*9880d681SAndroid Build Coastguard Worker!9 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
85*9880d681SAndroid Build Coastguard Worker!10 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
86*9880d681SAndroid Build Coastguard Worker!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)
87*9880d681SAndroid Build Coastguard Worker!15 = !DIFile(filename: "llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", directory: "radar/13690847")
88*9880d681SAndroid Build Coastguard Worker!16 = !DISubroutineType(types: !17)
89*9880d681SAndroid Build Coastguard Worker!17 = !{null, !10, null}
90*9880d681SAndroid Build Coastguard Worker!18 = !{i32 2, !"Dwarf Version", i32 2}
91*9880d681SAndroid Build Coastguard Worker!19 = !{i32 1, !"Debug Info Version", i32 3}
92*9880d681SAndroid Build Coastguard Worker!20 = !{!"clang version 3.5 "}
93*9880d681SAndroid Build Coastguard Worker!21 = !DILocalVariable(name: "c", line: 13, arg: 1, scope: !14, file: !15, type: !10)
94*9880d681SAndroid Build Coastguard Worker!22 = !DILocation(line: 13, scope: !14)
95*9880d681SAndroid Build Coastguard Worker!23 = !DILocalVariable(name: "a", line: 16, scope: !14, file: !15, type: !4)
96*9880d681SAndroid Build Coastguard Worker!24 = !DILocation(line: 16, scope: !14)
97*9880d681SAndroid Build Coastguard Worker; Manually modifed to avoid dependence on pointer size
98*9880d681SAndroid Build Coastguard Worker!25 = !DILocalVariable(name: "fptr", line: 18, scope: !14, file: !15, type: !16)
99*9880d681SAndroid Build Coastguard Worker!26 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16)
100*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 18, scope: !14)
101*9880d681SAndroid Build Coastguard Worker!28 = !DILocation(line: 22, scope: !14)
102