xref: /llvm-project/llvm/test/CodeGen/AArch64/debug-info-sve-dbg-declare.mir (revision 5bd01ac822d1d700623790ef146fb78216576616)
1# RUN: llc -o %t -filetype=obj -start-before=prologepilog %s
2# RUN: llvm-dwarfdump --name="z0" %t | FileCheck %s --check-prefix=CHECKZ0
3# RUN: llvm-dwarfdump --name="z1" %t | FileCheck %s --check-prefix=CHECKZ1
4# RUN: llvm-dwarfdump --name="p0" %t | FileCheck %s --check-prefix=CHECKP0
5# RUN: llvm-dwarfdump --name="p1" %t | FileCheck %s --check-prefix=CHECKP1
6# RUN: llvm-dwarfdump --name="localv0" %t | FileCheck %s --check-prefix=CHECKLV0
7# RUN: llvm-dwarfdump --name="localv1" %t | FileCheck %s --check-prefix=CHECKLV1
8# RUN: llvm-dwarfdump --name="localp0" %t | FileCheck %s --check-prefix=CHECKLP0
9# RUN: llvm-dwarfdump --name="localp1" %t | FileCheck %s --check-prefix=CHECKLP1
10#
11# CHECKZ0:       DW_AT_location    (DW_OP_fbreg +0, DW_OP_lit8, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
12# CHECKZ0-NEXT:  DW_AT_name        ("z0")
13# CHECKZ1:       DW_AT_location    (DW_OP_fbreg +0, DW_OP_lit16, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
14# CHECKZ1-NEXT:  DW_AT_name        ("z1")
15# CHECKP0:       DW_AT_location    (DW_OP_fbreg +0, DW_OP_lit17, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
16# CHECKP0-NEXT:  DW_AT_name        ("p0")
17# CHECKP1:       DW_AT_location    (DW_OP_fbreg +0, DW_OP_lit18, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
18# CHECKP1-NEXT:  DW_AT_name        ("p1")
19# CHECKLV0:      DW_AT_location    (DW_OP_fbreg +0, DW_OP_constu 0x20, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
20# CHECKLV0-NEXT: DW_AT_name        ("localv0")
21# CHECKLV1:      DW_AT_location    (DW_OP_fbreg +0, DW_OP_constu 0x28, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
22# CHECKLV1-NEXT: DW_AT_name        ("localv1")
23# CHECKLP0:      DW_AT_location    (DW_OP_fbreg +0, DW_OP_constu 0x29, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
24# CHECKLP0-NEXT: DW_AT_name        ("localp0")
25# CHECKLP1:      DW_AT_location    (DW_OP_fbreg +0, DW_OP_constu 0x2a, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_minus)
26# CHECKLP1-NEXT: DW_AT_name        ("localp1")
27--- |
28  ; ModuleID = 't.c'
29  source_filename = "t.c"
30  target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
31  target triple = "aarch64-unknown-linux-gnu"
32
33  ; Function Attrs: noinline nounwind optnone
34  define dso_local <vscale x 4 x i32> @foo(<vscale x 4 x i32> %z0, <vscale x 4 x i32> %z1, <vscale x 16 x i1> %p0, <vscale x 16 x i1> %p1, i32 %w0) #0 !dbg !11 {
35  entry:
36    %z0.addr = alloca <vscale x 4 x i32>, align 16
37    %z1.addr = alloca <vscale x 4 x i32>, align 16
38    %p0.addr = alloca <vscale x 16 x i1>, align 2
39    %p1.addr = alloca <vscale x 16 x i1>, align 2
40    %w0.addr = alloca i32, align 4
41    %local_gpr0 = alloca i32, align 4
42    %localv0 = alloca <vscale x 4 x i32>, align 16
43    %localv1 = alloca <vscale x 4 x i32>, align 16
44    %localp0 = alloca <vscale x 16 x i1>, align 2
45    %localp1 = alloca <vscale x 16 x i1>, align 2
46    store <vscale x 4 x i32> %z0, ptr %z0.addr, align 16
47    call void @llvm.dbg.declare(metadata ptr %z0.addr, metadata !29, metadata !DIExpression()), !dbg !30
48    store <vscale x 4 x i32> %z1, ptr %z1.addr, align 16
49    call void @llvm.dbg.declare(metadata ptr %z1.addr, metadata !31, metadata !DIExpression()), !dbg !32
50    store <vscale x 16 x i1> %p0, ptr %p0.addr, align 2
51    call void @llvm.dbg.declare(metadata ptr %p0.addr, metadata !33, metadata !DIExpression()), !dbg !34
52    store <vscale x 16 x i1> %p1, ptr %p1.addr, align 2
53    call void @llvm.dbg.declare(metadata ptr %p1.addr, metadata !35, metadata !DIExpression()), !dbg !36
54    store i32 %w0, ptr %w0.addr, align 4
55    call void @llvm.dbg.declare(metadata ptr %w0.addr, metadata !37, metadata !DIExpression()), !dbg !38
56    call void @llvm.dbg.declare(metadata ptr %local_gpr0, metadata !39, metadata !DIExpression()), !dbg !40
57    %0 = load i32, ptr %w0.addr, align 4, !dbg !41
58    store i32 %0, ptr %local_gpr0, align 4, !dbg !40
59    call void @llvm.dbg.declare(metadata ptr %localv0, metadata !42, metadata !DIExpression()), !dbg !43
60    %1 = load <vscale x 4 x i32>, ptr %z0.addr, align 16, !dbg !44
61    store <vscale x 4 x i32> %1, ptr %localv0, align 16, !dbg !43
62    call void @llvm.dbg.declare(metadata ptr %localv1, metadata !45, metadata !DIExpression()), !dbg !46
63    %2 = load <vscale x 4 x i32>, ptr %z1.addr, align 16, !dbg !47
64    store <vscale x 4 x i32> %2, ptr %localv1, align 16, !dbg !46
65    call void @llvm.dbg.declare(metadata ptr %localp0, metadata !48, metadata !DIExpression()), !dbg !49
66    %3 = load <vscale x 16 x i1>, ptr %p0.addr, align 2, !dbg !50
67    store <vscale x 16 x i1> %3, ptr %localp0, align 2, !dbg !49
68    call void @llvm.dbg.declare(metadata ptr %localp1, metadata !51, metadata !DIExpression()), !dbg !52
69    %4 = load <vscale x 16 x i1>, ptr %p1.addr, align 2, !dbg !53
70    store <vscale x 16 x i1> %4, ptr %localp1, align 2, !dbg !52
71    %call = call <vscale x 4 x i32> @bar(ptr %local_gpr0, ptr %localv0, ptr %localv1, ptr %localp0, ptr %localp1), !dbg !54
72    ret <vscale x 4 x i32> %call, !dbg !55
73  }
74
75  ; Function Attrs: nounwind readnone speculatable willreturn
76  declare void @llvm.dbg.declare(metadata, metadata, metadata)
77
78  declare dso_local <vscale x 4 x i32> @bar(ptr, ptr, ptr, ptr, ptr)
79
80  attributes #0 = { "frame-pointer"="non-leaf" "target-features"="+neon,+sve" }
81
82  !llvm.dbg.cu = !{!0}
83  !llvm.module.flags = !{!3, !4, !5, !6, !7, !8, !9}
84  !llvm.ident = !{!10}
85
86  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git b19275ba870a06c5ef0428af6264ffd28c7cde9e)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
87  !1 = !DIFile(filename: "t.c", directory: "/tmp/")
88  !2 = !{}
89  !3 = !{i32 7, !"Dwarf Version", i32 4}
90  !4 = !{i32 2, !"Debug Info Version", i32 3}
91  !5 = !{i32 1, !"wchar_size", i32 4}
92  !6 = !{i32 8, !"branch-target-enforcement", i32 0}
93  !7 = !{i32 8, !"sign-return-address", i32 0}
94  !8 = !{i32 8, !"sign-return-address-all", i32 0}
95  !9 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
96  !10 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git b19275ba870a06c5ef0428af6264ffd28c7cde9e)"}
97  !11 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !12, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
98  !12 = !DISubroutineType(types: !13)
99  !13 = !{!14, !14, !14, !21, !21, !27}
100  !15 = !DIFile(filename: "lib/clang/12.0.0/include/arm_sve.h", directory: "/tmp")
101  !14 = !DIDerivedType(tag: DW_TAG_typedef, name: "svint32_t", file: !15, line: 34, baseType: !16)
102  !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVInt32_t", file: !1, baseType: !17)
103  !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, flags: DIFlagVector, elements: !19)
104  !18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
105  !19 = !{!20}
106  !20 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 2, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
107  !21 = !DIDerivedType(tag: DW_TAG_typedef, name: "svbool_t", file: !15, line: 90, baseType: !22)
108  !22 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVBool_t", file: !1, baseType: !23)
109  !23 = !DICompositeType(tag: DW_TAG_array_type, baseType: !24, flags: DIFlagVector, elements: !25)
110  !24 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
111  !25 = !{!26}
112  !26 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
113  !27 = !DIDerivedType(tag: DW_TAG_typedef, name: "int32_t", file: !28, line: 38, baseType: !18)
114  !28 = !DIFile(filename: "/usr/include/stdint.h", directory: "")
115  !29 = !DILocalVariable(name: "z0", arg: 1, scope: !11, file: !1, line: 4, type: !14)
116  !30 = !DILocation(line: 4, column: 25, scope: !11)
117  !31 = !DILocalVariable(name: "z1", arg: 2, scope: !11, file: !1, line: 4, type: !14)
118  !32 = !DILocation(line: 4, column: 39, scope: !11)
119  !33 = !DILocalVariable(name: "p0", arg: 3, scope: !11, file: !1, line: 4, type: !21)
120  !34 = !DILocation(line: 4, column: 52, scope: !11)
121  !35 = !DILocalVariable(name: "p1", arg: 4, scope: !11, file: !1, line: 4, type: !21)
122  !36 = !DILocation(line: 4, column: 65, scope: !11)
123  !37 = !DILocalVariable(name: "w0", arg: 5, scope: !11, file: !1, line: 4, type: !27)
124  !38 = !DILocation(line: 4, column: 77, scope: !11)
125  !39 = !DILocalVariable(name: "local_gpr0", scope: !11, file: !1, line: 5, type: !27)
126  !40 = !DILocation(line: 5, column: 11, scope: !11)
127  !41 = !DILocation(line: 5, column: 24, scope: !11)
128  !42 = !DILocalVariable(name: "localv0", scope: !11, file: !1, line: 6, type: !14)
129  !43 = !DILocation(line: 6, column: 13, scope: !11)
130  !44 = !DILocation(line: 6, column: 23, scope: !11)
131  !45 = !DILocalVariable(name: "localv1", scope: !11, file: !1, line: 7, type: !14)
132  !46 = !DILocation(line: 7, column: 13, scope: !11)
133  !47 = !DILocation(line: 7, column: 23, scope: !11)
134  !48 = !DILocalVariable(name: "localp0", scope: !11, file: !1, line: 8, type: !21)
135  !49 = !DILocation(line: 8, column: 12, scope: !11)
136  !50 = !DILocation(line: 8, column: 22, scope: !11)
137  !51 = !DILocalVariable(name: "localp1", scope: !11, file: !1, line: 9, type: !21)
138  !52 = !DILocation(line: 9, column: 12, scope: !11)
139  !53 = !DILocation(line: 9, column: 22, scope: !11)
140  !54 = !DILocation(line: 10, column: 10, scope: !11)
141  !55 = !DILocation(line: 10, column: 3, scope: !11)
142
143...
144---
145name:            foo
146alignment:       4
147tracksRegLiveness: true
148liveins:
149  - { reg: '$z0' }
150  - { reg: '$z1' }
151  - { reg: '$p0' }
152  - { reg: '$p1' }
153  - { reg: '$w0' }
154frameInfo:
155  maxAlignment:    16
156  adjustsStack:    true
157  hasCalls:        true
158  maxCallFrameSize: 0
159  localFrameSize:  8
160stack:
161  - { id: 0, name: z0.addr, size: 16, alignment: 16, stack-id: scalable-vector,
162      debug-info-variable: '!29', debug-info-expression: '!DIExpression()',
163      debug-info-location: '!30' }
164  - { id: 1, name: z1.addr, size: 16, alignment: 16, stack-id: scalable-vector,
165      debug-info-variable: '!31', debug-info-expression: '!DIExpression()',
166      debug-info-location: '!32' }
167  - { id: 2, name: p0.addr, size: 2, alignment: 2, stack-id: scalable-vector,
168      debug-info-variable: '!33', debug-info-expression: '!DIExpression()',
169      debug-info-location: '!34' }
170  - { id: 3, name: p1.addr, size: 2, alignment: 2, stack-id: scalable-vector,
171      debug-info-variable: '!35', debug-info-expression: '!DIExpression()',
172      debug-info-location: '!36' }
173  - { id: 4, name: w0.addr, size: 4, alignment: 4, local-offset: -4, debug-info-variable: '!37',
174      debug-info-expression: '!DIExpression()', debug-info-location: '!38' }
175  - { id: 5, name: local_gpr0, size: 4, alignment: 4, local-offset: -8,
176      debug-info-variable: '!39', debug-info-expression: '!DIExpression()',
177      debug-info-location: '!40' }
178  - { id: 6, name: localv0, size: 16, alignment: 16, stack-id: scalable-vector,
179      debug-info-variable: '!42', debug-info-expression: '!DIExpression()',
180      debug-info-location: '!43' }
181  - { id: 7, name: localv1, size: 16, alignment: 16, stack-id: scalable-vector,
182      debug-info-variable: '!45', debug-info-expression: '!DIExpression()',
183      debug-info-location: '!46' }
184  - { id: 8, name: localp0, size: 2, alignment: 2, stack-id: scalable-vector,
185      debug-info-variable: '!48', debug-info-expression: '!DIExpression()',
186      debug-info-location: '!49' }
187  - { id: 9, name: localp1, size: 2, alignment: 2, stack-id: scalable-vector,
188      debug-info-variable: '!51', debug-info-expression: '!DIExpression()',
189      debug-info-location: '!52' }
190machineFunctionInfo: {}
191body:             |
192  bb.0.entry:
193    liveins: $z0, $z1, $p0, $p1, $w0
194
195    renamable $p2 = COPY killed $p0
196    renamable $p0 = PTRUE_S 31, implicit $vg
197    ST1W_IMM killed renamable $z0, renamable $p0, %stack.0.z0.addr, 0 :: (store unknown-size into %ir.z0.addr, align 16)
198    ST1W_IMM killed renamable $z1, renamable $p0, %stack.1.z1.addr, 0 :: (store unknown-size into %ir.z1.addr, align 16)
199    STR_PXI killed renamable $p2, %stack.2.p0.addr, 0 :: (store unknown-size into %ir.p0.addr, align 2)
200    STR_PXI killed renamable $p1, %stack.3.p1.addr, 0 :: (store unknown-size into %ir.p1.addr, align 2)
201    STRWui killed renamable $w0, %stack.4.w0.addr, 0 :: (store (s32) into %ir.w0.addr)
202    renamable $w8 = LDRWui %stack.4.w0.addr, 0, debug-location !41 :: (dereferenceable load (s32) from %ir.w0.addr)
203    STRWui killed renamable $w8, %stack.5.local_gpr0, 0, debug-location !40 :: (store (s32) into %ir.local_gpr0)
204    renamable $z0 = LD1W_IMM renamable $p0, %stack.0.z0.addr, 0, debug-location !44 :: (load unknown-size from %ir.z0.addr, align 16)
205    ST1W_IMM killed renamable $z0, renamable $p0, %stack.6.localv0, 0, debug-location !43 :: (store unknown-size into %ir.localv0, align 16)
206    renamable $z0 = LD1W_IMM renamable $p0, %stack.1.z1.addr, 0, debug-location !47 :: (load unknown-size from %ir.z1.addr, align 16)
207    ST1W_IMM killed renamable $z0, killed renamable $p0, %stack.7.localv1, 0, debug-location !46 :: (store unknown-size into %ir.localv1, align 16)
208    renamable $p0 = LDR_PXI %stack.2.p0.addr, 0, debug-location !50 :: (load unknown-size from %ir.p0.addr, align 2)
209    STR_PXI killed renamable $p0, %stack.8.localp0, 0, debug-location !49 :: (store unknown-size into %ir.localp0, align 2)
210    renamable $p0 = LDR_PXI %stack.3.p1.addr, 0, debug-location !53 :: (load unknown-size from %ir.p1.addr, align 2)
211    STR_PXI killed renamable $p0, %stack.9.localp1, 0, debug-location !52 :: (store unknown-size into %ir.localp1, align 2)
212    ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp, debug-location !54
213    renamable $x0 = ADDXri %stack.5.local_gpr0, 0, 0
214    renamable $x1 = ADDXri %stack.6.localv0, 0, 0
215    renamable $x2 = ADDXri %stack.7.localv1, 0, 0
216    renamable $x3 = ADDXri %stack.8.localp0, 0, 0
217    renamable $x4 = ADDXri %stack.9.localp1, 0, 0
218    BL @bar, csr_aarch64_sve_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $x0, implicit killed $x1, implicit killed $x2, implicit killed $x3, implicit killed $x4, implicit-def $sp, implicit-def $z0, debug-location !54
219    ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp, debug-location !54
220    RET_ReallyLR implicit killed $z0, debug-location !55
221
222...
223