1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 < %s | FileCheck %s
3
4%struct.A = type { [100 x i32] }
5
6; The 64-bit pointer argument %arg1 will be split into two registers
7; and for its llvm.dbg.declare, DAG should emit two DBG_VALUE instructions
8; with the fragment expressions.
9define hidden void @ptr_arg_split_subregs(%struct.A* %arg1) #0 !dbg !9 {
10; CHECK-LABEL: ptr_arg_split_subregs:
11; CHECK:       .Lfunc_begin0:
12; CHECK:       .loc 1 5 0 ; example.cpp:5:0
13; CHECK-NEXT:    .cfi_sections .debug_frame
14; CHECK-NEXT:    .cfi_startproc
15; CHECK-NEXT:  ; %bb.0:
16; CHECK-NEXT:    ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 32 32] [$vgpr1+0]
17; CHECK-NEXT:    ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 0 32] [$vgpr0+0]
18; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
19; CHECK-NEXT:    v_mov_b32_e32 v2, 1
20; CHECK-NEXT:  .Ltmp0:
21; CHECK-NEXT:    .loc 1 7 13 prologue_end ; example.cpp:7:13
22; CHECK-NEXT:    flat_store_dword v[0:1], v2 offset:396
23; CHECK-NEXT:    .loc 1 8 5 ; example.cpp:8:5
24; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
25; CHECK-NEXT:    s_setpc_b64 s[30:31]
26; CHECK-NEXT:  .Ltmp1:
27; CHECK:         .cfi_endproc
28  call void @llvm.dbg.declare(metadata %struct.A* %arg1, metadata !20, metadata !DIExpression()), !dbg !21
29  %gep1 = getelementptr inbounds %struct.A, %struct.A* %arg1, i32 0, i32 0, i32 99, !dbg !22
30  store i32 1, i32* %gep1, align 4, !dbg !23
31  ret void, !dbg !24
32}
33
34; FIXME: The 64-bit pointer argument %arg2 will be split between a register and
35; the stack memory. The SelectionDAG though failed to emit the DBG_VALUE for the
36; split part in memory. The two DBG_VALUE instructions emitted in the output pattern
37; are totally misleading. The former represent part of the incoming argument in register
38; while the latter was emitted for the parameter copy to a virtual register inserted
39; at the function entry by DAGBuilder.
40define hidden void @ptr_arg_split_reg_mem(<31 x i32>, %struct.A* %arg2) #0 !dbg !25 {
41; CHECK-LABEL: ptr_arg_split_reg_mem:
42; CHECK:       .Lfunc_begin1:
43; CHECK-NEXT:    .loc 1 10 0 ; example.cpp:10:0
44; CHECK-NEXT:    .cfi_startproc
45; CHECK-NEXT:  ; %bb.0:
46;; NOTE: One dbg_value (DEBUG_VALUE: ptr_arg_split_reg_mem:b <- [$vgpr31+0]) will be considered as
47;; redundant after the virtregrewrite, so it will be removed.
48; CHECK-NEXT:    ;DEBUG_VALUE: ptr_arg_split_reg_mem:b <- [$vgpr31+0]
49; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
50; CHECK-NEXT:    buffer_load_dword v32, off, s[0:3], s32
51; CHECK-NEXT:    v_mov_b32_e32 v0, 1
52; CHECK-NEXT:  .Ltmp2:
53; CHECK-NEXT:    .loc 1 12 13 prologue_end ; example.cpp:12:13
54; CHECK-NEXT:    s_waitcnt vmcnt(0)
55; CHECK-NEXT:    flat_store_dword v[31:32], v0 offset:396
56; CHECK-NEXT:    .loc 1 13 5 ; example.cpp:13:5
57; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
58; CHECK-NEXT:    s_setpc_b64 s[30:31]
59; CHECK-NEXT:  .Ltmp3:
60; CHECK:         .cfi_endproc
61  call void @llvm.dbg.declare(metadata %struct.A* %arg2, metadata !26, metadata !DIExpression()), !dbg !27
62  %gep2 = getelementptr inbounds %struct.A, %struct.A* %arg2, i32 0, i32 0, i32 99, !dbg !28
63  store i32 1, i32* %gep2, align 4, !dbg !29
64  ret void, !dbg !30
65}
66
67; FIXME: The 64-bit pointer argument %arg3 will be entirely in the stack memory.
68; No DBG_VALUE emitted for the incoming argument in this case and it should be fixed.
69define hidden void @ptr_arg_in_memory(<32 x i32>, %struct.A* %arg3) #0 !dbg !31 {
70; CHECK-LABEL: ptr_arg_in_memory:
71; CHECK:       .Lfunc_begin2:
72; CHECK-NEXT:    .loc 1 15 0 ; example.cpp:15:0
73; CHECK-NEXT:    .cfi_startproc
74; CHECK-NEXT:  ; %bb.0:
75; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
76; CHECK-NEXT:    buffer_load_dword v1, off, s[0:3], s32 offset:4
77; CHECK-NEXT:    buffer_load_dword v0, off, s[0:3], s32
78; CHECK-NEXT:    v_mov_b32_e32 v2, 1
79; CHECK-NEXT:  .Ltmp4:
80; CHECK-NEXT:    .loc 1 17 13 prologue_end ; example.cpp:17:13
81; CHECK-NEXT:    s_waitcnt vmcnt(0)
82; CHECK-NEXT:    flat_store_dword v[0:1], v2 offset:396
83; CHECK-NEXT:    .loc 1 18 5 ; example.cpp:18:5
84; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
85; CHECK-NEXT:    s_setpc_b64 s[30:31]
86; CHECK-NEXT:  .Ltmp5:
87; CHECK:         .cfi_endproc
88  call void @llvm.dbg.declare(metadata %struct.A* %arg3, metadata !32, metadata !DIExpression()), !dbg !33
89  %gep3 = getelementptr inbounds %struct.A, %struct.A* %arg3, i32 0, i32 0, i32 99, !dbg !34
90  store i32 1, i32* %gep3, align 4, !dbg !35
91  ret void, !dbg !36
92}
93
94declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
95
96attributes #0 = { nounwind }
97
98!llvm.dbg.cu = !{!0}
99!llvm.module.flags = !{!3, !4, !5, !6, !7}
100!llvm.ident = !{!8}
101
102!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
103!1 = !DIFile(filename: "example.cpp", directory: "temp")
104!2 = !{}
105!3 = !{i32 7, !"Dwarf Version", i32 4}
106!4 = !{i32 2, !"Debug Info Version", i32 3}
107!5 = !{i32 1, !"wchar_size", i32 4}
108!6 = !{i32 7, !"uwtable", i32 1}
109!7 = !{i32 7, !"frame-pointer", i32 2}
110!8 = !{!"clang version 13.0.0"}
111!9 = distinct !DISubprogram(name: "ptr_arg_split_subregs", scope: !10, file: !10, line: 5, type: !11, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
112!10 = !DIFile(filename: "example.cpp", directory: "temp")
113!11 = !DISubroutineType(types: !12)
114!12 = !{!13}
115!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !10, line: 1, size: 3200, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS1A")
116!14 = !{!15}
117!15 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !13, file: !10, line: 2, baseType: !16, size: 3200)
118!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 3200, elements: !18)
119!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
120!18 = !{!19}
121!19 = !DISubrange(count: 100)
122!20 = !DILocalVariable(name: "a", scope: !9, file: !10, line: 6, type: !13)
123!21 = !DILocation(line: 6, column: 7, scope: !9)
124!22 = !DILocation(line: 7, column: 7, scope: !9)
125!23 = !DILocation(line: 7, column: 13, scope: !9)
126!24 = !DILocation(line: 8, column: 5, scope: !9)
127!25 = distinct !DISubprogram(name: "ptr_arg_split_reg_mem", scope: !10, file: !10, line: 10, type: !11, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
128!26 = !DILocalVariable(name: "b", scope: !25, file: !10, line: 11, type: !13)
129!27 = !DILocation(line: 11, column: 7, scope: !25)
130!28 = !DILocation(line: 12, column: 7, scope: !25)
131!29 = !DILocation(line: 12, column: 13, scope: !25)
132!30 = !DILocation(line: 13, column: 5, scope: !25)
133!31 = distinct !DISubprogram(name: "ptr_arg_in_memory", scope: !10, file: !10, line: 15, type: !11, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
134!32 = !DILocalVariable(name: "c", scope: !31, file: !10, line: 16, type: !13)
135!33 = !DILocation(line: 16, column: 7, scope: !31)
136!34 = !DILocation(line: 17, column: 7, scope: !31)
137!35 = !DILocation(line: 17, column: 13, scope: !31)
138!36 = !DILocation(line: 18, column: 5, scope: !31)
139