1; REQUIRES: x86
2; RUN: llvm-as %s -o %t.o
3
4; RUN: rm -f %t.yaml
5; RUN: ld.lld --opt-remarks-filename %t.yaml %t.o -o %t -shared -save-temps
6; RUN: llvm-dis %t.0.4.opt.bc -o - | FileCheck %s
7; RUN: ld.lld --opt-remarks-with-hotness --opt-remarks-filename %t.hot.yaml \
8; RUN:  %t.o -o %t -shared
9; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
10; RUN: cat %t.hot.yaml | FileCheck %s -check-prefix=YAML-HOT
11; RUN: ld.lld --opt-remarks-filename %t1.yaml --opt-remarks-passes inline %t.o \
12; RUN: -o /dev/null -shared
13; RUN: cat %t1.yaml | FileCheck %s -check-prefix=YAML-PASSES
14; RUN: ld.lld --opt-remarks-filename %t1.yaml --opt-remarks-format yaml %t.o \
15; RUN: -o /dev/null -shared
16; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
17
18; Check that @tinkywinky is inlined after optimizations.
19; CHECK-LABEL: define i32 @main
20; CHECK-NEXT:  %a.i = {{.*}}call i32 @patatino()
21; CHECK-NEXT:  ret i32 %a.i
22; CHECK-NEXT: }
23
24; YAML:      --- !Passed
25; YAML-NEXT: Pass:            inline
26; YAML-NEXT: Name:            Inlined
27; YAML-NEXT: Function:        main
28; YAML-NEXT: Args:
29; YAML-NEXT:   - Callee:          tinkywinky
30; YAML-NEXT:   - String:          ' inlined into '
31; YAML-NEXT:   - Caller:          main
32; YAML-NEXT:   - String:          ' with '
33; YAML-NEXT:   - String:          '(cost='
34; YAML-NEXT:   - Cost:            '0'
35; YAML-NEXT:   - String:          ', threshold='
36; YAML-NEXT:   - Threshold:       '337'
37; YAML-NEXT:   - String:          ')'
38; YAML-NEXT: ...
39
40; YAML-HOT:      --- !Passed
41; YAML-HOT-NEXT: Pass:            inline
42; YAML-HOT-NEXT: Name:            Inlined
43; YAML-HOT-NEXT: Function:        main
44; YAML-HOT-NEXT: Hotness:         300
45; YAML-HOT-NEXT: Args:
46; YAML-HOT-NEXT:   - Callee:          tinkywinky
47; YAML-HOT-NEXT:   - String:          ' inlined into '
48; YAML-HOT-NEXT:   - Caller:          main
49; YAML-HOT-NEXT:   - String:          ' with '
50; YAML-HOT-NEXT:   - String:          '(cost='
51; YAML-HOT-NEXT:   - Cost:            '0'
52; YAML-HOT-NEXT:   - String:          ', threshold='
53; YAML-HOT-NEXT:   - Threshold:       '337'
54; YAML-HOT-NEXT:   - String:          ')'
55; YAML-HOT-NEXT: ...
56
57; YAML-PASSES: Pass:            inline
58
59target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
60target triple = "x86_64-scei-ps4"
61
62declare i32 @patatino()
63
64define i32 @tinkywinky() {
65  %a = call i32 @patatino()
66  ret i32 %a
67}
68
69define i32 @main() !prof !0 {
70  %i = call i32 @tinkywinky()
71  ret i32 %i
72}
73
74!0 = !{!"function_entry_count", i64 300}
75