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: 4## 5## $ perf record -j any,u -e branch -o perf.data -- ./blarge 6## 7## blarge is the binary for "basicmath large inputs" taken from Mibench. 8 9## Currently failing in MacOS / generating different hash for usqrt 10REQUIRES: system-linux 11 12RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe 13RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \ 14RUN: --show-density \ 15RUN: --profile-density-threshold=9 --profile-density-cutoff-hot=970000 \ 16RUN: --profile-use-dfs | FileCheck %s --check-prefix=CHECK-P2B 17 18CHECK-P2B: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile 19CHECK-P2B: BOLT-INFO: Functions with density >= 21.7 account for 97.00% total sample counts. 20 21RUN: perf2bolt %t.exe -o %t --pa -p %p/Inputs/pre-aggregated.txt -w %t.new \ 22RUN: --show-density \ 23RUN: --profile-density-cutoff-hot=970000 \ 24RUN: --profile-use-dfs 2>&1 | FileCheck %s --check-prefix=CHECK-WARNING 25 26CHECK-WARNING: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile 27CHECK-WARNING: BOLT-WARNING: BOLT is estimated to optimize better with 2.8x more samples. 28CHECK-WARNING: BOLT-INFO: Functions with density >= 21.7 account for 97.00% total sample counts. 29 30RUN: llvm-bolt %t.exe -data %t -o %t.null | FileCheck %s 31RUN: llvm-bolt %t.exe -data %t.new -o %t.null | FileCheck %s 32RUN: llvm-bolt %t.exe -p %p/Inputs/pre-aggregated.txt --pa -o %t.null | FileCheck %s 33 34CHECK: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty execution profile 35 36RUN: cat %t | sort | FileCheck %s -check-prefix=PERF2BOLT 37RUN: cat %t.new | FileCheck %s -check-prefix=NEWFORMAT 38 39## Test --profile-format option with perf2bolt 40RUN: perf2bolt %t.exe -o %t.fdata --pa -p %p/Inputs/pre-aggregated.txt \ 41RUN: --profile-format=fdata 42RUN: cat %t.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT 43 44RUN: perf2bolt %t.exe -o %t.yaml --pa -p %p/Inputs/pre-aggregated.txt \ 45RUN: --profile-format=yaml --profile-use-dfs 46RUN: cat %t.yaml | FileCheck %s -check-prefix=NEWFORMAT 47 48## Test --profile-format option with llvm-bolt --aggregate-only 49RUN: llvm-bolt %t.exe -o %t.bolt.fdata --pa -p %p/Inputs/pre-aggregated.txt \ 50RUN: --aggregate-only --profile-format=fdata 51RUN: cat %t.bolt.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT 52 53RUN: llvm-bolt %t.exe -o %t.bolt.yaml --pa -p %p/Inputs/pre-aggregated.txt \ 54RUN: --aggregate-only --profile-format=yaml --profile-use-dfs 55RUN: cat %t.bolt.yaml | FileCheck %s -check-prefix=NEWFORMAT 56 57PERF2BOLT: 0 [unknown] 7f36d18d60c0 1 main 53c 0 2 58PERF2BOLT: 1 main 451 1 SolveCubic 0 0 2 59PERF2BOLT: 1 main 490 0 [unknown] 4005f0 0 1 60PERF2BOLT: 1 main 537 0 [unknown] 400610 0 1 61PERF2BOLT: 1 usqrt 30 1 usqrt 32 0 22 62PERF2BOLT: 1 usqrt 30 1 usqrt 39 4 33 63PERF2BOLT: 1 usqrt 35 1 usqrt 39 0 22 64PERF2BOLT: 1 usqrt 3d 1 usqrt 10 0 58 65PERF2BOLT: 1 usqrt 3d 1 usqrt 3f 0 22 66PERF2BOLT: 1 usqrt a 1 usqrt 10 0 22 67 68NEWFORMAT: - name: 'frame_dummy/1' 69NEWFORMAT: fid: 3 70NEWFORMAT: hash: 0x28C72085C0BD8D37 71NEWFORMAT: exec: 1 72 73NEWFORMAT: - name: usqrt 74NEWFORMAT: fid: 7 75NEWFORMAT: exec: 0 76NEWFORMAT: nblocks: 5 77NEWFORMAT: blocks: 78NEWFORMAT: - bid: 0 79NEWFORMAT: insns: 4 80NEWFORMAT: succ: [ { bid: 1, cnt: 22 } ] 81NEWFORMAT: - bid: 1 82NEWFORMAT: insns: 9 83NEWFORMAT: succ: [ { bid: 3, cnt: 33, mis: 4 }, { bid: 2, cnt: 22 } ] 84NEWFORMAT: - bid: 2 85NEWFORMAT: insns: 2 86NEWFORMAT: succ: [ { bid: 3, cnt: 22 } ] 87NEWFORMAT: - bid: 3 88NEWFORMAT: insns: 2 89NEWFORMAT: succ: [ { bid: 1, cnt: 58 }, { bid: 4, cnt: 22 } ] 90