xref: /llvm-project/llvm/test/DebugInfo/X86/parameters.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1;
2; RUN: llc -mtriple=x86_64-unknown-linux-gnu -O0 -filetype=obj %s -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s
3; RUN: llc --try-experimental-debuginfo-iterators -mtriple=x86_64-unknown-linux-gnu -O0 -filetype=obj %s -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s
4
5; Test case derived from compiling the following source with clang -g:
6;
7; namespace pr14763 {
8; struct foo {
9;   foo(const foo&);
10; };
11;
12; foo func(foo f) {
13;   return f; // reference 'f' for now because otherwise we hit another bug
14; }
15;
16; void sink(ptr);
17;
18; void func2(bool b, foo g) {
19;   if (b)
20;     sink(&g); // reference 'f' for now because otherwise we hit another bug
21; }
22; }
23
24; CHECK: debug_info contents
25; The parameter is accessed indirectly (with a zero offset) from the second
26; register parameter. RDI is consumed by 'sret'.
27; CHECK: DW_TAG_subprogram
28; CHECK: DW_AT_name{{.*}} = "func"
29; CHECK: DW_TAG_formal_parameter
30; CHECK: DW_AT_location {{.*}}
31; CHECK-NEXT: DW_OP_breg4 RSI+0, DW_OP_deref
32; CHECK-NOT: DW_TAG
33; CHECK: DW_AT_name{{.*}} = "f"
34
35; CHECK: DW_TAG_subprogram
36; CHECK: DW_AT_name{{.*}} = "func2"
37; CHECK: DW_TAG_formal_parameter
38; CHECK: DW_AT_location{{.*}}(DW_OP_fbreg +23)
39; CHECK: DW_TAG_formal_parameter
40; CHECK: DW_AT_location{{.*}}(
41; CHECK-NEXT: {{.*}}: DW_OP_breg7 RSP+8, DW_OP_deref, DW_OP_deref
42; CHECK-NEXT: {{.*}}: DW_OP_breg4 RSI+0, DW_OP_deref
43; CHECK-NEXT: {{.*}}: DW_OP_breg7 RSP+8, DW_OP_deref, DW_OP_deref)
44; CHECK-NOT: DW_TAG
45; CHECK: DW_AT_name{{.*}} = "g"
46
47%"struct.pr14763::foo" = type { i8 }
48
49; Function Attrs: uwtable
50define void @_ZN7pr147634funcENS_3fooE(ptr noalias sret(%"struct.pr14763::foo") %agg.result, ptr %f) #0 !dbg !4 {
51entry:
52  call void @llvm.dbg.declare(metadata ptr %f, metadata !22, metadata !DIExpression(DW_OP_deref)), !dbg !24
53  call void @_ZN7pr147633fooC1ERKS0_(ptr %agg.result, ptr %f), !dbg !25
54  ret void, !dbg !25
55}
56
57; Function Attrs: nounwind readnone
58declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
59
60declare void @_ZN7pr147633fooC1ERKS0_(ptr, ptr) #2
61
62; Function Attrs: uwtable
63define void @_ZN7pr147635func2EbNS_3fooE(i1 zeroext %b, ptr %g) #0 !dbg !17 {
64entry:
65  %b.addr = alloca i8, align 1
66  %frombool = zext i1 %b to i8
67  store i8 %frombool, ptr %b.addr, align 1
68  call void @llvm.dbg.declare(metadata ptr %b.addr, metadata !26, metadata !DIExpression()), !dbg !27
69  call void @llvm.dbg.declare(metadata ptr %g, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !27
70  %0 = load i8, ptr %b.addr, align 1, !dbg !29
71  %tobool = trunc i8 %0 to i1, !dbg !29
72  br i1 %tobool, label %if.then, label %if.end, !dbg !29
73
74if.then:                                          ; preds = %entry
75  call void @_ZN7pr147634sinkEPv(ptr %g), !dbg !31
76  br label %if.end, !dbg !31
77
78if.end:                                           ; preds = %if.then, %entry
79  ret void, !dbg !32
80}
81
82declare void @_ZN7pr147634sinkEPv(ptr)
83
84attributes #0 = { uwtable }
85attributes #1 = { nounwind readnone }
86
87!llvm.dbg.cu = !{!0}
88!llvm.module.flags = !{!21, !33}
89
90!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
91!1 = !DIFile(filename: "pass.cpp", directory: "/tmp")
92!2 = !{}
93!4 = distinct !DISubprogram(name: "func", linkageName: "_ZN7pr147634funcENS_3fooE", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !1, scope: !5, type: !6, retainedNodes: !2)
94!5 = !DINamespace(name: "pr14763", scope: null)
95!6 = !DISubroutineType(types: !7)
96!7 = !{!8, !8}
97!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 2, size: 8, align: 8, file: !1, scope: !5, elements: !9)
98!9 = !{!10}
99!10 = !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !8, type: !11)
100!11 = !DISubroutineType(types: !12)
101!12 = !{null, !13, !14}
102!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !8)
103!14 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !15)
104!15 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
105!17 = distinct !DISubprogram(name: "func2", linkageName: "_ZN7pr147635func2EbNS_3fooE", line: 12, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 12, file: !1, scope: !5, type: !18, retainedNodes: !2)
106!18 = !DISubroutineType(types: !19)
107!19 = !{null, !20, !8}
108!20 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
109!21 = !{i32 2, !"Dwarf Version", i32 3}
110!22 = !DILocalVariable(name: "f", line: 6, arg: 1, scope: !4, file: !23, type: !8)
111!23 = !DIFile(filename: "pass.cpp", directory: "/tmp")
112!24 = !DILocation(line: 6, scope: !4)
113!25 = !DILocation(line: 7, scope: !4)
114!26 = !DILocalVariable(name: "b", line: 12, arg: 1, scope: !17, file: !23, type: !20)
115!27 = !DILocation(line: 12, scope: !17)
116!28 = !DILocalVariable(name: "g", line: 12, arg: 2, scope: !17, file: !23, type: !8)
117!29 = !DILocation(line: 13, scope: !30)
118!30 = distinct !DILexicalBlock(line: 13, column: 0, file: !1, scope: !17)
119!31 = !DILocation(line: 14, scope: !30)
120!32 = !DILocation(line: 15, scope: !17)
121!33 = !{i32 1, !"Debug Info Version", i32 3}
122