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 with pass remarks to stderr
9; Temporarily skip the next RUN/CHECK to debug bot failures
10; RUN %clang -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
11
12; CHECK tinkywinky inlined into main with cost=0 (threshold=337) (hotness: 300)
13
14; Next try YAML pass remarks file
15; RUN: rm -f %t2.opt.yaml
16; RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -fsave-optimization-record -fdiagnostics-show-hotness -o %t2.o -c
17; RUN: cat %t2.opt.yaml | FileCheck %s -check-prefix=YAML
18
19; YAML: --- !Passed
20; YAML-NEXT: Pass:            inline
21; YAML-NEXT: Name:            Inlined
22; YAML-NEXT: Function:        main
23; YAML-NEXT: Hotness:         300
24; YAML-NEXT: Args:
25; YAML-NEXT:   - Callee:          tinkywinky
26; YAML-NEXT:   - String:          ' inlined into '
27; YAML-NEXT:   - Caller:          main
28; YAML-NEXT:   - String:          ' with cost='
29; YAML-NEXT:   - Cost:            '0'
30; YAML-NEXT:   - String:          ' (threshold='
31; YAML-NEXT:   - Threshold:       '337'
32; YAML-NEXT:   - String:          ')'
33; YAML-NEXT: ...
34
35target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
36target triple = "x86_64-scei-ps4"
37
38declare i32 @patatino()
39
40define i32 @tinkywinky() {
41  %a = call i32 @patatino()
42  ret i32 %a
43}
44
45define i32 @main() !prof !0 {
46  %i = call i32 @tinkywinky()
47  ret i32 %i
48}
49
50!0 = !{!"function_entry_count", i64 300}
51