Skip to content

Commit ce22527

Browse files
committed
[AArch64][GlobalISel] Add more specific debug info tests for 613f12d.
As requested, these tests check for specific debug locs on the output of the legalizer. The only one that I couldn't write was for moreElementsVector, which AFAICT we don't trigger on AArch64.
1 parent 8039d2c commit ce22527

File tree

4 files changed

+205
-15
lines changed

4 files changed

+205
-15
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# RUN: llc -mtriple=aarch64-- -run-pass=legalizer -verify-machineinstrs -O0 %s -o - | FileCheck %s
2+
--- |
3+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4+
target triple = "arm64-apple-ios13.0.0"
5+
6+
define void @test_debugloc() {
7+
ret void
8+
}
9+
10+
!llvm.module.flags = !{!0, !1, !2, !3, !4}
11+
!llvm.dbg.cu = !{!5}
12+
!llvm.ident = !{!8}
13+
14+
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
15+
!1 = !{i32 7, !"Dwarf Version", i32 4}
16+
!2 = !{i32 2, !"Debug Info Version", i32 3}
17+
!3 = !{i32 1, !"wchar_size", i32 4}
18+
!4 = !{i32 7, !"PIC Level", i32 2}
19+
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "clang")
20+
!6 = !DIFile(filename: "foo.c", directory: "/")
21+
!7 = !{}
22+
!8 = !{!"clang"}
23+
!9 = distinct !DISubprogram(name: "test_debugloc", scope: !6, file: !6, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5, retainedNodes: !7)
24+
!10 = !DISubroutineType(types: !7)
25+
!11 = !DILocation(line: 4, column: 3, scope: !9)
26+
!12 = !DILocation(line: 5, column: 1, scope: !9)
27+
28+
...
29+
---
30+
name: test_debugloc
31+
alignment: 4
32+
tracksRegLiveness: true
33+
liveins:
34+
- { reg: '$x0' }
35+
- { reg: '$q0' }
36+
body: |
37+
bb.1:
38+
liveins: $q0, $x0
39+
40+
; CHECK-LABEL: name: test_debugloc
41+
; CHECK: liveins: $q0, $x0
42+
; CHECK: [[COPY:%[0-9]+]]:_(<2 x p0>) = COPY $q0
43+
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x0
44+
; CHECK: [[BITCAST:%[0-9]+]]:_(<2 x s64>) = G_BITCAST [[COPY]](<2 x p0>), debug-location !DILocation(line: 4, column: 3
45+
; CHECK: G_STORE [[BITCAST]](<2 x s64>), [[COPY1]](p0), debug-location !DILocation(line: 4, column: 3
46+
; CHECK: RET_ReallyLR debug-location !DILocation(line: 5, column: 1
47+
%0:_(<2 x p0>) = COPY $q0
48+
%1:_(p0) = COPY $x0
49+
G_STORE %0(<2 x p0>), %1(p0), debug-location !11 :: (store 16)
50+
RET_ReallyLR debug-location !12
51+
52+
...
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# RUN: llc -mtriple=aarch64-- -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
2+
--- |
3+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4+
target triple = "arm64-apple-ios13.0.0"
5+
6+
define void @test_memset_debug(i8* %ptr, i32 %c, i32 %len) local_unnamed_addr!dbg !9 {
7+
entry:
8+
%conv = zext i32 %len to i64, !dbg !11
9+
%0 = trunc i32 %c to i8, !dbg !11
10+
call void @llvm.memset.p0i8.i64(i8* align 1 %ptr, i8 %0, i64 %conv, i1 false) #3, !dbg !11
11+
ret void, !dbg !12
12+
}
13+
14+
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #1
15+
attributes #1 = { argmemonly nounwind willreturn writeonly }
16+
17+
!llvm.module.flags = !{!0, !1, !2, !3, !4}
18+
!llvm.dbg.cu = !{!5}
19+
!llvm.ident = !{!8}
20+
21+
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
22+
!1 = !{i32 7, !"Dwarf Version", i32 4}
23+
!2 = !{i32 2, !"Debug Info Version", i32 3}
24+
!3 = !{i32 1, !"wchar_size", i32 4}
25+
!4 = !{i32 7, !"PIC Level", i32 2}
26+
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "clang")
27+
!6 = !DIFile(filename: "foo.c", directory: "/")
28+
!7 = !{}
29+
!8 = !{!"clang"}
30+
!9 = distinct !DISubprogram(name: "test_memset_debug", scope: !6, file: !6, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5, retainedNodes: !7)
31+
!10 = !DISubroutineType(types: !7)
32+
!11 = !DILocation(line: 4, column: 3, scope: !9)
33+
!12 = !DILocation(line: 5, column: 1, scope: !9)
34+
35+
...
36+
---
37+
name: test_memset_debug
38+
alignment: 4
39+
tracksRegLiveness: true
40+
liveins:
41+
- { reg: '$x0' }
42+
- { reg: '$w1' }
43+
- { reg: '$w2' }
44+
body: |
45+
bb.1.entry:
46+
liveins: $w1, $w2, $x0
47+
48+
; We're checking that the BL call has the debug loc of the original intrinsic call.
49+
; CHECK-LABEL: name: test_memset_debug
50+
; CHECK: BL &memset, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0, implicit $w1, implicit $x2, debug-location !11
51+
; CHECK: RET_ReallyLR debug-location !12
52+
%0:_(p0) = COPY $x0
53+
%1:_(s32) = COPY $w1
54+
%2:_(s32) = COPY $w2
55+
%3:_(s64) = G_ZEXT %2(s32), debug-location !11
56+
%4:_(s8) = G_TRUNC %1(s32), debug-location !11
57+
G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.memset), %0(p0), %4(s8), %3(s64), 0, debug-location !11 :: (store 1 into %ir.ptr)
58+
RET_ReallyLR debug-location !12
59+
60+
...
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# RUN: llc -mtriple=aarch64-- -run-pass=legalizer -verify-machineinstrs -O0 %s -o - | FileCheck %s
2+
--- |
3+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4+
target triple = "arm64-apple-ios13.0.0"
5+
6+
define void @test_shl_imm_promote_debug() {
7+
ret void
8+
}
9+
10+
!llvm.module.flags = !{!0, !1, !2, !3, !4}
11+
!llvm.dbg.cu = !{!5}
12+
!llvm.ident = !{!8}
13+
14+
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
15+
!1 = !{i32 7, !"Dwarf Version", i32 4}
16+
!2 = !{i32 2, !"Debug Info Version", i32 3}
17+
!3 = !{i32 1, !"wchar_size", i32 4}
18+
!4 = !{i32 7, !"PIC Level", i32 2}
19+
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "clang")
20+
!6 = !DIFile(filename: "foo.c", directory: "/")
21+
!7 = !{}
22+
!8 = !{!"clang"}
23+
!9 = distinct !DISubprogram(name: "test_shl_imm_promote_debug", scope: !6, file: !6, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5, retainedNodes: !7)
24+
!10 = !DISubroutineType(types: !7)
25+
!11 = !DILocation(line: 4, column: 3, scope: !9)
26+
!12 = !DILocation(line: 5, column: 1, scope: !9)
27+
28+
...
29+
---
30+
name: test_shl_imm_promote_debug
31+
alignment: 4
32+
tracksRegLiveness: true
33+
liveins:
34+
- { reg: '$x0' }
35+
- { reg: '$w1' }
36+
- { reg: '$w2' }
37+
body: |
38+
bb.1:
39+
liveins: $w0, $w1
40+
41+
; Check that the G_LSHR has the right debug loc. This should also check that the G_ZEXT of the constant
42+
; also has the right DL too, but it gets optimized away.
43+
; CHECK-LABEL: name: test_shl_imm_promote_debug
44+
; CHECK: liveins: $w0, $w1
45+
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
46+
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
47+
; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
48+
; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY1]], [[C]](s64), debug-location !DILocation(line: 4, column: 3
49+
; CHECK: $w0 = COPY [[LSHR]](s32)
50+
; CHECK: RET_ReallyLR debug-location !DILocation(line: 5, column: 1
51+
%0:_(p0) = COPY $x0
52+
%1:_(s32) = COPY $w1
53+
%2:_(s32) = G_CONSTANT i32 8
54+
%3:_(s32) = G_LSHR %1(s32), %2(s32), debug-location !11
55+
$w0 = COPY %3(s32)
56+
RET_ReallyLR debug-location !12
57+
58+
...
Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -O0 -run-pass=legalizer --debugify-and-strip-all-safe --debugify-level=locations %s -o - | FileCheck %s
2+
# RUN: llc -O0 -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s
33

44
--- |
55
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
66
target triple = "aarch64--"
77
define void @test_vaarg() { ret void }
8+
9+
10+
!llvm.module.flags = !{!0, !1, !2, !3, !4}
11+
!llvm.dbg.cu = !{!5}
12+
!llvm.ident = !{!8}
13+
14+
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 14, i32 0]}
15+
!1 = !{i32 7, !"Dwarf Version", i32 4}
16+
!2 = !{i32 2, !"Debug Info Version", i32 3}
17+
!3 = !{i32 1, !"wchar_size", i32 4}
18+
!4 = !{i32 7, !"PIC Level", i32 2}
19+
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "clang")
20+
!6 = !DIFile(filename: "foo.c", directory: "/")
21+
!7 = !{}
22+
!8 = !{!"clang"}
23+
!9 = distinct !DISubprogram(name: "test_vaarg", scope: !6, file: !6, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5, retainedNodes: !7)
24+
!10 = !DISubroutineType(types: !7)
25+
!11 = !DILocation(line: 4, column: 3, scope: !9)
26+
!12 = !DILocation(line: 5, column: 1, scope: !9)
27+
828
...
929

1030
---
@@ -13,25 +33,25 @@ body: |
1333
bb.0:
1434
; CHECK-LABEL: name: test_vaarg
1535
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
16-
; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[COPY]](p0) :: (load 8)
36+
; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[COPY]](p0), debug-location !DILocation(line: 4, column: 3, scope: {{.*}}) :: (load 8)
1737
; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 8
18-
; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s64)
19-
; CHECK: G_STORE [[PTR_ADD]](p0), [[COPY]](p0) :: (store 8)
20-
; CHECK: [[LOAD1:%[0-9]+]]:_(p0) = G_LOAD [[COPY]](p0) :: (load 8)
21-
; CHECK: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD1]], [[C]](s64)
22-
; CHECK: G_STORE [[PTR_ADD1]](p0), [[COPY]](p0) :: (store 8)
23-
; CHECK: [[LOAD2:%[0-9]+]]:_(p0) = G_LOAD [[COPY]](p0) :: (load 8)
38+
; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD]], [[C]](s64), debug-location !DILocation(line: 4, column: 3, scope: {{.*}})
39+
; CHECK: G_STORE [[PTR_ADD]](p0), [[COPY]](p0), debug-location !DILocation(line: 4, column: 3, scope: {{.*}}) :: (store 8)
40+
; CHECK: [[LOAD1:%[0-9]+]]:_(p0) = G_LOAD [[COPY]](p0), debug-location !DILocation(line: 5, column: 1, scope: {{.*}}) :: (load 8)
41+
; CHECK: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD1]], [[C]](s64), debug-location !DILocation(line: 5, column: 1, scope: {{.*}})
42+
; CHECK: G_STORE [[PTR_ADD1]](p0), [[COPY]](p0), debug-location !DILocation(line: 5, column: 1, scope: {{.*}}) :: (store 8)
43+
; CHECK: [[LOAD2:%[0-9]+]]:_(p0) = G_LOAD [[COPY]](p0), debug-location !DILocation(line: 4, column: 3, scope: {{.*}}) :: (load 8)
2444
; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
25-
; CHECK: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD2]], [[C1]](s64)
45+
; CHECK: [[PTR_ADD2:%[0-9]+]]:_(p0) = G_PTR_ADD [[LOAD2]], [[C1]](s64), debug-location !DILocation(line: 4, column: 3, scope: {{.*}})
2646
; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
27-
; CHECK: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD2]], [[C2]](s64)
28-
; CHECK: [[PTR_ADD3:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C]](s64)
29-
; CHECK: G_STORE [[PTR_ADD3]](p0), [[COPY]](p0) :: (store 8)
47+
; CHECK: [[PTRMASK:%[0-9]+]]:_(p0) = G_PTRMASK [[PTR_ADD2]], [[C2]](s64), debug-location !DILocation(line: 4, column: 3, scope: {{.*}})
48+
; CHECK: [[PTR_ADD3:%[0-9]+]]:_(p0) = G_PTR_ADD [[PTRMASK]], [[C]](s64), debug-location !DILocation(line: 4, column: 3, scope: {{.*}})
49+
; CHECK: G_STORE [[PTR_ADD3]](p0), [[COPY]](p0), debug-location !DILocation(line: 4, column: 3, scope: {{.*}}) :: (store 8)
3050
%0:_(p0) = COPY $x0
3151
32-
%1:_(s8) = G_VAARG %0(p0), 1
52+
%1:_(s8) = G_VAARG %0(p0), 1, debug-location !11
3353
34-
%2:_(s64) = G_VAARG %0(p0), 8
54+
%2:_(s64) = G_VAARG %0(p0), 8, debug-location !12
3555
36-
%3:_(s64) = G_VAARG %0(p0), 16
56+
%3:_(s64) = G_VAARG %0(p0), 16, debug-location !11
3757
...

0 commit comments

Comments
 (0)