1; Test to ensure -fdiagnostics-show-hotness and -fsave-optimization-record
2; work when invoking the ThinLTO backend path.
3; REQUIRES: x86-registered-target
4
5; RUN: opt -module-summary -o %t.o %s
6; RUN: llvm-lto -thinlto -o %t %t.o
7
8; First try YAML pass remarks file
9; RUN: rm -f %t2.opt.yaml
10; RUN: %clang -target x86_64-scei-ps4 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -fsave-optimization-record -fdiagnostics-show-hotness -o %t2.o -c
11; RUN: cat %t2.opt.yaml | FileCheck %s -check-prefix=YAML
12
13; YAML: --- !Passed
14; YAML-NEXT: Pass:            inline
15; YAML-NEXT: Name:            Inlined
16; YAML-NEXT: Function:        main
17; YAML-NEXT: Hotness:         300
18; YAML-NEXT: Args:
19; YAML-NEXT:   - Callee:          tinkywinky
20; YAML-NEXT:   - String:          ' inlined into '
21; YAML-NEXT:   - Caller:          main
22; YAML-NEXT:   - String:          ' with cost='
23; YAML-NEXT:   - Cost:            '0'
24; YAML-NEXT:   - String:          ' (threshold='
25; YAML-NEXT:   - Threshold:       '337'
26; YAML-NEXT:   - String:          ')'
27; YAML-NEXT: ...
28
29; Next try with pass remarks to stderr
30; RUN: %clang -target x86_64-scei-ps4 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm -pass-remarks=inline -fdiagnostics-show-hotness -o %t2.o -c 2>&1 | FileCheck %s
31
32; CHECK: tinkywinky inlined into main with cost=0 (threshold=337) (hotness: 300)
33
34target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
35target triple = "x86_64-scei-ps4"
36
37declare i32 @patatino()
38
39define i32 @tinkywinky() {
40  %a = call i32 @patatino()
41  ret i32 %a
42}
43
44define i32 @main() !prof !0 {
45  %i = call i32 @tinkywinky()
46  ret i32 %i
47}
48
49!0 = !{!"function_entry_count", i64 300}
50