|
4 | 4 | ; RUN: split-file %s %t |
5 | 5 | ; RUN: llvm-ctxprof-util fromYAML --input=%t/profile.yaml --output=%t/profile.ctxprofdata |
6 | 6 | ; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' -use-ctx-profile=%t/profile.ctxprofdata \ |
7 | | -; RUN: %t/example.ll -S -o %t/prelink.ll |
8 | | -; RUN: FileCheck --input-file %t/prelink.ll %s --check-prefix=PRELINK |
9 | | -; RUN: opt -passes='ctx-prof-flatten' -use-ctx-profile=%t/profile.ctxprofdata %t/prelink.ll -S | FileCheck %s |
| 7 | +; RUN: %t/example.ll -S -o %t/4909520559318251808.ll |
| 8 | +; RUN: FileCheck --input-file %t/4909520559318251808.ll %s --check-prefix=PRELINK |
| 9 | + |
| 10 | +; RUN: opt -passes='ctx-prof-flatten' -use-ctx-profile=%t/profile.ctxprofdata %t/4909520559318251808.ll -S | FileCheck %s --check-prefix=POSTLINK |
10 | 11 | ; |
11 | 12 | ; |
12 | 13 | ; Check that instrumentation occurs where expected: the "no" block for both foo and |
|
18 | 19 | ; PRELINK-NEXT: call void @llvm.instrprof.increment(ptr @foo, i64 [[#]], i32 2, i32 1) |
19 | 20 |
|
20 | 21 | ; PRELINK-LABEL: @an_entrypoint |
| 22 | +; PRELINK: br i1 %t, label %yes, label %common.ret, !prof ![[PREPROF:[0-9]+]] |
21 | 23 | ; PRELINK-LABEL: yes: |
22 | 24 | ; PRELINK-NEXT: call void @llvm.instrprof.increment(ptr @an_entrypoint, i64 [[#]], i32 2, i32 1) |
23 | | -; PRELINK-NOT: "ProfileSummary" |
| 25 | +; PRELINK: ![[#]] = !{i32 1, !"ProfileSummary", !1} |
| 26 | +; PRELINK: ![[#]] = !{!"TotalCount", i64 3595} |
| 27 | +; PRELINK: ![[#]] = !{!"MaxCount", i64 3000} |
| 28 | +; PRELINK: ![[#]] = !{!"MaxInternalCount", i64 3000} |
| 29 | +; PRELINK: ![[#]] = !{!"MaxFunctionCount", i64 300} |
| 30 | +; PRELINK: ![[#]] = !{!"NumCounts", i64 6} |
| 31 | +; PRELINK: ![[#]] = !{!"NumFunctions", i64 3} |
| 32 | +; PRELINK: ![[PREPROF]] = !{!"branch_weights", i32 40, i32 60} |
24 | 33 |
|
25 | 34 | ; Check that the output has: |
26 | 35 | ; - no instrumentation |
27 | 36 | ; - the 2 functions have an entry count |
28 | 37 | ; - each conditional branch has profile annotation |
29 | 38 | ; |
30 | | -; CHECK-NOT: call void @llvm.instrprof |
| 39 | +; POSTLINK-NOT: call void @llvm.instrprof |
31 | 40 | ; |
32 | 41 | ; make sure we have function entry counts, branch weights, and a profile summary. |
33 | | -; CHECK-LABEL: @foo |
34 | | -; CHECK-SAME: !prof ![[FOO_EP:[0-9]+]] |
35 | | -; CHECK: br i1 %t, label %yes, label %no, !prof ![[FOO_BW:[0-9]+]] |
36 | | -; CHECK-LABEL: @an_entrypoint |
37 | | -; CHECK-SAME: !prof ![[AN_ENTRYPOINT_EP:[0-9]+]] |
38 | | -; CHECK: br i1 %t, label %yes, label %common.ret, !prof ![[AN_ENTRYPOINT_BW:[0-9]+]] |
| 42 | +; POSTLINK-LABEL: @foo |
| 43 | +; POSTLINK-SAME: !prof ![[FOO_EP:[0-9]+]] |
| 44 | +; POSTLINK: br i1 %t, label %yes, label %no, !prof ![[FOO_BW:[0-9]+]] |
| 45 | +; POSTLINK-LABEL: @an_entrypoint |
| 46 | +; POSTLINK-SAME: !prof ![[AN_ENTRYPOINT_EP:[0-9]+]] |
| 47 | +; POSTLINK: br i1 %t, label %yes, label %common.ret, !prof ![[AN_ENTRYPOINT_BW:[0-9]+]] |
39 | 48 |
|
| 49 | +; The postlink summary is restricted to the stuff under the root - including the |
| 50 | +; "unhandled" data. |
| 51 | +; POSTLINK: ![[#]] = !{i32 1, !"ProfileSummary", !1} |
| 52 | +; POSTLINK: ![[#]] = !{!"TotalCount", i64 1495} |
| 53 | +; POSTLINK: ![[#]] = !{!"MaxCount", i64 1000} |
| 54 | +; POSTLINK: ![[#]] = !{!"MaxInternalCount", i64 1000} |
| 55 | +; POSTLINK: ![[#]] = !{!"MaxFunctionCount", i64 200} |
| 56 | +; POSTLINK: ![[#]] = !{!"NumCounts", i64 6} |
| 57 | +; POSTLINK: ![[#]] = !{!"NumFunctions", i64 3} |
40 | 58 |
|
41 | | -; CHECK: ![[#]] = !{i32 1, !"ProfileSummary", !1} |
42 | | -; CHECK: ![[#]] = !{!"TotalCount", i64 480} |
43 | | -; CHECK: ![[#]] = !{!"MaxCount", i64 140} |
44 | | -; CHECK: ![[#]] = !{!"MaxInternalCount", i64 125} |
45 | | -; CHECK: ![[#]] = !{!"MaxFunctionCount", i64 140} |
46 | | -; CHECK: ![[#]] = !{!"NumCounts", i64 6} |
47 | | -; CHECK: ![[#]] = !{!"NumFunctions", i64 2} |
48 | 59 | ; |
49 | 60 | ; @foo will be called both unconditionally and conditionally, on the "yes" branch |
50 | 61 | ; which has a count of 40. So 140 times. |
51 | 62 |
|
52 | | -; CHECK: ![[FOO_EP]] = !{!"function_entry_count", i64 140} |
| 63 | +; POSTLINK: ![[FOO_EP]] = !{!"function_entry_count", i64 140} |
53 | 64 |
|
54 | 65 | ; foo's "no" branch is taken 10+5 times (from the 2 contexts belonging to foo). |
55 | 66 | ; Which means its "yes" branch is taken 140 - 15 times. |
56 | 67 |
|
57 | | -; CHECK: ![[FOO_BW]] = !{!"branch_weights", i32 125, i32 15} |
58 | | -; CHECK: ![[AN_ENTRYPOINT_EP]] = !{!"function_entry_count", i64 100} |
59 | | -; CHECK: ![[AN_ENTRYPOINT_BW]] = !{!"branch_weights", i32 40, i32 60} |
| 68 | +; POSTLINK: ![[FOO_BW]] = !{!"branch_weights", i32 125, i32 15} |
| 69 | +; POSTLINK: ![[AN_ENTRYPOINT_EP]] = !{!"function_entry_count", i64 100} |
| 70 | +; POSTLINK: ![[AN_ENTRYPOINT_BW]] = !{!"branch_weights", i32 40, i32 60} |
60 | 71 |
|
61 | 72 | ;--- profile.yaml |
62 | 73 | Contexts: |
63 | 74 | - Guid: 4909520559318251808 |
64 | 75 | TotalRootEntryCount: 100 |
| 76 | + Unhandled: |
| 77 | + - Guid: 1234 |
| 78 | + Counters: [200, 1000] |
65 | 79 | Counters: [100, 40] |
66 | 80 | Callsites: - |
67 | 81 | - Guid: 11872291593386833696 |
68 | 82 | Counters: [ 100, 5 ] |
69 | 83 | - |
70 | 84 | - Guid: 11872291593386833696 |
71 | 85 | Counters: [ 40, 10 ] |
| 86 | +FlatProfiles: |
| 87 | + - Guid: 1234 |
| 88 | + Counters: [ 100, 2000 ] |
72 | 89 | ;--- example.ll |
73 | 90 | declare void @bar() |
74 | 91 |
|
|
0 commit comments