xref: /llvm-project/bolt/test/X86/reader-stale-yaml-std.test (revision 58004e5bb74de607f2f81649fd5a8db3ee318528)
1# UNSUPPORTED: true
2## This script checks that YamlProfileReader in llvm-bolt is reading data
3## correctly and stale data is corrected by profile inference.
4
5RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
6RUN: llvm-bolt %t.exe -o %t.null -b %p/Inputs/blarge_profile_stale.std-hash.yaml \
7RUN:   --print-cfg --print-only=usqrt,SolveCubic --infer-stale-profile=1 -v=1 \
8RUN:   2>&1 | FileCheck %s
9
10## Verify that yaml reader works as expected.
11CHECK: pre-processing profile using YAML profile reader
12CHECK: BOLT-INFO: YAML profile with hash: std::hash
13
14## Function "SolveCubic" has stale profile, since there is one jump in the
15## profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
16## verifies that the inference is able to match two blocks (bid=1 and bid=13)
17## using "loose" hashes and then correctly propagate the counts.
18
19CHECK: Binary Function "SolveCubic" after building cfg {
20CHECK:   State       : CFG constructed
21CHECK:   Address     : 0x400e00
22CHECK:   Size        : 0x368
23CHECK:   Section     : .text
24CHECK:   IsSimple    : 1
25CHECK:   BB Count    : 18
26CHECK:   Exec Count  : 151
27CHECK:   Branch Count: 552
28CHECK: }
29## Verify block counts.
30CHECK: .LBB00 (43 instructions, align : 1)
31CHECK:   Successors: .Ltmp[[#BB07:]] (mispreds: 0, count: 0), .LFT[[#BB01:]] (mispreds: 0, count: 151)
32CHECK: .LFT[[#BB01:]] (5 instructions, align : 1)
33CHECK:   Successors: .Ltmp[[#BB013:]] (mispreds: 0, count: 151), .LFT[[#BB02:]] (mispreds: 0, count: 0)
34CHECK: .Ltmp[[#BB03:]] (26 instructions, align : 1)
35CHECK:   Successors: .Ltmp[[#BB05:]] (mispreds: 0, count: 151), .LFT[[#BB04:]] (mispreds: 0, count: 0)
36CHECK: .Ltmp[[#BB05:]] (9 instructions, align : 1)
37CHECK: .Ltmp[[#BB013:]] (12 instructions, align : 1)
38CHECK:   Successors: .Ltmp[[#BB03:]] (mispreds: 0, count: 151)
39CHECK: End of Function "SolveCubic"
40
41## Function "usqrt" has stale profile, since the number of blocks in the profile
42## (nblocks=6) does not match the size of the CFG in the binary. The entry
43## block (bid=0) has an incorrect (missing) count, which should be inferred by
44# #the algorithm.
45
46CHECK: Binary Function "usqrt" after building cfg {
47CHECK:   State       : CFG constructed
48CHECK:   Address     : 0x401170
49CHECK:   Size        : 0x43
50CHECK:   Section     : .text
51CHECK:   IsSimple    : 1
52CHECK:   BB Count    : 5
53CHECK:   Exec Count  : 20
54CHECK:   Branch Count: 640
55CHECK: }
56## Verify block counts.
57CHECK: .LBB01 (4 instructions, align : 1)
58CHECK:   Successors: .Ltmp[[#BB113:]] (mispreds: 0, count: 20)
59CHECK: .Ltmp[[#BB113:]] (9 instructions, align : 1)
60CHECK:   Successors: .Ltmp[[#BB112:]] (mispreds: 0, count: 320), .LFT[[#BB10:]] (mispreds: 0, count: 0)
61CHECK: .LFT[[#BB10:]] (2 instructions, align : 1)
62CHECK:   Successors: .Ltmp[[#BB112:]] (mispreds: 0, count: 0)
63CHECK: .Ltmp[[#BB112:]] (2 instructions, align : 1)
64CHECK:   Successors: .Ltmp[[#BB113:]] (mispreds: 0, count: 300), .LFT[[#BB11:]] (mispreds: 0, count: 20)
65CHECK: .LFT[[#BB11:]] (2 instructions, align : 1)
66CHECK: End of Function "usqrt"
67## Check the overall inference stats.
68CHECK: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
69CHECK: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})
70