xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir (revision 92b33822e989884d29465d34769b07d78aeb1a84)
1# Test call site parameter encoding in DWARFv4.
2# When the debugger tuning is set to gdb, use GNU opcodes.
3# For lldb, use the standard DWARF5 opcodes.
4
5# RUN: llc -emit-call-site-info -debugger-tune=gdb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU
6# RUN: llc -emit-call-site-info -debugger-tune=lldb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5
7#
8# extern void foo(int *a, int b, int c, int d, int e, int f);
9# extern int getVal();
10#
11# void baa(int arg1, int arg2, int arg3) {
12#   int local1 = getVal();
13#   foo(&local1, arg2, 10, 15, arg3 + 3, arg1 + arg2);
14# }
15#
16# CHECK-GNU: DW_TAG_GNU_call_site
17# CHECK-GNU:   DW_AT_abstract_origin {{.*}} "getVal"
18#
19# CHECK-GNU:       DW_TAG_GNU_call_site
20# CHECK-GNU:         DW_AT_abstract_origin {{.*}} "foo"
21# CHECK-GNU:         DW_AT_low_pc {{.*}}
22# CHECK-GNU-EMPTY:
23# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
24# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg2 RCX)
25# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_lit15)
26# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
27# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg1 RDX)
28# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_lit10)
29# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
30# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg4 RSI)
31# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_breg3 RBX+0)
32# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
33# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg5 RDI)
34# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_fbreg +12)
35# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
36# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg9 R9)
37# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_breg15 R15+0, DW_OP_breg3 RBX+0, DW_OP_plus)
38# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
39# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg8 R8)
40# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_breg14 R14+3)
41
42# CHECK-DWARF5: DW_TAG_call_site
43# CHECK-DWARF5:   DW_AT_call_origin ([[getValue_SP:.*]] "getVal")
44#
45# CHECK-DWARF5: DW_TAG_call_site
46# CHECK-DWARF5:   DW_AT_call_origin ([[foo_SP:.*]] "foo")
47# CHECK-DWARF5:   DW_AT_call_return_pc {{.*}}
48# CHECK-DWARF5-EMPTY:
49# CHECK-DWARF5:         DW_TAG_call_site_parameter
50# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg2 RCX)
51# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_lit15)
52# CHECK-DWARF5:         DW_TAG_call_site_parameter
53# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg1 RDX)
54# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_lit10)
55# CHECK-DWARF5:         DW_TAG_call_site_parameter
56# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg4 RSI)
57# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_breg3 RBX+0)
58# CHECK-DWARF5:         DW_TAG_call_site_parameter
59# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg5 RDI)
60# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_fbreg +12)
61# CHECK-DWARF5:         DW_TAG_call_site_parameter
62# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg9 R9)
63# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_breg15 R15+0, DW_OP_breg3 RBX+0, DW_OP_plus)
64# CHECK-DWARF5:         DW_TAG_call_site_parameter
65# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg8 R8)
66# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_breg14 R14+3)
67
68# CHECK-DWARF5: [[getValue_SP]]: DW_TAG_subprogram
69# CHECK-DWARF5-NEXT: DW_AT_name      ("getVal")
70
71# CHECK-DWARF5: [[foo_SP]]: DW_TAG_subprogram
72# CHECK-DWARF5-NEXT: DW_AT_name      ("foo")
73
74--- |
75  ; ModuleID = 'test.c'
76  source_filename = "test.c"
77  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
78
79  ; Function Attrs: nounwind uwtable
80  define dso_local void @baa(i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr !dbg !10 {
81  entry:
82    %local1 = alloca i32, align 4
83    call void @llvm.dbg.value(metadata i32 %arg1, metadata !15, metadata !DIExpression()), !dbg !19
84    call void @llvm.dbg.value(metadata i32 %arg2, metadata !16, metadata !DIExpression()), !dbg !20
85    call void @llvm.dbg.value(metadata i32 %arg3, metadata !17, metadata !DIExpression()), !dbg !21
86    %0 = bitcast ptr %local1 to ptr, !dbg !22
87    %call = tail call i32 (...) @getVal(), !dbg !23
88    call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !24
89    store i32 %call, ptr %local1, align 4, !dbg !24
90    %add = add nsw i32 %arg3, 3, !dbg !24
91    %add1 = add nsw i32 %arg2, %arg1, !dbg !24
92    call void @llvm.dbg.value(metadata ptr %local1, metadata !18, metadata !DIExpression(DW_OP_deref)), !dbg !24
93    call void @foo(ptr nonnull %local1, i32 %arg2, i32 10, i32 15, i32 %add, i32 %add1), !dbg !24
94    ret void, !dbg !24
95  }
96
97  declare !dbg !4 dso_local i32 @getVal(...) local_unnamed_addr
98
99  declare !dbg !5 dso_local void @foo(ptr, i32, i32, i32, i32, i32) local_unnamed_addr
100
101  ; Function Attrs: nounwind readnone speculatable
102  declare void @llvm.dbg.value(metadata, metadata, metadata)
103
104  !llvm.dbg.cu = !{!0}
105  !llvm.module.flags = !{!6, !7, !8}
106  !llvm.ident = !{!9}
107
108  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
109  !1 = !DIFile(filename: "test.c", directory: "/dir")
110  !2 = !{}
111  !4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, spFlags: DISPFlagOptimized, retainedNodes: !2)
112  !5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
113  !6 = !{i32 2, !"Dwarf Version", i32 4}
114  !7 = !{i32 2, !"Debug Info Version", i32 3}
115  !8 = !{i32 1, !"wchar_size", i32 4}
116  !9 = !{!"clang version 9.0.0"}
117  !10 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
118  !11 = !DISubroutineType(types: !12)
119  !12 = !{null, !13, !13, !13}
120  !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
121  !14 = !{!15, !16, !17, !18}
122  !15 = !DILocalVariable(name: "arg1", arg: 1, scope: !10, file: !1, line: 4, type: !13)
123  !16 = !DILocalVariable(name: "arg2", arg: 2, scope: !10, file: !1, line: 4, type: !13)
124  !17 = !DILocalVariable(name: "arg3", arg: 3, scope: !10, file: !1, line: 4, type: !13)
125  !18 = !DILocalVariable(name: "local1", scope: !10, file: !1, line: 5, type: !13)
126  !19 = !DILocation(line: 4, column: 14, scope: !10)
127  !20 = !DILocation(line: 4, column: 24, scope: !10)
128  !21 = !DILocation(line: 4, column: 34, scope: !10)
129  !22 = !DILocation(line: 5, column: 3, scope: !10)
130  !23 = !DILocation(line: 5, column: 16, scope: !10)
131  !24 = !DILocation(line: 5, column: 7, scope: !10)
132
133...
134---
135name:            baa
136liveins:
137  - { reg: '$edi', virtual-reg: '' }
138  - { reg: '$esi', virtual-reg: '' }
139  - { reg: '$edx', virtual-reg: '' }
140callSites:
141  - { bb: 0, offset: 21, fwdArgRegs: [] }
142  - { bb: 0, offset: 31, fwdArgRegs:
143      - { arg: 0, reg: '$rdi' }
144      - { arg: 1, reg: '$esi' }
145      - { arg: 2, reg: '$edx' }
146      - { arg: 3, reg: '$ecx' }
147      - { arg: 4, reg: '$r8d' }
148      - { arg: 5, reg: '$r9d' } }
149body:             |
150  bb.0.entry:
151    liveins: $edi, $edx, $esi, $r15, $r14, $rbx
152
153    DBG_VALUE $edi, $noreg, !15, !DIExpression(), debug-location !19
154    DBG_VALUE $esi, $noreg, !16, !DIExpression(), debug-location !20
155    DBG_VALUE $edx, $noreg, !17, !DIExpression(), debug-location !21
156    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
157    CFI_INSTRUCTION def_cfa_offset 16
158    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
159    CFI_INSTRUCTION def_cfa_offset 24
160    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
161    CFI_INSTRUCTION def_cfa_offset 32
162    $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
163    CFI_INSTRUCTION def_cfa_offset 48
164    CFI_INSTRUCTION offset $rbx, -32
165    CFI_INSTRUCTION offset $r14, -24
166    CFI_INSTRUCTION offset $r15, -16
167    $r14d = MOV32rr $edx, implicit-def $r14
168    $ebx = MOV32rr $esi, implicit-def $rbx
169    $r15d = MOV32rr $edi, implicit-def $r15
170    DBG_VALUE $r14d, $noreg, !17, !DIExpression(), debug-location !21
171    DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !20
172    DBG_VALUE $r15d, $noreg, !15, !DIExpression(), debug-location !19
173    dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !23
174    CALL64pcrel32 @getVal, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !23
175    DBG_VALUE $eax, $noreg, !18, !DIExpression(), debug-location !24
176    MOV32mr $rsp, 1, $noreg, 12, $noreg, killed renamable $eax, debug-location !24 :: (store (s32) into %ir.local1)
177    renamable $r8d = LEA64_32r killed renamable $r14, 1, $noreg, 3, $noreg, debug-location !24
178    renamable $r9d = LEA64_32r killed renamable $r15, 1, renamable $rbx, 0, $noreg, debug-location !24
179    DBG_VALUE $rsp, $noreg, !18, !DIExpression(DW_OP_plus_uconst, 12, DW_OP_deref), debug-location !24
180    renamable $rdi = LEA64r $rsp, 1, $noreg, 12, $noreg
181    $esi = MOV32rr $ebx, implicit killed $rbx, debug-location !24
182    $edx = MOV32ri 10, debug-location !24
183    $ecx = MOV32ri 15, debug-location !24
184    CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $esi, implicit $edx, implicit killed $ecx, implicit $r8d, implicit $r9d, implicit-def $rsp, implicit-def $ssp, debug-location !24
185    $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !24
186    CFI_INSTRUCTION def_cfa_offset 32, debug-location !24
187    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
188    CFI_INSTRUCTION def_cfa_offset 24, debug-location !24
189    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
190    CFI_INSTRUCTION def_cfa_offset 16, debug-location !24
191    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
192    CFI_INSTRUCTION def_cfa_offset 8, debug-location !24
193    RET64 debug-location !24
194
195...
196