xref: /llvm-project/llvm/test/Analysis/CtxProfAnalysis/load.ll (revision b15845c0059b06f406e33f278127d7eb41ff5ab6)
1; REQUIRES: x86_64-linux
2;
3; RUN: rm -rf %t
4; RUN: split-file %s %t
5; RUN: llvm-ctxprof-util fromYAML --input=%t/profile.yaml --output=%t/profile.ctxprofdata
6; RUN: opt -passes='require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \
7; RUN:   %t/example.ll -S 2>&1 | FileCheck %s --check-prefix=NO-CTX
8
9; RUN: not opt -passes='require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \
10; RUN:   -use-ctx-profile=does_not_exist.ctxprofdata %t/example.ll -S 2>&1 | FileCheck %s --check-prefix=NO-FILE
11
12; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' \
13; RUN:   -use-ctx-profile=%t/profile.ctxprofdata %t/example.ll -S -o %t/prelink.ll
14
15; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' -use-ctx-profile=%t/profile.ctxprofdata \
16; RUN:  %t/example.ll -S -o %t/prelink.ll
17; RUN: opt -passes='require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \
18; RUN:   -use-ctx-profile=%t/profile.ctxprofdata %t/prelink.ll -S 2> %t/output.txt
19; RUN: diff %t/expected-profile-output.txt %t/output.txt
20
21; NO-FILE: error: could not open contextual profile file
22; NO-CTX: No contextual profile was provided
23;
24; This is the reference profile, laid out in the format the json formatter will
25; output it from opt.
26;--- profile.yaml
27- Guid: 12341
28  Counters: [9]
29- Guid: 12074870348631550642
30  Counters: [5]
31- Guid: 11872291593386833696
32  Counters: [1]
33  Callsites:  -
34                - Guid: 728453322856651412
35                  Counters: [6, 7]
36;--- expected-profile-output.txt
37Function Info:
384909520559318251808 : an_entrypoint. MaxCounterID: 2. MaxCallsiteID: 1
3911872291593386833696 : foo. MaxCounterID: 1. MaxCallsiteID: 1
4012074870348631550642 : another_entrypoint_no_callees. MaxCounterID: 1. MaxCallsiteID: 0
41
42Current Profile:
43
44- Guid:            11872291593386833696
45  Counters:        [ 1 ]
46  Callsites:
47    - - Guid:            728453322856651412
48        Counters:        [ 6, 7 ]
49- Guid:            12074870348631550642
50  Counters:        [ 5 ]
51
52Flat Profile:
53728453322856651412 : 6 7
5411872291593386833696 : 1
5512074870348631550642 : 5
56;--- example.ll
57declare void @bar()
58
59define private void @foo(i32 %a, ptr %fct) #0 !guid !0 {
60  %t = icmp eq i32 %a, 0
61  br i1 %t, label %yes, label %no
62yes:
63  call void %fct(i32 %a)
64  br label %exit
65no:
66  call void @bar()
67  br label %exit
68exit:
69  ret void
70}
71
72define void @an_entrypoint(i32 %a) {
73  %t = icmp eq i32 %a, 0
74  br i1 %t, label %yes, label %no
75
76yes:
77  call void @foo(i32 1, ptr null)
78  ret void
79no:
80  ret void
81}
82
83define void @another_entrypoint_no_callees(i32 %a) {
84  %t = icmp eq i32 %a, 0
85  br i1 %t, label %yes, label %no
86
87yes:
88  ret void
89no:
90  ret void
91}
92
93attributes #0 = { noinline }
94!0 = !{ i64 11872291593386833696 }