blob: 16783634484fb6866b0945a20eb02ab0ccdfde03 [file] [log] [blame]
Brian Gesiak4ef3daa2017-06-30 23:14:53 +00001; RUN: opt < %s -S -inline -pass-remarks-missed=inline \
2; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold 15 \
Adam Nemeta62b7e12016-09-27 20:55:07 +00003; RUN: -pass-remarks-output=%t 2>&1 | FileCheck %s
4; RUN: cat %t | FileCheck -check-prefix=YAML %s
Hal Finkelbdd67352016-10-04 18:13:45 +00005; RUN: opt < %s -S -inline -pass-remarks-with-hotness -pass-remarks-output=%t
6; RUN: cat %t | FileCheck -check-prefix=YAML %s
Brian Gesiak4ef3daa2017-06-30 23:14:53 +00007;
8; Verify that remarks that don't meet the hotness threshold are not output.
9; RUN: opt < %s -S -inline -pass-remarks-missed=inline \
10; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold 100 \
11; RUN: -pass-remarks-output=%t.threshold 2>&1 | \
12; RUN: FileCheck -check-prefix=THRESHOLD %s
13; RUN: test ! -s %t.threshold
14; RUN: opt < %s -S -inline \
15; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold 100 \
16; RUN: -pass-remarks-output=%t.threshold
17; The remarks output file should be empty.
18; RUN: test ! -s %t.threshold
Adam Nemeta62b7e12016-09-27 20:55:07 +000019
20; Check the YAML file generated for inliner remarks for this program:
21;
22; 1 int foo();
23; 2 int bar();
24; 3
25; 4 int baz() {
26; 5 return foo() + bar();
27; 6 }
28
Adam Nemet11421472016-09-27 21:58:17 +000029; CHECK: remark: /tmp/s.c:5:10: foo will not be inlined into baz because its definition is unavailable (hotness: 30)
30; CHECK-NEXT: remark: /tmp/s.c:5:18: bar will not be inlined into baz because its definition is unavailable (hotness: 30)
Adam Nemeta62b7e12016-09-27 20:55:07 +000031
32; YAML: --- !Missed
33; YAML-NEXT: Pass: inline
Adam Nemet11421472016-09-27 21:58:17 +000034; YAML-NEXT: Name: NoDefinition
Adam Nemeta62b7e12016-09-27 20:55:07 +000035; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 5, Column: 10 }
36; YAML-NEXT: Function: baz
37; YAML-NEXT: Hotness: 30
38; YAML-NEXT: Args:
39; YAML-NEXT: - Callee: foo
Adam Nemet0428e932016-10-04 17:05:04 +000040; YAML-NEXT: - String: ' will not be inlined into '
Adam Nemeta62b7e12016-09-27 20:55:07 +000041; YAML-NEXT: - Caller: baz
Adam Nemetb103fc52016-11-07 22:41:13 +000042; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 4, Column: 0 }
Adam Nemet0428e932016-10-04 17:05:04 +000043; YAML-NEXT: - String: ' because its definition is unavailable'
Adam Nemeta62b7e12016-09-27 20:55:07 +000044; YAML-NEXT: ...
45; YAML-NEXT: --- !Missed
46; YAML-NEXT: Pass: inline
Adam Nemet11421472016-09-27 21:58:17 +000047; YAML-NEXT: Name: NoDefinition
Adam Nemeta62b7e12016-09-27 20:55:07 +000048; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 5, Column: 18 }
49; YAML-NEXT: Function: baz
50; YAML-NEXT: Hotness: 30
51; YAML-NEXT: Args:
52; YAML-NEXT: - Callee: bar
Adam Nemet0428e932016-10-04 17:05:04 +000053; YAML-NEXT: - String: ' will not be inlined into '
Adam Nemeta62b7e12016-09-27 20:55:07 +000054; YAML-NEXT: - Caller: baz
Adam Nemetb103fc52016-11-07 22:41:13 +000055; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 4, Column: 0 }
Adam Nemet0428e932016-10-04 17:05:04 +000056; YAML-NEXT: - String: ' because its definition is unavailable'
Adam Nemeta62b7e12016-09-27 20:55:07 +000057; YAML-NEXT: ...
58
Brian Gesiak4ef3daa2017-06-30 23:14:53 +000059; No remarks should be output, since none meet the threshold.
60; THRESHOLD-NOT: remark
61
Adam Nemeta62b7e12016-09-27 20:55:07 +000062; ModuleID = '/tmp/s.c'
63source_filename = "/tmp/s.c"
64target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
65target triple = "x86_64-apple-macosx10.11.0"
66
67; Function Attrs: nounwind ssp uwtable
Adam Nemet7da20c32016-11-10 17:47:03 +000068define i32 @"\01baz"() !dbg !7 !prof !14 {
Adam Nemeta62b7e12016-09-27 20:55:07 +000069entry:
70 %call = call i32 (...) @foo(), !dbg !9
Adam Nemetee5cf032016-10-08 04:47:20 +000071 %call1 = call i32 (...) @"\01bar"(), !dbg !10
Adam Nemeta62b7e12016-09-27 20:55:07 +000072 %add = add nsw i32 %call, %call1, !dbg !12
73 ret i32 %add, !dbg !13
74}
75
76declare i32 @foo(...)
77
Adam Nemetee5cf032016-10-08 04:47:20 +000078declare i32 @"\01bar"(...)
Adam Nemeta62b7e12016-09-27 20:55:07 +000079
80!llvm.dbg.cu = !{!0}
81!llvm.module.flags = !{!3, !4, !5}
82!llvm.ident = !{!6}
83
84!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 281293) (llvm/trunk 281290)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
85!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
86!2 = !{}
87!3 = !{i32 2, !"Dwarf Version", i32 4}
88!4 = !{i32 2, !"Debug Info Version", i32 3}
89!5 = !{i32 1, !"PIC Level", i32 2}
90!6 = !{!"clang version 4.0.0 (trunk 281293) (llvm/trunk 281290)"}
91!7 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: true, unit: !0, variables: !2)
92!8 = !DISubroutineType(types: !2)
93!9 = !DILocation(line: 5, column: 10, scope: !7)
94!10 = !DILocation(line: 5, column: 18, scope: !11)
95!11 = !DILexicalBlockFile(scope: !7, file: !1, discriminator: 1)
96!12 = !DILocation(line: 5, column: 16, scope: !7)
97!13 = !DILocation(line: 5, column: 3, scope: !7)
98!14 = !{!"function_entry_count", i64 30}