xref: /llvm-project/llvm/test/CodeGen/AMDGPU/split-arg-dbg-value.ll (revision bdf2fbba9cee60b4b260ff17e4f44c475c11e715)
1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefix=GCN %s
2; Make sure dbg_value reports something for argument registers when they are split into multiple registers
3
4define hidden <4 x float> @split_v4f32_arg(<4 x float> returned %arg) local_unnamed_addr #0 !dbg !7 {
5; GCN-LABEL: split_v4f32_arg:
6; GCN:       .Lfunc_begin0:
7; GCN-NEXT:    .file 0
8; GCN-NEXT:    .loc 0 3 0 ; /tmp/dbg.cl:3:0
9; GCN-NEXT:    .cfi_sections .debug_frame
10; GCN-NEXT:    .cfi_startproc
11; GCN-NEXT:  ; %bb.0:
12; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 96 32] $vgpr3
13; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 64 32] $vgpr2
14; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
15; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
16; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
17; GCN-NEXT:  .Ltmp0:
18; GCN-NEXT:    .loc 0 4 5 prologue_end ; /tmp/dbg.cl:4:5
19; GCN-NEXT:    s_setpc_b64 s[30:31]
20; GCN-NEXT:  .Ltmp1:
21; GCN:         .cfi_endproc
22  call void @llvm.dbg.value(metadata <4 x float> %arg, metadata !18, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !19
23  ret <4 x float> %arg, !dbg !20
24}
25
26define hidden <4 x float> @split_v4f32_multi_arg(<4 x float> %arg0, <2 x float> %arg1) local_unnamed_addr #0 !dbg !21 {
27; GCN-LABEL: split_v4f32_multi_arg:
28; GCN:       .Lfunc_begin1:
29; GCN-NEXT:    .loc 0 7 0 ; /tmp/dbg.cl:7:0
30; GCN-NEXT:    .cfi_startproc
31; GCN-NEXT:  ; %bb.0:
32; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_multi_arg:arg1 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr5
33; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_multi_arg:arg1 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr4
34; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_multi_arg:arg0 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 96 32] $vgpr3
35; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_multi_arg:arg0 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 64 32] $vgpr2
36; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_multi_arg:arg0 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
37; GCN-NEXT:    ;DEBUG_VALUE: split_v4f32_multi_arg:arg0 <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
38; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
39; GCN-NEXT:  .Ltmp2:
40; GCN-NEXT:    .loc 0 8 17 prologue_end ; /tmp/dbg.cl:8:17
41; GCN-NEXT:    v_add_f32_e32 v0, v4, v0
42; GCN-NEXT:  .Ltmp3:
43; GCN-NEXT:    v_add_f32_e32 v1, v5, v1
44; GCN-NEXT:  .Ltmp4:
45; GCN-NEXT:    v_add_f32_e32 v2, v4, v2
46; GCN-NEXT:  .Ltmp5:
47; GCN-NEXT:    v_add_f32_e32 v3, v5, v3
48; GCN-NEXT:  .Ltmp6:
49; GCN-NEXT:    .loc 0 8 5 is_stmt 0 ; /tmp/dbg.cl:8:5
50; GCN-NEXT:    s_setpc_b64 s[30:31]
51; GCN-NEXT:  .Ltmp7:
52; GCN:         .cfi_endproc
53  call void @llvm.dbg.value(metadata <4 x float> %arg0, metadata !29, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !31
54  call void @llvm.dbg.value(metadata <2 x float> %arg1, metadata !30, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !31
55  %tmp = shufflevector <2 x float> %arg1, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1>, !dbg !32
56  %add = fadd <4 x float> %tmp, %arg0, !dbg !33
57  ret <4 x float> %add, !dbg !34
58}
59
60define hidden <4 x half> @split_v4f16_arg(<4 x half> returned %arg) local_unnamed_addr #0 !dbg !35 {
61; GCN-LABEL: split_v4f16_arg:
62; GCN:       .Lfunc_begin2:
63; GCN-NEXT:    .loc 0 11 0 is_stmt 1 ; /tmp/dbg.cl:11:0
64; GCN-NEXT:    .cfi_startproc
65; GCN-NEXT:  ; %bb.0:
66; GCN-NEXT:    ;DEBUG_VALUE: split_v4f16_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
67; GCN-NEXT:    ;DEBUG_VALUE: split_v4f16_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
68; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
69; GCN-NEXT:  .Ltmp8:
70; GCN-NEXT:    .loc 0 12 5 prologue_end ; /tmp/dbg.cl:12:5
71; GCN-NEXT:    s_setpc_b64 s[30:31]
72; GCN-NEXT:  .Ltmp9:
73; GCN:         .cfi_endproc
74  call void @llvm.dbg.value(metadata <4 x half> %arg, metadata !42, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !43
75  ret <4 x half> %arg, !dbg !44
76}
77
78define hidden double @split_f64_arg(double returned %arg) local_unnamed_addr #0 !dbg !45 {
79; GCN-LABEL: split_f64_arg:
80; GCN:       .Lfunc_begin3:
81; GCN-NEXT:    .loc 0 15 0 ; /tmp/dbg.cl:15:0
82; GCN-NEXT:    .cfi_startproc
83; GCN-NEXT:  ; %bb.0:
84; GCN-NEXT:    ;DEBUG_VALUE: split_f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
85; GCN-NEXT:    ;DEBUG_VALUE: split_f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
86; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
87; GCN-NEXT:  .Ltmp10:
88; GCN-NEXT:    .loc 0 16 5 prologue_end ; /tmp/dbg.cl:16:5
89; GCN-NEXT:    s_setpc_b64 s[30:31]
90; GCN-NEXT:  .Ltmp11:
91; GCN:         .cfi_endproc
92  call void @llvm.dbg.value(metadata double %arg, metadata !50, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !51
93  ret double %arg, !dbg !52
94}
95
96define hidden <2 x double> @split_v2f64_arg(<2 x double> returned %arg) local_unnamed_addr #0 !dbg !53 {
97; GCN-LABEL: split_v2f64_arg:
98; GCN:       .Lfunc_begin4:
99; GCN-NEXT:    .loc 0 19 0 ; /tmp/dbg.cl:19:0
100; GCN-NEXT:    .cfi_startproc
101; GCN-NEXT:  ; %bb.0:
102; GCN-NEXT:    ;DEBUG_VALUE: split_v2f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 96 32] $vgpr3
103; GCN-NEXT:    ;DEBUG_VALUE: split_v2f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 64 32] $vgpr2
104; GCN-NEXT:    ;DEBUG_VALUE: split_v2f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
105; GCN-NEXT:    ;DEBUG_VALUE: split_v2f64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
106; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
107; GCN-NEXT:  .Ltmp12:
108; GCN-NEXT:    .loc 0 20 5 prologue_end ; /tmp/dbg.cl:20:5
109; GCN-NEXT:    s_setpc_b64 s[30:31]
110; GCN-NEXT:  .Ltmp13:
111; GCN:         .cfi_endproc
112  call void @llvm.dbg.value(metadata <2 x double> %arg, metadata !59, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !60
113  ret <2 x double> %arg, !dbg !61
114}
115
116define hidden i64 @split_i64_arg(i64 returned %arg) local_unnamed_addr #0 !dbg !62 {
117; GCN-LABEL: split_i64_arg:
118; GCN:       .Lfunc_begin5:
119; GCN-NEXT:    .loc 0 23 0 ; /tmp/dbg.cl:23:0
120; GCN-NEXT:    .cfi_startproc
121; GCN-NEXT:  ; %bb.0:
122; GCN-NEXT:    ;DEBUG_VALUE: split_i64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
123; GCN-NEXT:    ;DEBUG_VALUE: split_i64_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
124; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
125; GCN-NEXT:  .Ltmp14:
126; GCN-NEXT:    .loc 0 24 5 prologue_end ; /tmp/dbg.cl:24:5
127; GCN-NEXT:    s_setpc_b64 s[30:31]
128; GCN-NEXT:  .Ltmp15:
129; GCN:         .cfi_endproc
130  call void @llvm.dbg.value(metadata i64 %arg, metadata !67, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !68
131  ret i64 %arg, !dbg !69
132}
133
134define hidden ptr addrspace(1) @split_ptr_arg(ptr addrspace(1) readnone returned %arg) local_unnamed_addr #0 !dbg !70 {
135; GCN-LABEL: split_ptr_arg:
136; GCN:       .Lfunc_begin6:
137; GCN-NEXT:    .loc 0 27 0 ; /tmp/dbg.cl:27:0
138; GCN-NEXT:    .cfi_startproc
139; GCN-NEXT:  ; %bb.0:
140; GCN-NEXT:    ;DEBUG_VALUE: split_ptr_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 32 32] $vgpr1
141; GCN-NEXT:    ;DEBUG_VALUE: split_ptr_arg:arg <- [DW_OP_constu 1, DW_OP_swap, DW_OP_xderef, DW_OP_LLVM_fragment 0 32] $vgpr0
142; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
143; GCN-NEXT:  .Ltmp16:
144; GCN-NEXT:    .loc 0 28 5 prologue_end ; /tmp/dbg.cl:28:5
145; GCN-NEXT:    s_setpc_b64 s[30:31]
146; GCN-NEXT:  .Ltmp17:
147; GCN:         .cfi_endproc
148  call void @llvm.dbg.value(metadata ptr addrspace(1) %arg, metadata !76, metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !77
149  ret ptr addrspace(1) %arg, !dbg !78
150}
151
152declare void @llvm.dbg.value(metadata, metadata, metadata) #1
153
154attributes #0 = { norecurse nounwind readnone }
155attributes #1 = { nounwind readnone speculatable }
156
157!llvm.dbg.cu = !{!0}
158!llvm.module.flags = !{!3, !4, !5, !6}
159
160!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (trunk 365209) (llvm/trunk 365206)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
161!1 = !DIFile(filename: "/tmp/dbg.cl", directory: "/Users/matt/src/llvm", checksumkind: CSK_MD5, checksum: "0f834f91e91489a5ff6308040ddbd175")
162!2 = !{}
163!3 = !{i32 2, !"Dwarf Version", i32 5}
164!4 = !{i32 2, !"Debug Info Version", i32 3}
165!5 = !{i32 1, !"wchar_size", i32 4}
166!6 = !{i32 7, !"PIC Level", i32 1}
167!7 = distinct !DISubprogram(name: "split_v4f32_arg", scope: !8, file: !8, line: 3, type: !9, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17)
168!8 = !DIFile(filename: "/tmp/dbg.cl", directory: "", checksumkind: CSK_MD5, checksum: "0f834f91e91489a5ff6308040ddbd175")
169!9 = !DISubroutineType(types: !10)
170!10 = !{!11, !11}
171!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "float4", file: !12, line: 107, baseType: !13)
172!12 = !DIFile(filename: "build_debug/lib/clang/9.0.0/include/opencl-c-base.h", directory: "/Users/matt/src/llvm", checksumkind: CSK_MD5, checksum: "9526a66ac52220225f05e11186d7e461")
173!13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !14, size: 128, flags: DIFlagVector, elements: !15)
174!14 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
175!15 = !{!16}
176!16 = !DISubrange(count: 4)
177!17 = !{!18}
178!18 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !8, line: 3, type: !11)
179!19 = !DILocation(line: 0, scope: !7)
180!20 = !DILocation(line: 4, column: 5, scope: !7)
181!21 = distinct !DISubprogram(name: "split_v4f32_multi_arg", scope: !8, file: !8, line: 7, type: !22, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !28)
182!22 = !DISubroutineType(types: !23)
183!23 = !{!11, !11, !24}
184!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "float2", file: !12, line: 105, baseType: !25)
185!25 = !DICompositeType(tag: DW_TAG_array_type, baseType: !14, size: 64, flags: DIFlagVector, elements: !26)
186!26 = !{!27}
187!27 = !DISubrange(count: 2)
188!28 = !{!29, !30}
189!29 = !DILocalVariable(name: "arg0", arg: 1, scope: !21, file: !8, line: 7, type: !11)
190!30 = !DILocalVariable(name: "arg1", arg: 2, scope: !21, file: !8, line: 7, type: !24)
191!31 = !DILocation(line: 0, scope: !21)
192!32 = !DILocation(line: 8, column: 19, scope: !21)
193!33 = !DILocation(line: 8, column: 17, scope: !21)
194!34 = !DILocation(line: 8, column: 5, scope: !21)
195!35 = distinct !DISubprogram(name: "split_v4f16_arg", scope: !8, file: !8, line: 11, type: !36, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !41)
196!36 = !DISubroutineType(types: !37)
197!37 = !{!38, !38}
198!38 = !DIDerivedType(tag: DW_TAG_typedef, name: "half4", file: !12, line: 114, baseType: !39)
199!39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !40, size: 64, flags: DIFlagVector, elements: !15)
200!40 = !DIBasicType(name: "half", size: 16, encoding: DW_ATE_float)
201!41 = !{!42}
202!42 = !DILocalVariable(name: "arg", arg: 1, scope: !35, file: !8, line: 11, type: !38)
203!43 = !DILocation(line: 0, scope: !35)
204!44 = !DILocation(line: 12, column: 5, scope: !35)
205!45 = distinct !DISubprogram(name: "split_f64_arg", scope: !8, file: !8, line: 15, type: !46, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !49)
206!46 = !DISubroutineType(types: !47)
207!47 = !{!48, !48}
208!48 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
209!49 = !{!50}
210!50 = !DILocalVariable(name: "arg", arg: 1, scope: !45, file: !8, line: 15, type: !48)
211!51 = !DILocation(line: 0, scope: !45)
212!52 = !DILocation(line: 16, column: 5, scope: !45)
213!53 = distinct !DISubprogram(name: "split_v2f64_arg", scope: !8, file: !8, line: 19, type: !54, scopeLine: 19, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !58)
214!54 = !DISubroutineType(types: !55)
215!55 = !{!56, !56}
216!56 = !DIDerivedType(tag: DW_TAG_typedef, name: "double2", file: !12, line: 122, baseType: !57)
217!57 = !DICompositeType(tag: DW_TAG_array_type, baseType: !48, size: 128, flags: DIFlagVector, elements: !26)
218!58 = !{!59}
219!59 = !DILocalVariable(name: "arg", arg: 1, scope: !53, file: !8, line: 19, type: !56)
220!60 = !DILocation(line: 0, scope: !53)
221!61 = !DILocation(line: 20, column: 5, scope: !53)
222!62 = distinct !DISubprogram(name: "split_i64_arg", scope: !8, file: !8, line: 23, type: !63, scopeLine: 23, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !66)
223!63 = !DISubroutineType(types: !64)
224!64 = !{!65, !65}
225!65 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
226!66 = !{!67}
227!67 = !DILocalVariable(name: "arg", arg: 1, scope: !62, file: !8, line: 23, type: !65)
228!68 = !DILocation(line: 0, scope: !62)
229!69 = !DILocation(line: 24, column: 5, scope: !62)
230!70 = distinct !DISubprogram(name: "split_ptr_arg", scope: !8, file: !8, line: 27, type: !71, scopeLine: 27, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !75)
231!71 = !DISubroutineType(types: !72)
232!72 = !{!73, !73}
233!73 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !74, size: 64)
234!74 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
235!75 = !{!76}
236!76 = !DILocalVariable(name: "arg", arg: 1, scope: !70, file: !8, line: 27, type: !73)
237!77 = !DILocation(line: 0, scope: !70)
238!78 = !DILocation(line: 28, column: 5, scope: !70)
239