diff options
author | Shaw Young <58664393+shawbyoung@users.noreply.github.com> | 2024-07-03 11:39:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-03 11:39:18 -0700 |
commit | 97dc50882cbc63d7098e95f73f242185c75c226b (patch) | |
tree | ad0d4eac20567dd6bd0454dc6ad0046143a727c1 /bolt/test | |
parent | 4eecf3c650ea53aa00cae2fe983f95ee6ec6705a (diff) | |
download | llvm-97dc50882cbc63d7098e95f73f242185c75c226b.zip llvm-97dc50882cbc63d7098e95f73f242185c75c226b.tar.gz llvm-97dc50882cbc63d7098e95f73f242185c75c226b.tar.bz2 |
[BOLT] Match functions with name similarity (#95884)
A mapping - from namespace to associated binary functions - is used to
match function profiles to binary based on the
'--name-similarity-function-matching-threshold' flag set edit distance
threshold. The flag is set to 0 (exact name matching) by default as it is
expensive, requiring the processing of all BFs.
Test Plan: Added name-similarity-function-matching.test. On a binary
with 5M functions, rewrite passes took ~520s without the flag and
~2018s with the flag set to 20.
Diffstat (limited to 'bolt/test')
-rw-r--r-- | bolt/test/X86/name-similarity-function-matching.test | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/bolt/test/X86/name-similarity-function-matching.test b/bolt/test/X86/name-similarity-function-matching.test new file mode 100644 index 0000000..97ef4bf --- /dev/null +++ b/bolt/test/X86/name-similarity-function-matching.test @@ -0,0 +1,63 @@ +## Tests function matching in YAMLProfileReader by name similarity. + +# REQUIRES: system-linux +# RUN: split-file %s %t +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib +# RUN: llvm-bolt %t.exe -o %t.out --data %t/yaml -v=2 \ +# RUN: --print-cfg --name-similarity-function-matching-threshold=1 --funcs=main --profile-ignore-hash=0 2>&1 | FileCheck %s + +# CHECK: BOLT-INFO: matched 1 functions with similar names + +#--- main.s +.globl main +.type main, @function +main: + .cfi_startproc +.LBB00: + pushq %rbp + movq %rsp, %rbp + subq $16, %rsp + testq %rax, %rax + js .LBB03 +.LBB01: + jne .LBB04 +.LBB02: + nop +.LBB03: + xorl %eax, %eax + addq $16, %rsp + popq %rbp + retq +.LBB04: + xorl %eax, %eax + addq $16, %rsp + popq %rbp + retq +## For relocations against .text + .reloc 0, R_X86_64_NONE + .cfi_endproc + .size main, .-main + +#--- yaml +--- +header: + profile-version: 1 + binary-name: 'hashing-based-function-matching.s.tmp.exe' + binary-build-id: '<unknown>' + profile-flags: [ lbr ] + profile-origin: branch profile reader + profile-events: '' + dfs-order: false + hash-func: xxh3 +functions: + - name: main2 + fid: 0 + hash: 0x0000000000000001 + exec: 1 + nblocks: 5 + blocks: + - bid: 1 + insns: 1 + succ: [ { bid: 3, cnt: 1} ] +... |