mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 22:30:13 +00:00
[BOLT][TEST] Add instrumentation test using merge-fdata
Summary: BOLT meta test using merge-fdata tool. This tests BOLT instrumentation for a non-trivial binary, running instrumented binary, and using the instrumentation profile for BOLT optimizations. The results are verified between original, instrumented, and optimized binaries. Additional tested features: boltdiff mode and merge-fdata for two profiles. merge-fdata tool is linked with relocs on Linux to support this test. (cherry picked from FBD32141812)
This commit is contained in:
parent
f808ea00bd
commit
d1df113e30
@ -78,6 +78,7 @@ tools = [
|
|||||||
ToolSubst('llvm-strip', unresolved='fatal'),
|
ToolSubst('llvm-strip', unresolved='fatal'),
|
||||||
ToolSubst('llvm-readelf', unresolved='fatal'),
|
ToolSubst('llvm-readelf', unresolved='fatal'),
|
||||||
ToolSubst('link_fdata', command=FindTool('link_fdata.sh'), unresolved='fatal'),
|
ToolSubst('link_fdata', command=FindTool('link_fdata.sh'), unresolved='fatal'),
|
||||||
|
ToolSubst('merge-fdata', unresolved='fatal'),
|
||||||
]
|
]
|
||||||
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
||||||
|
|
||||||
|
3
bolt/test/runtime/lit.local.cfg
Normal file
3
bolt/test/runtime/lit.local.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Tests are not expected to pass in a cross-compilation setup.
|
||||||
|
if not {'native', 'system-linux'}.issubset(config.available_features):
|
||||||
|
config.unsupported = True
|
50
bolt/test/runtime/meta-merge-fdata.test
Normal file
50
bolt/test/runtime/meta-merge-fdata.test
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Meta test using merge-fdata binary
|
||||||
|
UNSUPPORTED: asan
|
||||||
|
# Instrumentation currently only works on X86
|
||||||
|
REQUIRES: x86_64-linux
|
||||||
|
|
||||||
|
# Instrumentation, should test:
|
||||||
|
# - Direct branches
|
||||||
|
# - Unmapped calls coming from uninstrumented code (libc)
|
||||||
|
# - Direct calls
|
||||||
|
RUN: llvm-bolt merge-fdata -o %t.inst -instrument -instrumentation-file=%t.fdata
|
||||||
|
|
||||||
|
# Execute with no input
|
||||||
|
RUN: %t.inst --version
|
||||||
|
RUN: mv %t.fdata %t.fdata1
|
||||||
|
|
||||||
|
# Check unmapped calls coverage - libc should be calling _start via
|
||||||
|
# uninstrumented code
|
||||||
|
RUN: cat %t.fdata1 | FileCheck %s --check-prefix=CHECK-FDATA
|
||||||
|
CHECK-FDATA: 0 [unknown] 0 1 _start 0 0 1
|
||||||
|
|
||||||
|
# Check that BOLT works with this profile
|
||||||
|
RUN: llvm-bolt merge-fdata -o %t.bolt -data %t.fdata1 \
|
||||||
|
RUN: -reorder-blocks=cache+ -reorder-functions=hfsort+ -split-functions=3 | \
|
||||||
|
RUN: FileCheck %s --check-prefix=CHECK-BOLT1
|
||||||
|
CHECK-BOLT1-NOT: invalid (possibly stale) profile
|
||||||
|
|
||||||
|
# Execute again
|
||||||
|
RUN: %t.inst --help
|
||||||
|
RUN: mv %t.fdata %t.fdata2
|
||||||
|
|
||||||
|
# Check profile coverage
|
||||||
|
RUN: llvm-boltdiff merge-fdata merge-fdata \
|
||||||
|
RUN: -data %t.fdata1 -data2 %t.fdata2 -display-count=20 | \
|
||||||
|
RUN: FileCheck %s --check-prefix=CHECK-BOLTDIFF
|
||||||
|
CHECK-BOLTDIFF: Inputs share [[#]] functions
|
||||||
|
|
||||||
|
# Check that instrumented binary produces the same result
|
||||||
|
RUN: merge-fdata %t.fdata1 %t.fdata2 > %t.fdata.base
|
||||||
|
RUN: %t.inst %t.fdata1 %t.fdata2 > %t.fdata.inst
|
||||||
|
RUN: cmp %t.fdata.base %t.fdata.inst
|
||||||
|
|
||||||
|
# Optimize using merged fdata
|
||||||
|
RUN: llvm-bolt merge-fdata -o %t.opt -data %t.fdata.base \
|
||||||
|
RUN: -reorder-blocks=cache+ -reorder-functions=hfsort+ -split-functions=3 | \
|
||||||
|
RUN: FileCheck %s --check-prefix=CHECK-BOLT2
|
||||||
|
CHECK-BOLT2-NOT: invalid (possibly stale) profile
|
||||||
|
|
||||||
|
# Check that optimized binary produces the same result
|
||||||
|
RUN: %t.opt %t.fdata1 %t.fdata2 > %t.fdata.opt
|
||||||
|
RUN: cmp %t.fdata.base %t.fdata.opt
|
@ -6,3 +6,8 @@ add_llvm_tool(merge-fdata
|
|||||||
DEPENDS
|
DEPENDS
|
||||||
intrinsics_gen
|
intrinsics_gen
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Emit relocations for BOLT meta test (bolt/test/runtime/meta-merge-fdata.test)
|
||||||
|
if (UNIX AND NOT APPLE)
|
||||||
|
target_link_options(merge-fdata PRIVATE LINKER:--emit-relocs)
|
||||||
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user