1 ## Test the call site encoding in DWARF5 vs GNU extensions.
3 ## === DWARF4, tune for gdb ===
4 # RUN: llc -emit-call-site-info -dwarf-version 4 -debugger-tune=gdb -filetype=obj \
5 # RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \
6 # RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU -implicit-check-not=DW_AT_call
8 # === DWARF5, tune for gdb ===
9 # RUN: llc -dwarf-version 5 -debugger-tune=gdb -emit-call-site-info -filetype=obj \
10 # RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \
11 # RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 -implicit-check-not=DW_AT_call
13 ## === DWARF4, tune for lldb ===
14 # RUN: llc -dwarf-version 4 -debugger-tune=lldb -emit-call-site-info -filetype=obj \
15 # RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \
16 # RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 -implicit-check-not=DW_AT_call
18 ## === DWARF5, tune for lldb ===
19 # RUN: llc -dwarf-version 5 -debugger-tune=lldb -emit-call-site-info -filetype=obj \
20 # RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \
21 # RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 -implicit-check-not=DW_AT_call
23 ## === DWARF4, tune for sce ===
24 # RUN: llc -emit-call-site-info -dwarf-version 4 -filetype=obj -debugger-tune=sce \
25 # RUN: -debug-entry-values -mtriple=x86_64-unknown-unknown \
26 # RUN: -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU
28 ## === DWARF5, tune for sce ===
29 # RUN: llc -emit-call-site-info -dwarf-version 5 -filetype=obj -debugger-tune=sce \
30 # RUN: -debug-entry-values -mtriple=x86_64-unknown-unknown \
31 # RUN: -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5
33 ## This is based on the following reproducer:
36 ## extern void fn2(int x);
39 ## int fn1(int (*fn4) ()) {
50 ## Check GNU extensions:
52 # CHECK-GNU: DW_TAG_subprogram
53 # CHECK-GNU: DW_AT_GNU_all_call_sites (true)
54 # CHECK-GNU: DW_TAG_GNU_call_site
55 # CHECK-GNU-NEXT: DW_AT_abstract_origin
56 # CHECK-GNU-NEXT: DW_AT_low_pc
57 # CHECK-GNU: DW_TAG_GNU_call_site_parameter
58 # CHECK-GNU-NEXT: DW_AT_location
59 # CHECK-GNU-NEXT: DW_AT_GNU_call_site_value
60 # CHECK-GNU: DW_TAG_GNU_call_site
61 # CHECK-GNU-NEXT: DW_AT_GNU_call_site_target
62 # CHECK-GNU-NEXT: DW_AT_low_pc
63 # CHECK-GNU: DW_TAG_GNU_call_site
64 # CHECK-GNU-NEXT: DW_AT_abstract_origin
65 # CHECK-GNU-NEXT: DW_AT_GNU_tail_call
66 # CHECK-GNU-NEXT: DW_AT_low_pc
70 # CHECK-DWARF5: DW_TAG_subprogram
71 # CHECK-DWARF5: DW_AT_call_all_calls (true)
72 # CHECK-DWARF5: DW_TAG_call_site
73 # CHECK-DWARF5-NEXT: DW_AT_call_origin
74 # CHECK-DWARF5-NEXT: DW_AT_call_return_pc
75 # CHECK-DWARF5: DW_TAG_call_site
76 # CHECK-DWARF5-NEXT: DW_AT_call_origin
77 # CHECK-DWARF5-NEXT: DW_AT_call_return_pc
78 # CHECK-DWARF5: DW_TAG_call_site_parameter
79 # CHECK-DWARF5-NEXT: DW_AT_location
80 # CHECK-DWARF5-NEXT: DW_AT_call_value
81 # CHECK-DWARF5: DW_TAG_call_site
82 # CHECK-DWARF5-NEXT: DW_AT_call_target
83 # CHECK-DWARF5-NEXT: DW_AT_call_return_pc
84 # CHECK-DWARF5: DW_TAG_call_site
85 # CHECK-DWARF5-NEXT: DW_AT_call_origin
86 # CHECK-DWARF5-NEXT: DW_AT_call_tail_call
87 # CHECK-DWARF5-NEXT: DW_AT_call_pc
90 ; ModuleID = 'call-site-attrs.c'
91 source_filename = "call-site-attrs.c"
92 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
93 target triple = "x86_64-unknown-linux-gnu"
94 ; Function Attrs: nounwind uwtable
95 define dso_local i32 @fn1(i32 (...)* nocapture %fn4) local_unnamed_addr !dbg !18 {
97 call void @llvm.dbg.value(metadata i32 (...)* %fn4, metadata !23, metadata !DIExpression()), !dbg !25
98 tail call void (...) @fn(), !dbg !26
99 tail call void @fn2(i32 5), !dbg !27
100 %call = tail call i32 (...) %fn4(), !dbg !28
101 call void @llvm.dbg.value(metadata i32 %call, metadata !24, metadata !DIExpression()), !dbg !25
102 %tobool = icmp eq i32 %call, 0, !dbg !29
103 br i1 %tobool, label %if.then, label %cleanup, !dbg !31
105 if.then: ; preds = %entry
106 %call1 = tail call i32 (...) @fn3(), !dbg !32
107 ret i32 %call1, !dbg !33
109 cleanup: ; preds = %entry
112 declare !dbg !4 dso_local void @fn(...) local_unnamed_addr
113 declare !dbg !7 dso_local void @fn2(i32) local_unnamed_addr
114 declare !dbg !11 dso_local i32 @fn3(...) local_unnamed_addr
115 ; Function Attrs: nounwind readnone speculatable willreturn
116 declare void @llvm.dbg.value(metadata, metadata, metadata)
119 !llvm.module.flags = !{!14, !15, !16}
122 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
123 !1 = !DIFile(filename: "call-site-attrs.c", directory: "/")
126 !4 = !DISubprogram(name: "fn", scope: !1, file: !1, line: 1, type: !5, spFlags: DISPFlagOptimized, retainedNodes: !2)
127 !5 = !DISubroutineType(types: !6)
129 !7 = !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
130 !8 = !DISubroutineType(types: !9)
132 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
133 !11 = !DISubprogram(name: "fn3", scope: !1, file: !1, line: 3, type: !12, spFlags: DISPFlagOptimized, retainedNodes: !2)
134 !12 = !DISubroutineType(types: !13)
136 !14 = !{i32 7, !"Dwarf Version", i32 4}
137 !15 = !{i32 2, !"Debug Info Version", i32 3}
138 !16 = !{i32 1, !"wchar_size", i32 4}
139 !17 = !{!"clang version 11.0.0"}
140 !18 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 5, type: !19, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22)
141 !19 = !DISubroutineType(types: !20)
143 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
145 !23 = !DILocalVariable(name: "fn4", arg: 1, scope: !18, file: !1, line: 5, type: !21)
146 !24 = !DILocalVariable(name: "x", scope: !18, file: !1, line: 9, type: !10)
147 !25 = !DILocation(line: 0, scope: !18)
148 !26 = !DILocation(line: 6, column: 3, scope: !18)
149 !27 = !DILocation(line: 7, column: 3, scope: !18)
150 !28 = !DILocation(line: 9, column: 11, scope: !18)
151 !29 = !DILocation(line: 10, column: 8, scope: !30)
152 !30 = distinct !DILexicalBlock(scope: !18, file: !1, line: 10, column: 7)
153 !31 = !DILocation(line: 10, column: 7, scope: !18)
154 !32 = !DILocation(line: 11, column: 12, scope: !30)
155 !33 = !DILocation(line: 14, column: 1, scope: !18)
161 - { bb: 0, offset: 7, fwdArgRegs: [] }
162 - { bb: 0, offset: 9, fwdArgRegs:
163 - { arg: 0, reg: '$edi' } }
164 - { bb: 0, offset: 11, fwdArgRegs: [] }
165 - { bb: 2, offset: 7, fwdArgRegs: [] }
168 successors: %bb.2(0x30000000), %bb.1(0x50000000)
171 DBG_VALUE $rdi, $noreg, !23, !DIExpression(), debug-location !25
172 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
173 CFI_INSTRUCTION def_cfa_offset 16
174 CFI_INSTRUCTION offset $rbx, -16
176 DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25
177 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !26
178 CALL64pcrel32 @fn, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, debug-location !26
179 $edi = MOV32ri 5, debug-location !27
180 CALL64pcrel32 @fn2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, debug-location !27
181 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !28
182 CALL64r killed renamable $rbx, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !28
183 DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25
184 TEST32rr killed renamable $eax, renamable $eax, implicit-def $eflags, debug-location !29
185 JCC_1 %bb.2, 4, implicit $eflags, debug-location !31
188 DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25
189 DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25
190 $eax = MOV32ri -1, debug-location !33
191 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !33
192 DBG_VALUE $rdi, $noreg, !23, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25
193 CFI_INSTRUCTION def_cfa_offset 8, debug-location !33
194 RETQ $eax, debug-location !33
197 CFI_INSTRUCTION def_cfa_offset 16, debug-location !32
198 DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25
199 DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25
200 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !32
201 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !32
202 DBG_VALUE $rdi, $noreg, !23, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25
203 CFI_INSTRUCTION def_cfa_offset 8, debug-location !32
204 TAILJMPd64 @fn3, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp, implicit $al, debug-location !32