blob: df7fecbc195727a010e13cd4f641731addb7bcb3 [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
Sam Elliotte604b562017-08-21 16:45:47 +000020; NewPM:
21; RUN: opt < %s -S -passes=inline -pass-remarks-missed=inline \
22; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold 15 \
23; RUN: -pass-remarks-output=%t 2>&1 | FileCheck %s -check-prefix=CHECK_NEW
24; RUN: test ! -s %t
25; RUN: opt < %s -S -passes=inline -pass-remarks-with-hotness -pass-remarks-output=%t
26; RUN: test ! -s %t
27;
28; Verify that remarks that don't meet the hotness threshold are not output.
29; RUN: opt < %s -S -passes=inline -pass-remarks-missed=inline \
30; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold 100 \
31; RUN: -pass-remarks-output=%t.threshold 2>&1 | \
32; RUN: FileCheck -check-prefix=THRESHOLD %s
33; RUN: test ! -s %t.threshold
34; RUN: opt < %s -S -passes=inline \
35; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold 100 \
36; RUN: -pass-remarks-output=%t.threshold
37; The remarks output file should be empty.
38; RUN: test ! -s %t.threshold
39
Adam Nemeta62b7e12016-09-27 20:55:07 +000040; Check the YAML file generated for inliner remarks for this program:
41;
42; 1 int foo();
43; 2 int bar();
44; 3
45; 4 int baz() {
46; 5 return foo() + bar();
47; 6 }
48
Adam Nemet11421472016-09-27 21:58:17 +000049; CHECK: remark: /tmp/s.c:5:10: foo will not be inlined into baz because its definition is unavailable (hotness: 30)
50; 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 +000051
52; YAML: --- !Missed
53; YAML-NEXT: Pass: inline
Adam Nemet11421472016-09-27 21:58:17 +000054; YAML-NEXT: Name: NoDefinition
Adam Nemeta62b7e12016-09-27 20:55:07 +000055; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 5, Column: 10 }
56; YAML-NEXT: Function: baz
57; YAML-NEXT: Hotness: 30
58; YAML-NEXT: Args:
59; YAML-NEXT: - Callee: foo
Adam Nemet0428e932016-10-04 17:05:04 +000060; YAML-NEXT: - String: ' will not be inlined into '
Adam Nemeta62b7e12016-09-27 20:55:07 +000061; YAML-NEXT: - Caller: baz
Adam Nemetb103fc52016-11-07 22:41:13 +000062; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 4, Column: 0 }
Adam Nemet0428e932016-10-04 17:05:04 +000063; YAML-NEXT: - String: ' because its definition is unavailable'
Adam Nemeta62b7e12016-09-27 20:55:07 +000064; YAML-NEXT: ...
65; YAML-NEXT: --- !Missed
66; YAML-NEXT: Pass: inline
Adam Nemet11421472016-09-27 21:58:17 +000067; YAML-NEXT: Name: NoDefinition
Adam Nemeta62b7e12016-09-27 20:55:07 +000068; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 5, Column: 18 }
69; YAML-NEXT: Function: baz
70; YAML-NEXT: Hotness: 30
71; YAML-NEXT: Args:
72; YAML-NEXT: - Callee: bar
Adam Nemet0428e932016-10-04 17:05:04 +000073; YAML-NEXT: - String: ' will not be inlined into '
Adam Nemeta62b7e12016-09-27 20:55:07 +000074; YAML-NEXT: - Caller: baz
Adam Nemetb103fc52016-11-07 22:41:13 +000075; YAML-NEXT: DebugLoc: { File: /tmp/s.c, Line: 4, Column: 0 }
Adam Nemet0428e932016-10-04 17:05:04 +000076; YAML-NEXT: - String: ' because its definition is unavailable'
Adam Nemeta62b7e12016-09-27 20:55:07 +000077; YAML-NEXT: ...
78
Brian Gesiak4ef3daa2017-06-30 23:14:53 +000079; No remarks should be output, since none meet the threshold.
80; THRESHOLD-NOT: remark
81
Sam Elliotte604b562017-08-21 16:45:47 +000082; NewPM does not output this kind of "missed" remark.
83; CHECK_NEW-NOT: remark
84
Adam Nemeta62b7e12016-09-27 20:55:07 +000085; ModuleID = '/tmp/s.c'
86source_filename = "/tmp/s.c"
87target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
88target triple = "x86_64-apple-macosx10.11.0"
89
90; Function Attrs: nounwind ssp uwtable
Adam Nemet7da20c32016-11-10 17:47:03 +000091define i32 @"\01baz"() !dbg !7 !prof !14 {
Adam Nemeta62b7e12016-09-27 20:55:07 +000092entry:
93 %call = call i32 (...) @foo(), !dbg !9
Adam Nemetee5cf032016-10-08 04:47:20 +000094 %call1 = call i32 (...) @"\01bar"(), !dbg !10
Adam Nemeta62b7e12016-09-27 20:55:07 +000095 %add = add nsw i32 %call, %call1, !dbg !12
96 ret i32 %add, !dbg !13
97}
98
99declare i32 @foo(...)
100
Adam Nemetee5cf032016-10-08 04:47:20 +0000101declare i32 @"\01bar"(...)
Adam Nemeta62b7e12016-09-27 20:55:07 +0000102
103!llvm.dbg.cu = !{!0}
104!llvm.module.flags = !{!3, !4, !5}
105!llvm.ident = !{!6}
106
107!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)
108!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
109!2 = !{}
110!3 = !{i32 2, !"Dwarf Version", i32 4}
111!4 = !{i32 2, !"Debug Info Version", i32 3}
112!5 = !{i32 1, !"PIC Level", i32 2}
113!6 = !{!"clang version 4.0.0 (trunk 281293) (llvm/trunk 281290)"}
114!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)
115!8 = !DISubroutineType(types: !2)
116!9 = !DILocation(line: 5, column: 10, scope: !7)
117!10 = !DILocation(line: 5, column: 18, scope: !11)
118!11 = !DILexicalBlockFile(scope: !7, file: !1, discriminator: 1)
119!12 = !DILocation(line: 5, column: 16, scope: !7)
120!13 = !DILocation(line: 5, column: 3, scope: !7)
121!14 = !{!"function_entry_count", i64 30}