brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 4c6e9c2 Raw
111 lines · plain
1## This script checks that YamlProfileReader in llvm-bolt is reading data2## correctly and stale data is corrected by profile inference.3 4REQUIRES: asserts5RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe6RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \7RUN:   --infer-stale-profile=0 --profile-ignore-hash=1 --profile-use-dfs=0 \8RUN:   2>&1 | FileCheck %s -check-prefix=CHECK09## Testing "usqrt"10RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \11RUN:   --print-cfg --print-only=usqrt --infer-stale-profile=1 \12RUN:   --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK113## Testing "SolveCubic"14RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \15RUN:   --print-cfg --print-only=SolveCubic --infer-stale-profile=1 \16RUN:   --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK217## Testing skipped function18RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \19RUN:   --print-cfg --print-only=usqrt --infer-stale-profile=1 --skip-funcs=usqrt \20RUN:   --profile-ignore-hash=1 --profile-use-dfs=021 22CHECK0: BOLT-INFO: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile23CHECK0: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile24CHECK0: BOLT-WARNING: 1192 out of 1192 samples in the binary (100.0%) belong to functions with invalid (possibly stale) profile25 26## Function "usqrt" has stale profile, since the number of blocks in the profile27## (nblocks=6) does not match the size of the CFG in the binary. The entry28## block (bid=0) has an incorrect (missing) count, which should be inferred by29## the algorithm.30 31## Verify inference details.32CHECK1:  pre-processing profile using YAML profile reader33CHECK1:  applying profile inference for "usqrt"34CHECK1: Matched yaml block (bid = 0) with hash 1111111111111111 to BB (index = 0) with hash 36007ba1d80c000035CHECK1-NEXT: loose match36CHECK1:  Matched yaml block (bid = 1) with hash d70d7a64320e0010 to BB (index = 1) with hash d70d7a64320e001037CHECK1-NEXT: exact match38CHECK1:  Matched yaml block (bid = 3) with hash 5c06705524800039 to BB (index = 3) with hash 5c0670552480003939CHECK1-NEXT: exact match40 41## Verify that yaml reader works as expected.42CHECK1:    Binary Function "usqrt" after building cfg {43CHECK1:      State       : CFG constructed44CHECK1:      Address     : 0x40117045CHECK1:      Size        : 0x4346CHECK1:      Section     : .text47CHECK1:      IsSimple    : 148CHECK1:      BB Count    : 549CHECK1:      Exec Count  : 2050CHECK1:      Sample Count: 64051CHECK1:    }52 53## Verify block counts.54CHECK1:    .LBB01 (4 instructions, align : 1)55CHECK1:      Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 20)56CHECK1:    .Ltmp[[#BB13:]] (9 instructions, align : 1)57CHECK1:      Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 320), .LFT[[#BB0:]] (mispreds: 0, count: 0)58CHECK1:    .LFT[[#BB0:]] (2 instructions, align : 1)59CHECK1:      Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 0)60CHECK1:    .Ltmp[[#BB12:]] (2 instructions, align : 1)61CHECK1:      Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 300), .LFT[[#BB1:]] (mispreds: 0, count: 20)62CHECK1:    .LFT[[#BB1:]] (2 instructions, align : 1)63## Check the overall inference stats.64CHECK1:  2 out of 7 functions in the binary (28.6%) have non-empty execution profile65CHECK1:  BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile66CHECK1:  BOLT-WARNING: 1192 out of 1192 samples in the binary (100.0%) belong to functions with invalid (possibly stale) profile67CHECK1:  inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})68 69 70## Function "SolveCubic" has stale profile, since there is one jump in the71## profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test72## verifies that the inference is able to match two blocks (bid=1 and bid=13)73## using "loose" hashes and then correctly propagate the counts.74 75## Verify inference details.76CHECK2:  pre-processing profile using YAML profile reader77CHECK2:  applying profile inference for "SolveCubic"78CHECK2:  Matched yaml block (bid = 0) with hash 4600940a609c0000 to BB (index = 0) with hash 4600940a609c000079CHECK2-NEXT:  exact match80CHECK2:  Matched yaml block (bid = 13) with hash a8d50000f81902a7 to BB (index = 13) with hash a8d5aa43f81902a781CHECK2-NEXT:  loose match82CHECK2:  Matched yaml block (bid = 1) with hash 167a1f084f130088 to BB (index = 1) with hash 167a1f084f13008883CHECK2-NEXT:  exact match84CHECK2:  Matched yaml block (bid = 3) with hash c516000073dc00a0 to BB (index = 3) with hash c516b1c973dc00a085CHECK2-NEXT:  loose match86CHECK2:  Matched yaml block (bid = 5) with hash 6446e1ea500111 to BB (index = 5) with hash 6446e1ea50011187CHECK2-NEXT:  exact match88 89## Verify that yaml reader works as expected.90CHECK2:    Binary Function "SolveCubic" after building cfg {91CHECK2:      State       : CFG constructed92CHECK2:      Address     : 0x400e0093CHECK2:      Size        : 0x36894CHECK2:      Section     : .text95CHECK2:      IsSimple    : 196CHECK2:      BB Count    : 1897CHECK2:      Exec Count  : 15198CHECK2:      Sample Count: 55299 100## Verify block counts.101CHECK2:    .LBB00 (43 instructions, align : 1)102CHECK2:      Successors: .Ltmp[[#BB7:]] (mispreds: 0, count: 0), .LFT[[#BB1:]] (mispreds: 0, count: 151)103CHECK2:    .LFT[[#BB1:]] (5 instructions, align : 1)104CHECK2:      Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 151), .LFT[[#BB2:]] (mispreds: 0, count: 0)105CHECK2:    .Ltmp[[#BB3:]] (26 instructions, align : 1)106CHECK2:      Successors: .Ltmp[[#BB5:]] (mispreds: 0, count: 151), .LFT[[#BB4:]] (mispreds: 0, count: 0)107CHECK2:    .Ltmp[[#BB5:]] (9 instructions, align : 1)108CHECK2:    .Ltmp[[#BB13:]] (12 instructions, align : 1)109CHECK2:      Successors: .Ltmp[[#BB3:]] (mispreds: 0, count: 151)110CHECK2:  2 out of 7 functions in the binary (28.6%) have non-empty execution profile111