1; RUN: opt -module-summary %s -o %t1.bc
2; RUN: opt -module-summary %p/Inputs/diagnostic-handler-remarks.ll -o %t2.bc
3
4; Optimization records are collected regardless of the diagnostic handler
5; RUN: rm -f %t.yaml.thin.0.yaml %t.yaml.thin.1.yaml
6; RUN: llvm-lto -thinlto-action=run \
7; RUN:          -lto-pass-remarks-output=%t.yaml \
8; RUN:          -lto-pass-remarks-filter=inline \
9; RUN:          -lto-pass-remarks-format=yaml \
10; RUN:          -exported-symbol _func2 \
11; RUN:          -exported-symbol _main %t1.bc %t2.bc 2>&1 | \
12; RUN:     FileCheck %s -allow-empty
13; CHECK-NOT: remark:
14; CHECK-NOT: llvm-lto:
15
16
17; Verify that bar is imported and inlined into foo
18; RUN: cat %t.yaml.thin.0.yaml | FileCheck %s -check-prefix=YAML1
19; YAML1:      --- !Passed
20; YAML1-NEXT: Pass:            inline
21; YAML1-NEXT: Name:            Inlined
22; YAML1-NEXT: Function:        main
23; YAML1-NEXT: Args:
24; YAML1-NEXT:   - Callee:          foo
25; YAML1-NEXT:   - String:          ' inlined into '
26; YAML1-NEXT:   - Caller:          main
27; YAML1-NEXT:   - String:          ' with '
28; YAML1-NEXT:   - String:          '(cost='
29; YAML1-NEXT:   - Cost:            '-30'
30; YAML1-NEXT:   - String:          ', threshold='
31; YAML1-NEXT:   - Threshold:       '337'
32; YAML1-NEXT:   - String:          ')'
33; YAML1-NEXT: ...
34
35
36; Verify that bar is imported and inlined into foo
37; RUN: cat %t.yaml.thin.1.yaml | FileCheck %s -check-prefix=YAML2
38; YAML2: --- !Passed
39; YAML2-NEXT: Pass:            inline
40; YAML2-NEXT: Name:            Inlined
41; YAML2-NEXT: Function:        foo
42; YAML2-NEXT: Args:
43; YAML2-NEXT:   - Callee:          bar
44; YAML2-NEXT:   - String:          ' inlined into '
45; YAML2-NEXT:   - Caller:          foo
46; YAML2-NEXT:   - String:          ' with '
47; YAML2-NEXT:   - String:          '(cost='
48; YAML2-NEXT:   - Cost:            '-30'
49; YAML2-NEXT:   - String:          ', threshold='
50; YAML2-NEXT:   - Threshold:       '337'
51; YAML2-NEXT:   - String:          ')'
52; YAML2-NEXT: ...
53
54; The file extension depends on the format of the remarks
55; RUN: rm -f %t.bitstream.thin.0.bitstream %t.bitstream.thin.1.bitstream
56; RUN: llvm-lto -thinlto-action=run \
57; RUN:          -lto-pass-remarks-output=%t.bitstream \
58; RUN:          -lto-pass-remarks-filter=inline \
59; RUN:          -lto-pass-remarks-format=bitstream \
60; RUN:          -exported-symbol _func2 \
61; RUN:          -exported-symbol _main %t1.bc %t2.bc 2>&1 | \
62; RUN:     FileCheck %s -allow-empty
63; RUN: llvm-bcanalyzer %t.bitstream.thin.0.bitstream
64; RUN: llvm-bcanalyzer %t.bitstream.thin.1.bitstream
65; CHECK-NOT: remark:
66; CHECK-NOT: llvm-lto:
67
68target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
69target triple = "x86_64-apple-macosx10.11.0"
70
71define i32 @bar() {
72	ret i32 42
73}
74declare i32 @foo()
75define i32 @main() {
76  %i = call i32 @foo()
77  ret i32 %i
78}
79
80