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