[ESan] EfficiencySanitizer implementation. 59/174159/9
authorDenis Khalikov <d.khalikov@partner.samsung.com>
Wed, 24 Jan 2018 10:55:22 +0000 (13:55 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 19 Jul 2018 09:01:05 +0000 (18:01 +0900)
commit44b748e6c5d1b10696e9bfa3256f13ced23c4e5e
treef12abaa48bb491f8b8e286deef5c1c0d6e3e399a
parent2a2c39cdfa172cbac364069947a3b9e4fe84e8e7
[ESan] EfficiencySanitizer implementation.

EfficiencySanitizer (WorkingSet tool and CacheFragmentation tool)
implementation for X86_64 and armv7l.

The ESan is a set of compiler-based tools for analyzing targeted
performance problems.

This patch includes:

1. GCC pass.

1.1. GCC pass for WorkingSet tool.
Special compiler pass instruments every memory access in the program.
Memory accesses are simply prepended with a function call like
__esan_aligned_load(addr), __esan_aligned_store(addr).

1.2. GCC pass for CacheFragmentation tool.
Special compiler pass instruments every memory access to the struct
field. Creates fields counter array, each cell of that array
counts memory access to the special field. Creates array of
struct, where every instance of the struct represetnts meta info
of the real struct and so on.

A call to __esan_init is inserted to the static constructor.
A call to __esan_exit is inserted to the static destructor.

2. Runtime library.

2.1. WorkingSet tool.
The runtime library simply manages shadow memory and computes statistic
of the program efficiency. The tool maps one cashe line (64 bytes) of
the program to the one byte of the shadow memory. Runtime library measures
the data working set size of an application at each snapshot during
execution. It can help understand phased behavior as well as providing basic
direction for futher effort by the developer: e.g., knowing whether the working
set is close to fitting in current L3 cashes or is many times larger can help
to determine where to spend effort.

2.2. CacheFragmentation tool.
The runtime part prints statistics about an amount of field accesses and
detailed information about which field was actually accessed.

3. Testsuite.
Simple testsuite.

4. HOW TO USE:

4.1. WorkingSet tool.
To measure the working set size, you should build your binary or shared library
with compile time flag -fsanitize=efficiency-working-set and
set runtime options ESAN_OPTIONS=process_range_access=1:record_snapshots=1

4.2. CacheFragmentation tool.
To enable CacheFragmentation tool you should compile your binary or
shared library with compile time flag -fsanitize=efficiency-cache-frag
and set runtime options ESAN_OPTIONS=build_mode=0:verbosity=1

Change-Id: Ie3231d3defa183712997e6fca39b1e8b4586e9b7
61 files changed:
gcc/Makefile.in
gcc/builtins.def
gcc/esan.c [new file with mode: 0644]
gcc/esan.h [new file with mode: 0644]
gcc/flag-types.h
gcc/gcc.c
gcc/internal-fn.c
gcc/internal-fn.def
gcc/opts.c
gcc/passes.def
gcc/sanitizer.def
gcc/sanopt.c
gcc/testsuite/g++.dg/esan/cache-fragmentation.C [new file with mode: 0644]
gcc/testsuite/g++.dg/esan/esan.exp [new file with mode: 0644]
gcc/testsuite/g++.dg/esan/unalignet.C [new file with mode: 0644]
gcc/testsuite/g++.dg/esan/workingset-simple.C [new file with mode: 0644]
gcc/testsuite/lib/esan-dg.exp [new file with mode: 0644]
gcc/toplev.c
gcc/tree-pass.h
gcc/tree-ssa-alias.c
libsanitizer/Makefile.am
libsanitizer/Makefile.in
libsanitizer/asan/Makefile.in
libsanitizer/configure
libsanitizer/configure.ac
libsanitizer/configure.tgt
libsanitizer/esan/Makefile.am [new file with mode: 0644]
libsanitizer/esan/Makefile.in [new file with mode: 0644]
libsanitizer/esan/cache_frag.cpp [new file with mode: 0644]
libsanitizer/esan/cache_frag.h [new file with mode: 0644]
libsanitizer/esan/esan.cpp [new file with mode: 0644]
libsanitizer/esan/esan.h [new file with mode: 0644]
libsanitizer/esan/esan.syms.extra [new file with mode: 0644]
libsanitizer/esan/esan_circular_buffer.h [new file with mode: 0644]
libsanitizer/esan/esan_flags.cpp [new file with mode: 0644]
libsanitizer/esan/esan_flags.h [new file with mode: 0644]
libsanitizer/esan/esan_flags.inc [new file with mode: 0644]
libsanitizer/esan/esan_hashtable.h [new file with mode: 0644]
libsanitizer/esan/esan_interceptors.cpp [new file with mode: 0644]
libsanitizer/esan/esan_interface.cpp [new file with mode: 0644]
libsanitizer/esan/esan_interface_internal.h [new file with mode: 0644]
libsanitizer/esan/esan_linux.cpp [new file with mode: 0644]
libsanitizer/esan/esan_shadow.h [new file with mode: 0644]
libsanitizer/esan/esan_sideline.h [new file with mode: 0644]
libsanitizer/esan/esan_sideline_linux.cpp [new file with mode: 0644]
libsanitizer/esan/libtool-version [new file with mode: 0644]
libsanitizer/esan/working_set.cpp [new file with mode: 0644]
libsanitizer/esan/working_set.h [new file with mode: 0644]
libsanitizer/esan/working_set_posix.cpp [new file with mode: 0644]
libsanitizer/include/esan_interface.h [new file with mode: 0644]
libsanitizer/interception/Makefile.in
libsanitizer/libbacktrace/Makefile.in
libsanitizer/libsanitizer.spec.in
libsanitizer/lsan/Makefile.in
libsanitizer/sanitizer_common/Makefile.in
libsanitizer/tsan/Makefile.in
libsanitizer/ubsan/Makefile.in
packaging/gcc-aarch64.spec
packaging/gcc-armv7hl.spec
packaging/gcc-armv7l.spec
packaging/linaro-gcc.spec