1 ## This script checks that perf2bolt is reading pre-aggregated perf information
2 ## correctly for a simple example. The perf.data of this example was generated
3 ## with the following command:
5 ## $ perf record -j any,u -e branch -o perf.data -- ./blarge
7 ## blarge is the binary for "basicmath large inputs" taken from Mibench.
9 ## Currently failing in MacOS / generating different hash for usqrt
10 REQUIRES: system-linux
12 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
13 RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \
15 RUN: --profile-density-threshold=9 --profile-density-cutoff-hot=970000 \
16 RUN: --profile-use-dfs | FileCheck %s --check-prefix=CHECK-P2B
18 CHECK-P2B: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
19 CHECK-P2B: BOLT-INFO: Functions with density >= 21.7 account for 97.00% total sample counts.
21 RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \
23 RUN: --profile-density-cutoff-hot=970000 \
24 RUN: --profile-use-dfs 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING
26 CHECK-WARNING: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
27 CHECK-WARNING: BOLT-WARNING: BOLT is estimated to optimize better with 2.8x more samples.
28 CHECK-WARNING: BOLT-INFO: Functions with density >= 21.7 account for 97.00% total sample counts.
30 RUN: llvm-bolt %t.exe -data %t -o %t.null | FileCheck %s
31 RUN: llvm-bolt %t.exe -data %t.new -o %t.null | FileCheck %s
32 RUN: llvm-bolt %t.exe -p %p/Inputs/pre-aggregated.txt --pa -o %t.null | FileCheck %s
34 CHECK: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile
36 RUN: cat %t | sort | FileCheck %s -check-prefix=PERF2BOLT
37 RUN: cat %t.new | FileCheck %s -check-prefix=NEWFORMAT
39 ## Test --profile-format option with perf2bolt
40 RUN: perf2bolt %t.exe -o %t.fdata --pa -p %p/Inputs/pre-aggregated.txt \
41 RUN: --profile-format=fdata
42 RUN: cat %t.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT
44 RUN: perf2bolt %t.exe -o %t.yaml --pa -p %p/Inputs/pre-aggregated.txt \
45 RUN: --profile-format=yaml --profile-use-dfs
46 RUN: cat %t.yaml | FileCheck %s -check-prefix=NEWFORMAT
48 ## Test --profile-format option with llvm-bolt --aggregate-only
49 RUN: llvm-bolt %t.exe -o %t.bolt.fdata --pa -p %p/Inputs/pre-aggregated.txt \
50 RUN: --aggregate-only --profile-format=fdata
51 RUN: cat %t.bolt.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT
53 RUN: llvm-bolt %t.exe -o %t.bolt.yaml --pa -p %p/Inputs/pre-aggregated.txt \
54 RUN: --aggregate-only --profile-format=yaml --profile-use-dfs
55 RUN: cat %t.bolt.yaml | FileCheck %s -check-prefix=NEWFORMAT
57 PERF2BOLT: 0 [unknown] 7f36d18d60c0 1 main 53c 0 2
58 PERF2BOLT: 1 main 451 1 SolveCubic 0 0 2
59 PERF2BOLT: 1 main 490 0 [unknown] 4005f0 0 1
60 PERF2BOLT: 1 main 537 0 [unknown] 400610 0 1
61 PERF2BOLT: 1 usqrt 30 1 usqrt 32 0 22
62 PERF2BOLT: 1 usqrt 30 1 usqrt 39 4 33
63 PERF2BOLT: 1 usqrt 35 1 usqrt 39 0 22
64 PERF2BOLT: 1 usqrt 3d 1 usqrt 10 0 58
65 PERF2BOLT: 1 usqrt 3d 1 usqrt 3f 0 22
66 PERF2BOLT: 1 usqrt a 1 usqrt 10 0 22
68 NEWFORMAT: - name: 'frame_dummy/1'
70 NEWFORMAT: hash: 0x28C72085C0BD8D37
73 NEWFORMAT: - name: usqrt
80 NEWFORMAT: succ: [ { bid: 1, cnt: 22 } ]
83 NEWFORMAT: succ: [ { bid: 3, cnt: 33, mis: 4 }, { bid: 2, cnt: 22 } ]
86 NEWFORMAT: succ: [ { bid: 3, cnt: 22 } ]
89 NEWFORMAT: succ: [ { bid: 1, cnt: 58 }, { bid: 4, cnt: 22 } ]