xref: /llvm-project/bolt/test/X86/hashing-based-function-matching.test (revision 49fdbbcfed96a3d7a957a4d9c31ebeb1d3950dd2)
1## Tests function matching in YAMLProfileReader by function hash.
2
3# REQUIRES: system-linux
4# RUN: split-file %s %t
5# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
6# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
7# RUN: llvm-bolt %t.exe -o %t.out --data %t/yaml -v=2 \
8# RUN:   --print-cfg --match-profile-with-function-hash --profile-ignore-hash=0 2>&1 | FileCheck %s
9
10# CHECK: BOLT-INFO: matched 1 functions with hash
11
12#--- main.s
13.globl main
14.type	main, @function
15main:
16  .cfi_startproc
17.LBB00:
18  pushq   %rbp
19  movq    %rsp, %rbp
20  subq    $16, %rsp
21  testq   %rax, %rax
22  js      .LBB03
23.LBB01:
24  jne     .LBB04
25.LBB02:
26  nop
27.LBB03:
28  xorl    %eax, %eax
29  addq    $16, %rsp
30  popq    %rbp
31  retq
32.LBB04:
33  xorl    %eax, %eax
34  addq    $16, %rsp
35  popq    %rbp
36  retq
37## For relocations against .text
38  .reloc 0, R_X86_64_NONE
39  .cfi_endproc
40  .size	main, .-main
41
42#--- yaml
43---
44header:
45  profile-version: 1
46  binary-name:     'hashing-based-function-matching.s.tmp.exe'
47  binary-build-id: '<unknown>'
48  profile-flags:   [ lbr ]
49  profile-origin:  branch profile reader
50  profile-events:  ''
51  dfs-order:       false
52  hash-func:       xxh3
53functions:
54  - name:            main2
55    fid:             0
56    hash:            0x6E7F15254DE2478
57    exec:            1
58    nblocks:         6
59    blocks:
60      - bid:             1
61        insns:           1
62        succ:            [ { bid: 3, cnt: 1} ]
63...
64