llvm/compiler-rt/test/memprof/CMakeLists.txt
Teresa Johnson 3d4bba302d [MemProf] Memory profiling runtime support
See RFC for background:
http://lists.llvm.org/pipermail/llvm-dev/2020-June/142744.html

Follow on companion to the clang/llvm instrumentation support in D85948
and committed earlier.

This patch adds the compiler-rt runtime support for the memory
profiling.

Note that much of this support was cloned from asan (and then greatly
simplified and renamed). For example the interactions with the
sanitizer_common allocators, error handling, interception, etc.

The bulk of the memory profiling specific code can be found in the
MemInfoBlock, MemInfoBlockCache, and related classes defined and used
in memprof_allocator.cpp.

For now, the memory profile is dumped to text (stderr by default, but
honors the sanitizer_common log_path flag). It is dumped in either a
default verbose format, or an optional terse format.

This patch also adds a set of tests for the core functionality.

Differential Revision: https://reviews.llvm.org/D87120
2020-10-16 09:47:02 -07:00

61 lines
2.1 KiB
CMake

set(MEMPROF_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(MEMPROF_TESTSUITES)
set(MEMPROF_DYNAMIC_TESTSUITES)
macro(get_bits_for_arch arch bits)
if (${arch} MATCHES "x86_64")
set(${bits} 64)
else()
message(FATAL_ERROR "Unexpected target architecture: ${arch}")
endif()
endmacro()
set(MEMPROF_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
if(NOT COMPILER_RT_STANDALONE_BUILD)
list(APPEND MEMPROF_TEST_DEPS memprof)
if(COMPILER_RT_HAS_LLD AND TARGET lld)
list(APPEND MEMPROF_TEST_DEPS lld)
endif()
endif()
set(MEMPROF_DYNAMIC_TEST_DEPS ${MEMPROF_TEST_DEPS})
set(MEMPROF_TEST_ARCH ${MEMPROF_SUPPORTED_ARCH})
foreach(arch ${MEMPROF_TEST_ARCH})
set(MEMPROF_TEST_TARGET_ARCH ${arch})
string(TOLOWER "-${arch}-${OS_NAME}" MEMPROF_TEST_CONFIG_SUFFIX)
get_bits_for_arch(${arch} MEMPROF_TEST_BITS)
get_test_cc_for_arch(${arch} MEMPROF_TEST_TARGET_CC MEMPROF_TEST_TARGET_CFLAGS)
set(MEMPROF_TEST_DYNAMIC False)
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
)
list(APPEND MEMPROF_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
string(TOLOWER "-${arch}-${OS_NAME}-dynamic" MEMPROF_TEST_CONFIG_SUFFIX)
set(MEMPROF_TEST_DYNAMIC True)
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
list(APPEND MEMPROF_DYNAMIC_TESTSUITES
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
endforeach()
add_lit_testsuite(check-memprof "Running the MemProfiler tests"
${MEMPROF_TESTSUITES}
DEPENDS ${MEMPROF_TEST_DEPS})
set_target_properties(check-memprof PROPERTIES FOLDER "Compiler-RT Misc")
add_lit_testsuite(check-memprof-dynamic
"Running the MemProfiler tests with dynamic runtime"
${MEMPROF_DYNAMIC_TESTSUITES}
${exclude_from_check_all.g}
DEPENDS ${MEMPROF_DYNAMIC_TEST_DEPS})
set_target_properties(check-memprof-dynamic
PROPERTIES FOLDER "Compiler-RT Misc")