xref: /llvm-project/bolt/test/runtime/meta-merge-fdata.test (revision 6678f602c243fe8a9c9db9d02b162f02ecec5173)
1# Meta test using merge-fdata binary
2UNSUPPORTED: asan
3# Instrumentation currently only works on X86
4REQUIRES: x86_64-linux,bolt-runtime
5
6# Instrumentation, should test:
7# - Direct branches
8# - Unmapped calls coming from uninstrumented code (libc)
9# - Direct calls
10RUN: llvm-bolt merge-fdata -o %t.inst --instrument \
11RUN:   --instrumentation-file=%t.fdata
12
13# Execute with no input
14RUN: %t.inst --version
15RUN: mv %t.fdata %t.fdata1
16
17# Check unmapped calls coverage - libc should be calling _start via
18# uninstrumented code
19RUN: cat %t.fdata1 | FileCheck %s --check-prefix=CHECK-FDATA
20CHECK-FDATA: 0 [unknown] 0 1 _start 0 0 1
21
22# Check that BOLT works with this profile
23RUN: llvm-bolt merge-fdata -o %t.bolt --data %t.fdata1 \
24RUN:   --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
25RUN:   --split-functions 2>&1 \
26RUN:   | FileCheck %s --check-prefix=CHECK-BOLT1
27CHECK-BOLT1-NOT: invalid (possibly stale) profile
28
29# Execute again
30RUN: %t.inst --help
31RUN: mv %t.fdata %t.fdata2
32
33# Check profile coverage
34RUN: llvm-boltdiff merge-fdata merge-fdata \
35RUN:   --data %t.fdata1 --data2 %t.fdata2 --display-count=20 | \
36RUN:   FileCheck %s --check-prefix=CHECK-BOLTDIFF
37CHECK-BOLTDIFF: Inputs share [[#]] functions
38
39# Check that instrumented binary produces the same result
40RUN: merge-fdata %t.fdata1 %t.fdata2 > %t.fdata.base
41RUN: %t.inst %t.fdata1 %t.fdata2 > %t.fdata.inst
42RUN: cmp %t.fdata.base %t.fdata.inst
43
44# Optimize using merged fdata
45RUN: llvm-bolt merge-fdata -o %t.opt --data %t.fdata.base \
46RUN:   --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
47RUN:   --split-functions 2>&1 \
48RUN:   | FileCheck %s --check-prefix=CHECK-BOLT2
49CHECK-BOLT2-NOT: invalid (possibly stale) profile
50
51# Check that optimized binary produces the same result
52RUN: %t.opt %t.fdata1 %t.fdata2 > %t.fdata.opt
53RUN: cmp %t.fdata.base %t.fdata.opt
54