1 # RUN: llc -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
3 # CHECK: DW_TAG_GNU_call_site
4 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo"
5 # CHECK-NEXT: DW_AT_low_pc
7 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
8 # CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)
9 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0)
11 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
12 # CHECK-NEXT: DW_AT_location (DW_OP_reg1 RDX)
13 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8)
15 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
16 # CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)
17 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg4 RSI))
19 # CHECK: DW_TAG_GNU_call_site
20 # CHECK-NEXT: DW_AT_abstract_origin {{.*}}"foo"
21 # CHECK-NEXT: DW_AT_low_pc
23 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
24 # RCX loads memory location. We can't rely that memory location won't be changed.
25 # CHECK-NOT: DW_AT_location (DW_OP_reg2 RCX)
26 # CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)
27 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit4)
29 # CHECK-NOT: DW_TAG_GNU_call_site_parameter
31 # Check that call site interpretation analysis can interpret instructions such
32 # as move immediate, register to register moves, stack loading and LEA
33 # instructions. Last negative check should verify that we are not producing
34 # interpretation for RDX register since its loaded value is call clobberable.
35 # Also check that we are generating proper call site debug entities.
37 ; ModuleID = 'dbgcall-site-interpretation.c'
38 source_filename = "dbgcall-site-interpretation.c"
39 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40 target triple = "x86_64-unknown-linux-gnu"
42 ; Function Attrs: nounwind uwtable
43 define dso_local i32 @baa(i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4) local_unnamed_addr !dbg !9 {
45 %arg3.addr = alloca i32, align 4
46 %local2 = alloca i32, align 4
47 call void @llvm.dbg.value(metadata i32 %arg1, metadata !14, metadata !DIExpression()), !dbg !21
48 call void @llvm.dbg.value(metadata i32 %arg2, metadata !15, metadata !DIExpression()), !dbg !21
49 call void @llvm.dbg.value(metadata i32 %arg3, metadata !16, metadata !DIExpression()), !dbg !21
50 store i32 %arg3, i32* %arg3.addr, align 4
51 call void @llvm.dbg.value(metadata i32 %arg4, metadata !17, metadata !DIExpression()), !dbg !21
52 %0 = bitcast i32* %local2 to i8*, !dbg !21
53 call void @llvm.dbg.value(metadata i32* %arg3.addr, metadata !16, metadata !DIExpression(DW_OP_deref)), !dbg !21
54 %call = call i32 @foo(i32 %arg1, i32 %arg2, i32* nonnull %arg3.addr, i32 %arg4), !dbg !21
55 call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !21
56 %cmp = icmp sgt i32 %arg1, %arg2, !dbg !21
57 %1 = load i32, i32* %arg3.addr, align 4, !dbg !21
58 call void @llvm.dbg.value(metadata i32 %1, metadata !16, metadata !DIExpression()), !dbg !21
59 %add = add nsw i32 %1, %arg1, !dbg !21
60 %add1 = add nsw i32 %arg4, %arg2, !dbg !21
61 %local1.0 = select i1 %cmp, i32 %add, i32 %add1, !dbg !21
62 call void @llvm.dbg.value(metadata i32 %local1.0, metadata !18, metadata !DIExpression()), !dbg !21
63 %rem = srem i32 %1, %arg1, !dbg !21
64 %tobool = icmp eq i32 %rem, 0, !dbg !21
65 %mul = mul nsw i32 %1, %arg1, !dbg !21
66 %add3 = add nsw i32 %1, %arg4, !dbg !21
67 %storemerge = select i1 %tobool, i32 %mul, i32 %add3, !dbg !21
68 call void @llvm.dbg.value(metadata i32 %storemerge, metadata !19, metadata !DIExpression()), !dbg !21
69 store i32 %storemerge, i32* %local2, align 4, !dbg !21
70 %cmp6 = icmp slt i32 %storemerge, %arg4, !dbg !21
71 %local3.0.v = select i1 %cmp6, i32 %local1.0, i32 %arg1, !dbg !21
72 %local3.0 = mul nsw i32 %local3.0.v, %storemerge, !dbg !21
73 call void @llvm.dbg.value(metadata i32 %local3.0, metadata !20, metadata !DIExpression()), !dbg !21
74 call void @llvm.dbg.value(metadata i32* %local2, metadata !19, metadata !DIExpression(DW_OP_deref)), !dbg !21
75 %call12 = call i32 @foo(i32 %local1.0, i32 4, i32* nonnull %local2, i32 %local3.0), !dbg !21
76 call void @llvm.dbg.value(metadata i32 %call12, metadata !14, metadata !DIExpression()), !dbg !21
77 %add13 = add nsw i32 %call12, 4, !dbg !21
78 ret i32 %add13, !dbg !21
81 declare !dbg !4 dso_local i32 @foo(i32, i32, i32*, i32) local_unnamed_addr
83 ; Function Attrs: nounwind readnone speculatable
84 declare void @llvm.dbg.value(metadata, metadata, metadata)
87 !llvm.module.flags = !{!5, !6, !7}
90 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
91 !1 = !DIFile(filename: "dbgcall-site-interpretation.c", directory: "/dir")
94 !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
95 !5 = !{i32 2, !"Dwarf Version", i32 4}
96 !6 = !{i32 2, !"Debug Info Version", i32 3}
97 !7 = !{i32 1, !"wchar_size", i32 4}
98 !8 = !{!"clang version 9.0.0"}
99 !9 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 10, type: !10, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
100 !10 = !DISubroutineType(types: !11)
101 !11 = !{!12, !12, !12, !12, !12}
102 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
103 !13 = !{!14, !15, !16, !17, !18, !19, !20}
104 !14 = !DILocalVariable(name: "arg1", arg: 1, scope: !9, file: !1, line: 10, type: !12)
105 !15 = !DILocalVariable(name: "arg2", arg: 2, scope: !9, file: !1, line: 10, type: !12, flags: DIFlagArgumentNotModified)
106 !16 = !DILocalVariable(name: "arg3", arg: 3, scope: !9, file: !1, line: 10, type: !12)
107 !17 = !DILocalVariable(name: "arg4", arg: 4, scope: !9, file: !1, line: 10, type: !12, flags: DIFlagArgumentNotModified)
108 !18 = !DILocalVariable(name: "local1", scope: !9, file: !1, line: 11, type: !12)
109 !19 = !DILocalVariable(name: "local2", scope: !9, file: !1, line: 11, type: !12)
110 !20 = !DILocalVariable(name: "local3", scope: !9, file: !1, line: 11, type: !12)
111 !21 = !DILocation(line: 10, column: 13, scope: !9)
117 - { reg: '$edi', virtual-reg: '' }
118 - { reg: '$esi', virtual-reg: '' }
119 - { reg: '$edx', virtual-reg: '' }
120 - { reg: '$ecx', virtual-reg: '' }
122 - { bb: 0, offset: 23, fwdArgRegs:
123 - { arg: 0, reg: '$edi' }
124 - { arg: 1, reg: '$esi' }
125 - { arg: 2, reg: '$rdx' }
126 - { arg: 3, reg: '$ecx' } }
127 - { bb: 0, offset: 49, fwdArgRegs:
128 - { arg: 0, reg: '$edi' }
129 - { arg: 1, reg: '$esi' }
130 - { arg: 2, reg: '$rdx' }
131 - { arg: 3, reg: '$ecx' } }
134 liveins: $ecx, $edi, $edx, $esi, $r15, $r14, $rbx
136 DBG_VALUE $edi, $noreg, !14, !DIExpression(), debug-location !21
137 DBG_VALUE $esi, $noreg, !15, !DIExpression(), debug-location !21
138 DBG_VALUE $edx, $noreg, !16, !DIExpression(), debug-location !21
139 DBG_VALUE $ecx, $noreg, !17, !DIExpression(), debug-location !21
140 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
141 CFI_INSTRUCTION def_cfa_offset 16
142 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
143 CFI_INSTRUCTION def_cfa_offset 24
144 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
145 CFI_INSTRUCTION def_cfa_offset 32
146 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
147 CFI_INSTRUCTION def_cfa_offset 48
148 CFI_INSTRUCTION offset $rbx, -32
149 CFI_INSTRUCTION offset $r14, -24
150 CFI_INSTRUCTION offset $r15, -16
151 $r14d = MOV32rr $ecx, implicit-def $r14
152 DBG_VALUE $edx, $noreg, !16, !DIExpression(), debug-location !21
153 $r15d = MOV32rr $esi, implicit-def $r15
154 $ebx = MOV32rr $edi, implicit-def $rbx
156 MOV32mr $rsp, 1, $noreg, 8, $noreg, killed renamable $edx :: (store 4 into %ir.arg3.addr)
157 renamable $rdx = LEA64r $rsp, 1, $noreg, 8, $noreg
158 renamable $ecx = MOV32rr $r14d,
159 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, implicit-def $rax, debug-location !21
160 DBG_VALUE $noreg, $noreg, !18, !DIExpression(), debug-location !21
161 $rdx = MOV64rr renamable $rax
162 $ecx = KILL renamable $ecx, implicit-def $rcx
163 renamable $eax = LEA64_32r renamable $rcx, 1, renamable $rbx, 0, $noreg, debug-location !21
164 renamable $edi = LEA64_32r renamable $r14, 1, renamable $r15, 0, $noreg, debug-location !21
165 CMP32rr renamable $ebx, renamable $r15d, implicit-def $eflags, implicit killed $r15, debug-location !21
166 renamable $edi = CMOV32rr killed renamable $edi, killed renamable $eax, 15, implicit killed $eflags, debug-location !21
167 DBG_VALUE $edi, $noreg, !18, !DIExpression(), debug-location !21
168 $eax = MOV32rr $ecx, debug-location !21
169 CDQ implicit-def $eax, implicit-def $edx, implicit $eax, debug-location !21
170 IDIV32r renamable $ebx, implicit-def dead $eax, implicit-def $edx, implicit-def dead $eflags, implicit $eax, implicit $edx, debug-location !21
171 $eax = MOV32rr $ecx, debug-location !21
172 renamable $eax = nsw IMUL32rr killed renamable $eax, renamable $ebx, implicit-def dead $eflags, debug-location !21
173 renamable $ecx = nsw ADD32rr renamable $ecx, renamable $r14d, implicit-def dead $eflags, implicit killed $rcx, implicit-def $rcx, debug-location !21
174 TEST32rr killed renamable $edx, renamable $edx, implicit-def $eflags, debug-location !21
175 renamable $ecx = CMOV32rr renamable $ecx, killed renamable $eax, 4, implicit killed $eflags, implicit killed $rcx, implicit-def $rcx, debug-location !21
176 DBG_VALUE $ecx, $noreg, !19, !DIExpression(), debug-location !21
177 MOV32mr $rsp, 1, $noreg, 12, $noreg, renamable $ecx, debug-location !21 :: (store 4 into %ir.local2)
178 CMP32rr renamable $ecx, renamable $r14d, implicit-def $eflags, implicit killed $r14, debug-location !21
179 renamable $ebx = CMOV32rr renamable $ebx, renamable $edi, 12, implicit killed $eflags, implicit killed $rbx, implicit-def $rbx, debug-location !21
180 renamable $ecx = nsw IMUL32rr renamable $ecx, renamable $ebx, implicit-def dead $eflags, implicit killed $rbx, implicit killed $rcx, implicit-def $rcx, debug-location !21
181 DBG_VALUE $rsp, $noreg, !19, !DIExpression(DW_OP_plus_uconst, 12, DW_OP_deref), debug-location !21
182 DBG_VALUE $ecx, $noreg, !20, !DIExpression(), debug-location !21
183 $esi = MOV32ri 4, debug-location !21
184 renamable $ecx = MOV32rm $rsp, 1, $noreg, 8, $noreg, implicit-def $rcx, debug-location !21 :: (dereferenceable load 4 from %ir.arg3.addr)
185 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, implicit-def $rax, debug-location !21
186 DBG_VALUE $eax, $noreg, !14, !DIExpression(), debug-location !21
187 renamable $eax = nsw ADD32ri8 killed renamable $eax, 4, implicit-def dead $eflags, debug-location !21
188 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !21
189 CFI_INSTRUCTION def_cfa_offset 32, debug-location !21
190 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21
191 CFI_INSTRUCTION def_cfa_offset 24, debug-location !21
192 $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21
193 DBG_VALUE $ecx, $noreg, !17, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !21
194 CFI_INSTRUCTION def_cfa_offset 16, debug-location !21
195 $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21
196 DBG_VALUE $esi, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !21
197 CFI_INSTRUCTION def_cfa_offset 8, debug-location !21
198 RETQ $eax, debug-location !21