1; Test plugin options for opt-remarks.
2; RUN: llvm-as %s -o %t.o
3; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
4; RUN:	  -plugin-opt=save-temps \
5; RUN:    -plugin-opt=opt-remarks-passes=inline \
6; RUN:    -plugin-opt=opt-remarks-format=yaml \
7; RUN:    -plugin-opt=opt-remarks-filename=%t.yaml %t.o -o %t2.o 2>&1
8; RUN: llvm-dis %t2.o.0.4.opt.bc -o - | FileCheck %s
9; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
10; RUN:    -plugin-opt=opt-remarks-passes=inline \
11; RUN:    -plugin-opt=opt-remarks-format=yaml \
12; RUN:    -plugin-opt=opt-remarks-with-hotness \
13; RUN:	  -plugin-opt=opt-remarks-filename=%t.hot.yaml %t.o -o %t2.o 2>&1
14; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
15; RUN:    -plugin-opt=opt-remarks-passes=inline \
16; RUN:    -plugin-opt=opt-remarks-format=yaml \
17; RUN:    -plugin-opt=opt-remarks-with-hotness \
18; RUN:    -plugin-opt=opt-remarks-hotness-threshold=300 \
19; RUN:	  -plugin-opt=opt-remarks-filename=%t.t300.yaml %t.o -o %t2.o 2>&1
20; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext -shared \
21; RUN:    -plugin-opt=opt-remarks-passes=inline \
22; RUN:    -plugin-opt=opt-remarks-format=yaml \
23; RUN:    -plugin-opt=opt-remarks-with-hotness \
24; RUN:    -plugin-opt=opt-remarks-hotness-threshold=301 \
25; RUN:	  -plugin-opt=opt-remarks-filename=%t.t301.yaml %t.o -o %t2.o 2>&1
26; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
27; RUN: cat %t.hot.yaml | FileCheck %s -check-prefix=YAML-HOT
28; RUN: FileCheck %s -check-prefix=YAML-HOT < %t.t300.yaml
29; RUN: count 0 < %t.t301.yaml
30
31; Check that @f is inlined after optimizations.
32; CHECK-LABEL: define i32 @_start
33; CHECK-NEXT:  %a.i = tail call i32 @bar()
34; CHECK-NEXT:  ret i32 %a.i
35; CHECK-NEXT: }
36
37; YAML: --- !Missed
38; YAML-NEXT: Pass:            inline
39; YAML-NEXT: Name:            NoDefinition
40; YAML-NEXT: Function:        f
41; YAML-NEXT: Args:
42; YAML-NEXT:   - Callee:          bar
43; YAML-NEXT:   - String:          ' will not be inlined into '
44; YAML-NEXT:   - Caller:          f
45; YAML-NEXT:   - String:          ' because its definition is unavailable'
46; YAML-NEXT: ...
47; YAML-NEXT: --- !Passed
48; YAML-NEXT: Pass:            inline
49; YAML-NEXT: Name:            Inlined
50; YAML-NEXT: Function:        _start
51; YAML-NEXT: Args:
52; YAML-NEXT:   - Callee:          f
53; YAML-NEXT:   - String:          ' inlined into '
54; YAML-NEXT:   - Caller:          _start
55; YAML-NEXT:   - String:          ' with '
56; YAML-NEXT:   - String:          '(cost='
57; YAML-NEXT:   - Cost:            '0'
58; YAML-NEXT:   - String:          ', threshold='
59; YAML-NEXT:   - Threshold:       '337'
60; YAML-NEXT:   - String:          ')'
61; YAML-NEXT: ...
62
63; YAML-HOT: --- !Passed
64; YAML-HOT: Pass:            inline
65; YAML-HOT-NEXT: Name:            Inlined
66; YAML-HOT-NEXT: Function:        _start
67; YAML-HOT-NEXT: Hotness:         300
68; YAML-HOT-NEXT: Args:
69; YAML-HOT-NEXT:   - Callee:          f
70; YAML-HOT-NEXT:   - String:          ' inlined into '
71; YAML-HOT-NEXT:   - Caller:          _start
72; YAML-HOT-NEXT:   - String:          ' with '
73; YAML-HOT-NEXT:   - String:          '(cost='
74; YAML-HOT-NEXT:   - Cost:            '0'
75; YAML-HOT-NEXT:   - String:          ', threshold='
76; YAML-HOT-NEXT:   - Threshold:       '337'
77; YAML-HOT-NEXT:   - String:          ')'
78; YAML-HOT-NEXT: ...
79
80target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
81target triple = "x86_64-unknown-linux-gnu"
82
83declare i32 @bar()
84
85define i32 @f() {
86  %a = call i32 @bar()
87  ret i32 %a
88}
89
90define i32 @_start() !prof !0 {
91  %call = call i32 @f()
92  ret i32 %call
93}
94
95!0 = !{!"function_entry_count", i64 300}
96