1 # This script checks that YamlProfileReader in llvm-bolt is reading data
2 # correctly and stale data is corrected by profile inference.
4 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
6 RUN: llvm-bolt %t.exe -o /dev/null --b %p/Inputs/blarge_profile_stale.yaml \
7 RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 \
8 RUN: --profile-ignore-hash=1 --profile-use-dfs=0 2>&1 | FileCheck %s -check-prefix=CHECK1
10 RUN: llvm-bolt %t.exe -o /dev/null --b %p/Inputs/blarge_profile_stale.yaml \
11 RUN: --print-cfg --print-only=SolveCubic --infer-stale-profile=1 \
12 RUN: --profile-ignore-hash=1 --profile-use-dfs=0 2>&1 | FileCheck %s -check-prefix=CHECK2
14 # Function "usqrt" has stale profile, since the number of blocks in the profile
15 # (nblocks=6) does not match the size of the CFG in the binary. The entry
16 # block (bid=0) has an incorrect (missing) count, which should be inferred by
19 # Verify that yaml reader works as expected.
20 CHECK1: pre-processing profile using YAML profile reader
21 CHECK1: Binary Function "usqrt" after building cfg {
22 CHECK1: State : CFG constructed
23 CHECK1: Address : 0x401170
25 CHECK1: Section : .text
28 CHECK1: Exec Count : 20
29 CHECK1: Branch Count: 640
31 # Verify block counts.
32 CHECK1: .LBB01 (4 instructions, align : 1)
33 CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 20)
34 CHECK1: .Ltmp[[#BB13:]] (9 instructions, align : 1)
35 CHECK1: Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 320), .LFT[[#BB0:]] (mispreds: 0, count: 0)
36 CHECK1: .LFT[[#BB0:]] (2 instructions, align : 1)
37 CHECK1: Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 0)
38 CHECK1: .Ltmp[[#BB12:]] (2 instructions, align : 1)
39 CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 300), .LFT[[#BB1:]] (mispreds: 0, count: 20)
40 CHECK1: .LFT[[#BB1:]] (2 instructions, align : 1)
41 # Check the overall inference stats.
42 CHECK1: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
43 CHECK1: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})
46 # Function "SolveCubic" has stale profile, since there is one jump in the
47 # profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
48 # verifies that the inference is able to match two blocks (bid=1 and bid=13)
49 # using "loose" hashes and then correctly propagate the counts.
51 CHECK2: pre-processing profile using YAML profile reader
52 CHECK2: Binary Function "SolveCubic" after building cfg {
53 CHECK2: State : CFG constructed
54 CHECK2: Address : 0x400e00
56 CHECK2: Section : .text
59 CHECK2: Exec Count : 151
60 CHECK2: Branch Count: 552
61 # Verify block counts.
62 CHECK2: .LBB00 (43 instructions, align : 1)
63 CHECK2: Successors: .Ltmp[[#BB7:]] (mispreds: 0, count: 0), .LFT[[#BB1:]] (mispreds: 0, count: 151)
64 CHECK2: .LFT[[#BB1:]] (5 instructions, align : 1)
65 CHECK2: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 151), .LFT[[#BB2:]] (mispreds: 0, count: 0)
66 CHECK2: .Ltmp[[#BB3:]] (26 instructions, align : 1)
67 CHECK2: Successors: .Ltmp[[#BB5:]] (mispreds: 0, count: 151), .LFT[[#BB4:]] (mispreds: 0, count: 0)
68 CHECK2: .Ltmp[[#BB5:]] (9 instructions, align : 1)
69 CHECK2: .Ltmp[[#BB13:]] (12 instructions, align : 1)
70 CHECK2: Successors: .Ltmp[[#BB3:]] (mispreds: 0, count: 151)
71 CHECK2: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile