xref: /llvm-project/llvm/test/CodeGen/AArch64/live-debugvalues-sve.mir (revision 5bd01ac822d1d700623790ef146fb78216576616)
1# RUN: llc -start-before=prologepilog -stop-after=livedebugvalues -mattr=+sve -o - %s | FileCheck %s
2#
3# FIXME: re-enable this run line when InstrRef LiveDebugValues is able to
4# rely on the target spill/restore inst recognisers.
5# run: llc -start-before=prologepilog -stop-after=livedebugvalues -experimental-debug-variable-locations -mattr=+sve -o - %s | FileCheck %s
6#
7# Test that the LiveDebugValues pass can correctly handle the address
8# of the SVE spill (at a scalable address location) which is expressed
9# with a complex DIExpression.
10#
11# CHECK: $z2 = ORR_ZZZ killed $z1, $z1
12# CHECK: $z1 = ORR_ZZZ killed $z0, $z0
13# CHECK-DAG: ST1W_IMM renamable $z1, killed renamable $p{{[0-9]+}}, $fp, -[[#%u,OFFSET:]], debug-location !{{[0-9]+}} :: (store unknown-size into %stack.0, align 16)
14# CHECK-DAG: DBG_VALUE $fp, 0, !{{[0-9]+}}, !DIExpression(DW_OP_constu, [[#mul(OFFSET,8)]], DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_minus),
15#
16# TODO: When LiveDebugValues pass supports reloads for AArch64, it should
17# correctly recognize debug-value !27 is in $z1 after the following reload:
18#
19# CHECK: renamable $z1 = LD1W_IMM renamable $p0, $fp, -[[#OFFSET]], debug-location !34 :: (load unknown-size from %stack.0, align 16)
20# CHECK-DAG: ST1W_IMM killed renamable $z3, killed renamable $p0, $fp, -[[#OFFSET]] :: (store unknown-size into %stack.0, align 16)
21# CHECK-DAG: DBG_VALUE $noreg, $noreg, !27, !DIExpression(), debug-location !30
22
23--- |
24  ; ModuleID = 't.c'
25  source_filename = "t.c"
26  target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
27  target triple = "aarch64-unknown-linux-gnu"
28
29  ; Function Attrs: nounwind
30  define dso_local <vscale x 8 x i32> @foo(<vscale x 4 x i32> %z0, <vscale x 4 x i32> %z1, i32 %c) local_unnamed_addr #0 !dbg !11 {
31  entry:
32    call void @llvm.dbg.value(metadata <vscale x 4 x i32> %z0, metadata !27, metadata !DIExpression()), !dbg !30
33    call void @llvm.dbg.value(metadata <vscale x 4 x i32> %z1, metadata !28, metadata !DIExpression()), !dbg !30
34    call void @llvm.dbg.value(metadata i32 %c, metadata !29, metadata !DIExpression()), !dbg !30
35    %tobool.not = icmp eq i32 %c, 0, !dbg !31
36    br i1 %tobool.not, label %if.end, label %if.then, !dbg !33
37
38  if.then:                                          ; preds = %entry
39    %call = call <vscale x 8 x i32> @bar(<vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0, <vscale x 4 x i32> %z0) #0, !dbg !34
40    br label %return, !dbg !35
41
42  if.end:                                           ; preds = %entry
43    %0 = call <vscale x 8 x i32> @llvm.aarch64.sve.tuple.create2.nxv8i32.nxv4i32(<vscale x 4 x i32> %z1, <vscale x 4 x i32> %z0), !dbg !36
44    br label %return, !dbg !37
45
46  return:                                           ; preds = %if.end, %if.then
47    %retval.0 = phi <vscale x 8 x i32> [ %call, %if.then ], [ %0, %if.end ], !dbg !30
48    ret <vscale x 8 x i32> %retval.0, !dbg !38
49  }
50
51  declare !dbg !39 dso_local <vscale x 8 x i32> @bar(<vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>) local_unnamed_addr
52
53  ; Function Attrs: nounwind readonly
54  declare <vscale x 8 x i32> @llvm.aarch64.sve.tuple.create2.nxv8i32.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>)
55
56  ; Function Attrs: nounwind readnone speculatable willreturn
57  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
58
59  attributes #0 = { "frame-pointer"="non-leaf"}
60  attributes #1 = { readnone speculatable willreturn }
61
62  !llvm.dbg.cu = !{!0}
63  !llvm.module.flags = !{!3, !4, !5, !6, !7, !8, !9}
64  !llvm.ident = !{!10}
65
66  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git b19275ba870a06c5ef0428af6264ffd28c7cde9e)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
67  !1 = !DIFile(filename: "t.c", directory: "/tmp/")
68  !2 = !{}
69  !3 = !{i32 7, !"Dwarf Version", i32 4}
70  !4 = !{i32 2, !"Debug Info Version", i32 3}
71  !5 = !{i32 1, !"wchar_size", i32 4}
72  !6 = !{i32 8, !"branch-target-enforcement", i32 0}
73  !7 = !{i32 8, !"sign-return-address", i32 0}
74  !8 = !{i32 8, !"sign-return-address-all", i32 0}
75  !9 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
76  !10 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git b19275ba870a06c5ef0428af6264ffd28c7cde9e)"}
77  !11 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !12, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !26)
78  !12 = !DISubroutineType(types: !13)
79  !13 = !{!14, !21, !21, !18}
80  !14 = !DIDerivedType(tag: DW_TAG_typedef, name: "svint32x2_t", file: !15, line: 59, baseType: !16)
81  !15 = !DIFile(filename: "lib/clang/12.0.0/include/arm_sve.h", directory: "/tmp")
82  !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "__clang_svint32x2_t", file: !1, baseType: !17)
83  !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, flags: DIFlagVector, elements: !19)
84  !18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
85  !19 = !{!20}
86  !20 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 4, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
87  !21 = !DIDerivedType(tag: DW_TAG_typedef, name: "svint32_t", file: !15, line: 34, baseType: !22)
88  !22 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVInt32_t", file: !1, baseType: !23)
89  !23 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, flags: DIFlagVector, elements: !24)
90  !24 = !{!25}
91  !25 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 2, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
92  !26 = !{!27, !28, !29}
93  !27 = !DILocalVariable(name: "z0", arg: 1, scope: !11, file: !1, line: 6, type: !21)
94  !28 = !DILocalVariable(name: "z1", arg: 2, scope: !11, file: !1, line: 6, type: !21)
95  !29 = !DILocalVariable(name: "c", arg: 3, scope: !11, file: !1, line: 6, type: !18)
96  !30 = !DILocation(line: 0, scope: !11)
97  !31 = !DILocation(line: 7, column: 7, scope: !32)
98  !32 = distinct !DILexicalBlock(scope: !11, file: !1, line: 7, column: 7)
99  !33 = !DILocation(line: 7, column: 7, scope: !11)
100  !34 = !DILocation(line: 8, column: 12, scope: !32)
101  !35 = !DILocation(line: 8, column: 5, scope: !32)
102  !36 = !DILocation(line: 9, column: 10, scope: !11)
103  !37 = !DILocation(line: 9, column: 3, scope: !11)
104  !38 = !DILocation(line: 10, column: 1, scope: !11)
105  !39 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !40, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
106  !40 = !DISubroutineType(types: !41)
107  !41 = !{!17, !23, !23, !23, !23, !23, !23, !23, !23, !23}
108
109...
110---
111name:            foo
112alignment:       4
113tracksRegLiveness: true
114liveins:
115  - { reg: '$z0' }
116  - { reg: '$z1' }
117  - { reg: '$w0' }
118frameInfo:
119  maxAlignment:    16
120  adjustsStack:    true
121  hasCalls:        true
122  maxCallFrameSize: 0
123  savePoint:       '%bb.1'
124  restorePoint:    '%bb.1'
125stack:
126  - { id: 0, size: 16, alignment: 16, stack-id: scalable-vector }
127machineFunctionInfo: {}
128body:             |
129  bb.0.entry:
130    successors: %bb.2(0x30000000), %bb.1(0x50000000)
131    liveins: $w0, $z0, $z1
132
133    DBG_VALUE $z0, $noreg, !27, !DIExpression(), debug-location !30
134    DBG_VALUE $z1, $noreg, !28, !DIExpression(), debug-location !30
135    DBG_VALUE $w0, $noreg, !29, !DIExpression(), debug-location !30
136    renamable $z2 = COPY $z1
137    renamable $z1 = COPY $z0
138    DBG_VALUE $w0, $noreg, !29, !DIExpression(), debug-location !30
139    DBG_VALUE $z2, $noreg, !28, !DIExpression(), debug-location !30
140    DBG_VALUE $z1, $noreg, !27, !DIExpression(), debug-location !30
141    CBZW killed renamable $w0, %bb.2, debug-location !33
142    B %bb.1, debug-location !33
143
144  bb.1.if.then:
145    liveins: $z1
146
147    ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp, debug-location !34
148    renamable $p0 = PTRUE_S 31, implicit $vg, debug-location !34
149    $x0 = ADDXri %stack.0, 0, 0, debug-location !34
150    ST1W_IMM renamable $z1, killed renamable $p0, %stack.0, 0, debug-location !34 :: (store unknown-size into %stack.0, align 16)
151    $z0 = COPY renamable $z1, debug-location !34
152    $z2 = COPY renamable $z1, debug-location !34
153    $z3 = COPY renamable $z1, debug-location !34
154    $z4 = COPY renamable $z1, debug-location !34
155    $z5 = COPY renamable $z1, debug-location !34
156    $z6 = COPY renamable $z1, debug-location !34
157    $z7 = COPY renamable $z1, debug-location !34
158    BL @bar, csr_aarch64_sve_aapcs, implicit-def dead $lr, implicit $sp, implicit $z0, implicit $z1, implicit $z2, implicit $z3, implicit $z4, implicit $z5, implicit $z6, implicit $z7, implicit $x0, implicit-def $sp, implicit-def $z0, implicit-def $z1, debug-location !34
159    ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp, debug-location !34
160    renamable $p0 = PTRUE_S 31, implicit $vg, debug-location !34
161    $z3 = IMPLICIT_DEF
162    renamable $z1 = LD1W_IMM renamable $p0, %stack.0, 0, debug-location !34 :: (load unknown-size from %stack.0, align 16)
163    ST1W_IMM renamable $z3, killed renamable $p0, %stack.0, 0 :: (store unknown-size into %stack.0, align 16)
164    renamable $z2 = COPY $z0, debug-location !34
165    B %bb.3, debug-location !35
166
167  bb.2.if.end:
168    liveins: $z1, $z2
169
170
171  bb.3.return:
172    liveins: $z1, $z2
173
174    $z0 = COPY killed renamable $z2, debug-location !38
175    RET_ReallyLR implicit $z0, implicit $z1, debug-location !38
176
177...
178