Skip to content

Commit 4ed0a55

Browse files
committed
[AnnotationRemarks] Add test for annotation remarks with dbg locations.
The test illustrates that we not pick the debug location from the function directly. This will be fixed in a follow-up patch.
1 parent f22b4c7 commit 4ed0a55

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
; RUN: opt -annotation-remarks -pass-remarks-missed='annotation-remarks' -disable-output -pass-remarks-output=%t.opt.yaml %s
2+
; RUN: FileCheck --input-file=%t.opt.yaml %s
3+
; RUN: opt -passes='annotation-remarks' -pass-remarks-missed='annotation-remarks' -disable-output -pass-remarks-output=%t.opt.yaml %s
4+
; RUN: FileCheck --input-file=%t.opt.yaml %s
5+
6+
; Make sure a suitable location is used for the function start when emitting
7+
; the annotation summary remarks.
8+
9+
; CHECK: --- !Analysis
10+
; CHECK-NEXT: Pass: annotation-remarks
11+
; CHECK-NEXT: Name: AnnotationSummary
12+
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 400, Column: 3 }
13+
; CHECK-NEXT: Function: test1
14+
; CHECK-NEXT: Args:
15+
; CHECK-NEXT: - String: 'Annotated '
16+
; CHECK-NEXT: - count: '4'
17+
; CHECK-NEXT: - String: ' instructions with '
18+
; CHECK-NEXT: - type: _remarks1
19+
; CHECK-NEXT: ...
20+
; CHECK-NEXT: --- !Analysis
21+
; CHECK-NEXT: Pass: annotation-remarks
22+
; CHECK-NEXT: Name: AnnotationSummary
23+
; CHECK-NEXT: DebugLoc: { File: test.c, Line: 400, Column: 3 }
24+
; CHECK-NEXT: Function: test1
25+
; CHECK-NEXT: Args:
26+
; CHECK-NEXT: - String: 'Annotated '
27+
; CHECK-NEXT: - count: '3'
28+
; CHECK-NEXT: - String: ' instructions with '
29+
; CHECK-NEXT: - type: _remarks2
30+
; CHECK-NEXT: ...
31+
; CHECK-NEXT: --- !Analysis
32+
; CHECK-NEXT: Pass: annotation-remarks
33+
; CHECK-NEXT: Name: AnnotationSummary
34+
; CHECK-NEXT: Function: test2
35+
; CHECK-NEXT: Args:
36+
; CHECK-NEXT: - String: 'Annotated '
37+
; CHECK-NEXT: - count: '2'
38+
; CHECK-NEXT: - String: ' instructions with '
39+
; CHECK-NEXT: - type: _remarks1
40+
; CHECK-NEXT: ...
41+
42+
define void @test1(float* %a) !dbg !7 {
43+
entry:
44+
%a.addr = alloca float*, align 8, !dbg !16, !annotation !5
45+
store float* null, float** %a.addr, align 8, !annotation !6
46+
store float* %a, float** %a.addr, align 8, !annotation !5
47+
ret void, !annotation !5
48+
}
49+
50+
define void @test2(float* %a) !dbg !17 {
51+
entry:
52+
%a.addr = alloca float*, align 8, !annotation !6
53+
ret void, !dbg !18, !annotation !6
54+
}
55+
56+
!llvm.dbg.cu = !{!0}
57+
!llvm.module.flags = !{!3, !4}
58+
59+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
60+
!1 = !DIFile(filename: "test.c", directory: "/test")
61+
!2 = !{}
62+
!3 = !{i32 2, !"Dwarf Version", i32 4}
63+
!4 = !{i32 2, !"Debug Info Version", i32 3}
64+
!5 = !{!"_remarks1", !"_remarks2"}
65+
!6 = !{!"_remarks1"}
66+
!7 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 11, type: !8, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
67+
!8 = !DISubroutineType(types: !9)
68+
!9 = !{null, !10, !10, !13}
69+
!10 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !11)
70+
!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32, align: 32)
71+
!12 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
72+
!13 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
73+
!14 = !{!15}
74+
!15 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)
75+
!16 = !DILocation(line: 400, column: 3, scope: !7)
76+
!17 = distinct !DISubprogram(name: "test2", scope: !1, file: !1, line: 21, type: !8, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
77+
!18 = !DILocation(line: 200, column: 3, scope: !17)

0 commit comments

Comments
 (0)