1 # This script checks that YamlProfileReader in llvm-bolt is reading data
2 # correctly and stale data is corrected by profile inference.
5 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
7 RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
8 RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 \
9 RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK1
10 # Testing "SolveCubic"
11 RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
12 RUN: --print-cfg --print-only=SolveCubic --infer-stale-profile=1 \
13 RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK2
15 # Function "usqrt" has stale profile, since the number of blocks in the profile
16 # (nblocks=6) does not match the size of the CFG in the binary. The entry
17 # block (bid=0) has an incorrect (missing) count, which should be inferred by
20 # Verify inference details.
21 CHECK1: pre-processing profile using YAML profile reader
22 CHECK1: applying profile inference for "usqrt"
23 CHECK1: Matched yaml block (bid = 0) with hash 1111111111111111 to BB (index = 0) with hash 36007ba1d80c0000
24 CHECK1-NEXT: loose match
25 CHECK1: Matched yaml block (bid = 1) with hash d70d7a64320e0010 to BB (index = 1) with hash d70d7a64320e0010
26 CHECK1-NEXT: exact match
27 CHECK1: Matched yaml block (bid = 3) with hash 5c06705524800039 to BB (index = 3) with hash 5c06705524800039
28 CHECK1-NEXT: exact match
30 # Verify that yaml reader works as expected.
31 CHECK1: Binary Function "usqrt" after building cfg {
32 CHECK1: State : CFG constructed
33 CHECK1: Address : 0x401170
35 CHECK1: Section : .text
38 CHECK1: Exec Count : 20
39 CHECK1: Branch Count: 640
42 # Verify block counts.
43 CHECK1: .LBB01 (4 instructions, align : 1)
44 CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 20)
45 CHECK1: .Ltmp[[#BB13:]] (9 instructions, align : 1)
46 CHECK1: Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 320), .LFT[[#BB0:]] (mispreds: 0, count: 0)
47 CHECK1: .LFT[[#BB0:]] (2 instructions, align : 1)
48 CHECK1: Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 0)
49 CHECK1: .Ltmp[[#BB12:]] (2 instructions, align : 1)
50 CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 300), .LFT[[#BB1:]] (mispreds: 0, count: 20)
51 CHECK1: .LFT[[#BB1:]] (2 instructions, align : 1)
52 # Check the overall inference stats.
53 CHECK1: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
54 CHECK1: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})
57 # Function "SolveCubic" has stale profile, since there is one jump in the
58 # profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
59 # verifies that the inference is able to match two blocks (bid=1 and bid=13)
60 # using "loose" hashes and then correctly propagate the counts.
62 # Verify inference details.
63 CHECK2: pre-processing profile using YAML profile reader
64 CHECK2: applying profile inference for "SolveCubic"
65 CHECK2: Matched yaml block (bid = 0) with hash 4600940a609c0000 to BB (index = 0) with hash 4600940a609c0000
66 CHECK2-NEXT: exact match
67 CHECK2: Matched yaml block (bid = 1) with hash 167a1f084f130088 to BB (index = 1) with hash 167a1f084f130088
68 CHECK2-NEXT: exact match
69 CHECK2: Matched yaml block (bid = 13) with hash a8d50000f81902a7 to BB (index = 13) with hash a8d5aa43f81902a7
70 CHECK2-NEXT: loose match
71 CHECK2: Matched yaml block (bid = 3) with hash c516000073dc00a0 to BB (index = 3) with hash c516b1c973dc00a0
72 CHECK2-NEXT: loose match
73 CHECK2: Matched yaml block (bid = 5) with hash 6446e1ea500111 to BB (index = 5) with hash 6446e1ea500111
74 CHECK2-NEXT: exact match
76 # Verify that yaml reader works as expected.
77 CHECK2: Binary Function "SolveCubic" after building cfg {
78 CHECK2: State : CFG constructed
79 CHECK2: Address : 0x400e00
81 CHECK2: Section : .text
84 CHECK2: Exec Count : 151
85 CHECK2: Branch Count: 552
87 # Verify block counts.
88 CHECK2: .LBB00 (43 instructions, align : 1)
89 CHECK2: Successors: .Ltmp[[#BB7:]] (mispreds: 0, count: 0), .LFT[[#BB1:]] (mispreds: 0, count: 151)
90 CHECK2: .LFT[[#BB1:]] (5 instructions, align : 1)
91 CHECK2: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 151), .LFT[[#BB2:]] (mispreds: 0, count: 0)
92 CHECK2: .Ltmp[[#BB3:]] (26 instructions, align : 1)
93 CHECK2: Successors: .Ltmp[[#BB5:]] (mispreds: 0, count: 151), .LFT[[#BB4:]] (mispreds: 0, count: 0)
94 CHECK2: .Ltmp[[#BB5:]] (9 instructions, align : 1)
95 CHECK2: .Ltmp[[#BB13:]] (12 instructions, align : 1)
96 CHECK2: Successors: .Ltmp[[#BB3:]] (mispreds: 0, count: 151)
97 CHECK2: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile