xref: /llvm-project/llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll (revision e5369823bc0655806469724335d0ca5a4c17d8c7)
1; RUN: opt < %s -S -passes=inline -pass-remarks-output=%t -pass-remarks=inline \
2; RUN:    -pass-remarks-missed=inline -pass-remarks-analysis=inline \
3; RUN:    -pass-remarks-with-hotness 2>&1 | FileCheck %s
4; RUN: cat %t | FileCheck -check-prefixes=YAML,YAML-NO-ANNOTATE %s
5
6; RUN: opt < %s -S -passes=inline -pass-remarks-output=%t -pass-remarks=inline \
7; RUN:    -pass-remarks-missed=inline -pass-remarks-analysis=inline \
8; RUN:    -pass-remarks-with-hotness 2>&1 | FileCheck %s
9; RUN: cat %t | FileCheck -check-prefixes=YAML,YAML-NO-ANNOTATE %s
10
11; RUN: opt < %s -S -passes=inliner-wrapper -pass-remarks-output=%t -pass-remarks=inline \
12; RUN:    -pass-remarks-missed=inline -pass-remarks-analysis=inline \
13; RUN:    -annotate-inline-phase=false \
14; RUN:    -pass-remarks-with-hotness 2>&1 | FileCheck %s
15; RUN: cat %t | FileCheck -check-prefixes=YAML,YAML-NO-ANNOTATE %s
16
17; RUN: opt < %s -S -passes=inliner-wrapper -pass-remarks-output=%t -pass-remarks=inline \
18; RUN:    -pass-remarks-missed=inline -pass-remarks-analysis=inline \
19; RUN:    -annotate-inline-phase \
20; RUN:    -pass-remarks-with-hotness 2>&1 | FileCheck %s
21; RUN: cat %t | FileCheck -check-prefixes=YAML,YAML-ANNOTATE %s
22
23; Check the YAML file for inliner-generated passed and analysis remarks.  This
24; is the input:
25
26;  1     int foo() { return 1; }
27;  2
28;  3     int bar() {
29;  4       return foo();
30;  5     }
31
32; CHECK: remark: /tmp/s.c:4:10: 'foo' inlined into 'bar' with (cost={{[0-9\-]+}}, threshold={{[0-9]+}}) at callsite bar:1:10; (hotness: 30)
33
34; YAML:      --- !Passed
35; YAML-NO-ANNOTATE-NEXT: Pass:            inline
36; YAML-ANNOTATE-NEXT: Pass:            main-always-inline
37; YAML-NEXT: Name:            Inlined
38; YAML-NEXT: DebugLoc:        { File: '/tmp/s.c', Line: 4, Column: 10 }
39; YAML-NEXT: Function:        bar
40; YAML-NEXT: Hotness:         30
41; YAML-NEXT: Args:
42; YAML-NEXT:   - String: ''''
43; YAML-NEXT:   - Callee: foo
44; YAML-NEXT:     DebugLoc:        { File: '/tmp/s.c', Line: 1, Column: 0 }
45; YAML-NEXT:   - String: ''' inlined into '''
46; YAML-NEXT:   - Caller: bar
47; YAML-NEXT:     DebugLoc:        { File: '/tmp/s.c', Line: 3, Column: 0 }
48; YAML-NEXT:   - String: ''''
49; YAML-NEXT:   - String: ' with '
50; YAML-NEXT:   - String: '(cost='
51; YAML-NEXT:   - Cost: '{{[0-9\-]+}}'
52; YAML-NEXT:   - String: ', threshold='
53; YAML-NEXT:   - Threshold: '{{[0-9]+}}'
54; YAML-NEXT:   - String: ')'
55; YAML-NEXT:   - String:          ' at callsite '
56; YAML-NEXT:   - String:          bar
57; YAML-NEXT:   - String:          ':'
58; YAML-NEXT:   - Line:            '1'
59; YAML-NEXT:   - String:          ':'
60; YAML-NEXT:   - Column:          '10'
61; YAML-NEXT:   - String:          ';'
62; YAML-NEXT: ...
63
64; ModuleID = '/tmp/s.c'
65source_filename = "/tmp/s.c"
66target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
67target triple = "x86_64-apple-macosx10.11.0"
68
69; Function Attrs: nounwind ssp uwtable
70define i32 @foo() #0 !dbg !7 {
71entry:
72  ret i32 1, !dbg !9
73}
74
75; Function Attrs: nounwind ssp uwtable
76define i32 @bar() #0 !dbg !10 !prof !13 {
77entry:
78  %call = call i32 @foo(), !dbg !11
79  ret i32 %call, !dbg !12
80}
81
82attributes #0 = { nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="core2" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
83
84!llvm.dbg.cu = !{!0}
85!llvm.module.flags = !{!3, !4, !5}
86!llvm.ident = !{!6}
87
88!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
89!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
90!2 = !{}
91!3 = !{i32 2, !"Dwarf Version", i32 4}
92!4 = !{i32 2, !"Debug Info Version", i32 3}
93!5 = !{i32 1, !"PIC Level", i32 2}
94!6 = !{!"clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)"}
95!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !2)
96!8 = !DISubroutineType(types: !2)
97!9 = !DILocation(line: 1, column: 13, scope: !7)
98!10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, retainedNodes: !2)
99!11 = !DILocation(line: 4, column: 10, scope: !10)
100!12 = !DILocation(line: 4, column: 3, scope: !10)
101!13 = !{!"function_entry_count", i64 30}
102