xref: /aosp_15_r20/external/llvm/test/DebugInfo/X86/parameters.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; REQUIRES: object-emission
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=x86_64-unknown-linux-gnu -O0 -filetype=obj < %s > %t
4*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dwarfdump %t | FileCheck %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Test case derived from compiling the following source with clang -g:
7*9880d681SAndroid Build Coastguard Worker;
8*9880d681SAndroid Build Coastguard Worker; namespace pr14763 {
9*9880d681SAndroid Build Coastguard Worker; struct foo {
10*9880d681SAndroid Build Coastguard Worker;   foo(const foo&);
11*9880d681SAndroid Build Coastguard Worker; };
12*9880d681SAndroid Build Coastguard Worker;
13*9880d681SAndroid Build Coastguard Worker; foo func(foo f) {
14*9880d681SAndroid Build Coastguard Worker;   return f; // reference 'f' for now because otherwise we hit another bug
15*9880d681SAndroid Build Coastguard Worker; }
16*9880d681SAndroid Build Coastguard Worker;
17*9880d681SAndroid Build Coastguard Worker; void sink(void*);
18*9880d681SAndroid Build Coastguard Worker;
19*9880d681SAndroid Build Coastguard Worker; void func2(bool b, foo g) {
20*9880d681SAndroid Build Coastguard Worker;   if (b)
21*9880d681SAndroid Build Coastguard Worker;     sink(&g); // reference 'f' for now because otherwise we hit another bug
22*9880d681SAndroid Build Coastguard Worker; }
23*9880d681SAndroid Build Coastguard Worker; }
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; CHECK: debug_info contents
26*9880d681SAndroid Build Coastguard Worker; 0x74 is DW_OP_breg4, showing that the parameter is accessed indirectly
27*9880d681SAndroid Build Coastguard Worker; (with a zero offset) from the register parameter
28*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_location [DW_FORM_data4]	([[F_LOC:0x[0-9]*]])
29*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
30*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name{{.*}} = "f"
31*9880d681SAndroid Build Coastguard Worker;
32*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_location{{.*}}([[G_LOC:0x[0-9]*]])
33*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG
34*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name{{.*}} = "g"
35*9880d681SAndroid Build Coastguard Worker;
36*9880d681SAndroid Build Coastguard Worker; CHECK: debug_loc contents
37*9880d681SAndroid Build Coastguard Worker; CHECK:         [[F_LOC]]: Beginning
38*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:               Ending
39*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: Location description: 74 00
40*9880d681SAndroid Build Coastguard Worker; CHECK:         [[G_LOC]]: Beginning
41*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:               Ending
42*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: Location description: 74 00
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker%"struct.pr14763::foo" = type { i8 }
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker; Function Attrs: uwtable
47*9880d681SAndroid Build Coastguard Workerdefine void @_ZN7pr147634funcENS_3fooE(%"struct.pr14763::foo"* noalias sret %agg.result, %"struct.pr14763::foo"* %f) #0 !dbg !4 {
48*9880d681SAndroid Build Coastguard Workerentry:
49*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %f, metadata !22, metadata !DIExpression(DW_OP_deref)), !dbg !24
50*9880d681SAndroid Build Coastguard Worker  call void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"* %agg.result, %"struct.pr14763::foo"* %f), !dbg !25
51*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !25
52*9880d681SAndroid Build Coastguard Worker}
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
55*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Workerdeclare void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"*, %"struct.pr14763::foo"*) #2
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker; Function Attrs: uwtable
60*9880d681SAndroid Build Coastguard Workerdefine void @_ZN7pr147635func2EbNS_3fooE(i1 zeroext %b, %"struct.pr14763::foo"* %g) #0 !dbg !17 {
61*9880d681SAndroid Build Coastguard Workerentry:
62*9880d681SAndroid Build Coastguard Worker  %b.addr = alloca i8, align 1
63*9880d681SAndroid Build Coastguard Worker  %frombool = zext i1 %b to i8
64*9880d681SAndroid Build Coastguard Worker  store i8 %frombool, i8* %b.addr, align 1
65*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i8* %b.addr, metadata !26, metadata !DIExpression()), !dbg !27
66*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %g, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !27
67*9880d681SAndroid Build Coastguard Worker  %0 = load i8, i8* %b.addr, align 1, !dbg !29
68*9880d681SAndroid Build Coastguard Worker  %tobool = trunc i8 %0 to i1, !dbg !29
69*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %if.then, label %if.end, !dbg !29
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %entry
72*9880d681SAndroid Build Coastguard Worker  %1 = bitcast %"struct.pr14763::foo"* %g to i8*, !dbg !31
73*9880d681SAndroid Build Coastguard Worker  call void @_ZN7pr147634sinkEPv(i8* %1), !dbg !31
74*9880d681SAndroid Build Coastguard Worker  br label %if.end, !dbg !31
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Workerif.end:                                           ; preds = %if.then, %entry
77*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !32
78*9880d681SAndroid Build Coastguard Worker}
79*9880d681SAndroid Build Coastguard Worker
80*9880d681SAndroid Build Coastguard Workerdeclare void @_ZN7pr147634sinkEPv(i8*) #2
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Workerattributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
83*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
84*9880d681SAndroid Build Coastguard Workerattributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
87*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!21, !33}
88*9880d681SAndroid Build Coastguard Worker
89*9880d681SAndroid Build Coastguard Worker!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)
90*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "pass.cpp", directory: "/tmp")
91*9880d681SAndroid Build Coastguard Worker!2 = !{}
92*9880d681SAndroid Build Coastguard Worker!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, variables: !2)
93*9880d681SAndroid Build Coastguard Worker!5 = !DINamespace(name: "pr14763", line: 1, file: !1, scope: null)
94*9880d681SAndroid Build Coastguard Worker!6 = !DISubroutineType(types: !7)
95*9880d681SAndroid Build Coastguard Worker!7 = !{!8, !8}
96*9880d681SAndroid Build Coastguard Worker!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 2, size: 8, align: 8, file: !1, scope: !5, elements: !9)
97*9880d681SAndroid Build Coastguard Worker!9 = !{!10}
98*9880d681SAndroid Build Coastguard Worker!10 = !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !8, type: !11)
99*9880d681SAndroid Build Coastguard Worker!11 = !DISubroutineType(types: !12)
100*9880d681SAndroid Build Coastguard Worker!12 = !{null, !13, !14}
101*9880d681SAndroid Build Coastguard Worker!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !8)
102*9880d681SAndroid Build Coastguard Worker!14 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !15)
103*9880d681SAndroid Build Coastguard Worker!15 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
104*9880d681SAndroid Build Coastguard Worker!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, variables: !2)
105*9880d681SAndroid Build Coastguard Worker!18 = !DISubroutineType(types: !19)
106*9880d681SAndroid Build Coastguard Worker!19 = !{null, !20, !8}
107*9880d681SAndroid Build Coastguard Worker!20 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
108*9880d681SAndroid Build Coastguard Worker!21 = !{i32 2, !"Dwarf Version", i32 3}
109*9880d681SAndroid Build Coastguard Worker!22 = !DILocalVariable(name: "f", line: 6, arg: 1, scope: !4, file: !23, type: !8)
110*9880d681SAndroid Build Coastguard Worker!23 = !DIFile(filename: "pass.cpp", directory: "/tmp")
111*9880d681SAndroid Build Coastguard Worker!24 = !DILocation(line: 6, scope: !4)
112*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 7, scope: !4)
113*9880d681SAndroid Build Coastguard Worker!26 = !DILocalVariable(name: "b", line: 12, arg: 1, scope: !17, file: !23, type: !20)
114*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 12, scope: !17)
115*9880d681SAndroid Build Coastguard Worker!28 = !DILocalVariable(name: "g", line: 12, arg: 2, scope: !17, file: !23, type: !8)
116*9880d681SAndroid Build Coastguard Worker!29 = !DILocation(line: 13, scope: !30)
117*9880d681SAndroid Build Coastguard Worker!30 = distinct !DILexicalBlock(line: 13, column: 0, file: !1, scope: !17)
118*9880d681SAndroid Build Coastguard Worker!31 = !DILocation(line: 14, scope: !30)
119*9880d681SAndroid Build Coastguard Worker!32 = !DILocation(line: 15, scope: !17)
120*9880d681SAndroid Build Coastguard Worker!33 = !{i32 1, !"Debug Info Version", i32 3}
121