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